busvoodoo_i2c.c File Reference

BusVoodoo I²C mode (code) More...

Go to the source code of this file.

## Macros

#define | BUSVOODOO_I2C I2C2
| I2C peripheral.

## Enumerations

enum | busvoodoo_i2c_setting_t { BUSVOODOO_I2C_SETTING_NONE, BUSVOODOO_I2C_SETTING_SPEED, BUSVOODOO_I2C_SETTING_ADDRESSBITS, BUSVOODOO_I2C_SETTING_PULLUP, BUSVOODOO_I2C_SETTING_DONE }
| mode setup stage

## Functions

static bool | busvoodoo_i2c_setup (char **prefix, const char *line)
| setup I2C mode More...
static void | busvoodoo_i2c_exit (void)
| exit I2C mode
static void | busvoodoo_i2c_read (void)
| read from I2C
static void | busvoodoo_i2c_write (uint8_t data)
| write to I2C More...
static void | busvoodoo_i2c_select (uint16_t slave, bool write)
| select I2C slave More...
static bool | busvoodoo_i2c_action (const char *action, uint32_t repetition, bool perform)
| perform I2C action More...
static void | busvoodoo_i2c_command_reset (void *argument)
| command to reset I2C peripheral More...
static void | busvoodoo_i2c_command_actions (void *argument)
| command to perform actions More...
static void | busvoodoo_i2c_command_scan (void *argument)
| command to scan for slave devices More...

## Variables

static enum busvoodoo_i2c_setting_t | busvoodoo_i2c_setting = BUSVOODOO_I2C_SETTING_NONE
| current mode setup stage
uint16_t | busvoodoo_i2c_speed = 100
| I2C speed (in kHz)
uint8_t | busvoodoo_i2c_addressbits = 7
| I2C address bits (7 or 10)
bool | busvoodoo_i2c_embedded_pullup = true
| if embedded or external pull-up resistors are use
static const struct menu_command_t | busvoodoo_i2c_commands []
| I2C menu commands. More...
const struct busvoodoo_mode_t | busvoodoo_i2c_mode
| I2C mode interface definition. More...

## Detailed Description

BusVoodoo I²C mode (code)

Author
  King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info

Date
  2018

Note
  peripherals used: I2C I2C peripheral to communicate with I2C devices

Definition in file busvoodoo_i2c.c.

## Function Documentation

## busvoodoo_i2c_action()

static bool busvoodoo_i2c_action | ( | const char * | action,
|  | uint32_t | repetition,
|  | bool | perform
| ) |  |

static

perform I2C action

Parameters

  [in] | action | action to perform
  [in] | repetition | how many times to perform the action
  [in] | perform | the action (true) or just check it (false)

Returns
  true if the action has been performed, false if it is malformed

Definition at line 265 of file busvoodoo_i2c.c.

## busvoodoo_i2c_command_actions()

static void busvoodoo_i2c_command_actions | ( | void * | argument | ) |

static

command to perform actions

Parameters

  [in] | argument | actions to perform

Definition at line 419 of file busvoodoo_i2c.c.

## busvoodoo_i2c_command_reset()

static void busvoodoo_i2c_command_reset | ( | void * | argument | ) |

static

command to reset I2C peripheral

Parameters

  [in] | argument | no argument required

Definition at line 407 of file busvoodoo_i2c.c.

## busvoodoo_i2c_command_scan()

static void busvoodoo_i2c_command_scan | ( | void * | argument | ) |

static

command to scan for slave devices

Parameters

  [in] | argument | no argument required

Definition at line 453 of file busvoodoo_i2c.c.

## busvoodoo_i2c_select()

static void busvoodoo_i2c_select | ( | uint16_t | slave,
|  | bool | write
| ) |  |

static

select I2C slave

Parameters

  [in] | slave | slave I2C address
  [in] | write | enter read (false) or write (true) mode

Definition at line 224 of file busvoodoo_i2c.c.

## busvoodoo_i2c_setup()

static bool busvoodoo_i2c_setup | ( | char ** | prefix,
|  | const char * | line
| ) |  |

static

setup I2C mode

Parameters

  [out] | prefix | terminal prompt prefix
  [in] | line | terminal prompt line to configure mode

Returns
  if setup is complete

Definition at line 64 of file busvoodoo_i2c.c.

## busvoodoo_i2c_write()

static void busvoodoo_i2c_write | ( | uint8_t | data | ) |

static

write to I2C

Parameters

  [in] | data | data to write

Definition at line 191 of file busvoodoo_i2c.c.

## Variable Documentation

## busvoodoo_i2c_commands

const struct menu_command_t busvoodoo_i2c_commands[]

static

Initial value:
= {
{
.shortcut = 'r',
.name = "reset_i2c",
.command_description = "reset I2C peripheral",
.argument = MENU_ARGUMENT_NONE,
.argument_description = NULL,
.command_handler = &busvoodoo_i2c_command_reset,
},
{
.shortcut = 'a',
.name = "action",
.command_description = "perform protocol actions",
.argument = MENU_ARGUMENT_STRING,
.argument_description = "[actions]",
.command_handler = &busvoodoo_i2c_command_actions,
},
{
.shortcut = 's',
.name = "scan",
.command_description = "scan for slave devices",
.argument = MENU_ARGUMENT_NONE,
.argument_description = NULL,
.command_handler = &busvoodoo_i2c_command_scan,
},
}
busvoodoo_i2c_command_reset
static void busvoodoo_i2c_command_reset(void *argument)
command to reset I2C peripheral
Definition: busvoodoo_i2c.c:407
busvoodoo_i2c_command_actions
static void busvoodoo_i2c_command_actions(void *argument)
command to perform actions
Definition: busvoodoo_i2c.c:419
busvoodoo_i2c_command_scan
static void busvoodoo_i2c_command_scan(void *argument)
command to scan for slave devices
Definition: busvoodoo_i2c.c:453

I2C menu commands.

Definition at line 523 of file busvoodoo_i2c.c.

## busvoodoo_i2c_mode

const struct busvoodoo_mode_t busvoodoo_i2c_mode

Initial value:
= {
.name = "i2c",
.description = "Inter-Integrated Circuit",
.full_only = false,
.setup = &busvoodoo_i2c_setup,
.commands = busvoodoo_i2c_commands,
.commands_nb = LENGTH(busvoodoo_i2c_commands),
.exit = &busvoodoo_i2c_exit,
}
busvoodoo_i2c_exit
static void busvoodoo_i2c_exit(void)
exit I2C mode
Definition: busvoodoo_i2c.c:154
busvoodoo_i2c_setup
static bool busvoodoo_i2c_setup(char **prefix, const char *line)
setup I2C mode
Definition: busvoodoo_i2c.c:64
busvoodoo_i2c_commands
static const struct menu_command_t busvoodoo_i2c_commands[]
I2C menu commands.
Definition: busvoodoo_i2c.c:523
LENGTH
#define LENGTH(x)
get the length of an array
Definition: global.h:26

I2C mode interface definition.

Definition at line 550 of file busvoodoo_i2c.c.