I2c#

group bsp_i2c

Control the I2C peripheral.

Author

Alexandre Abadie alexandre.abadie@inria.fr

Copyright

Inria, 2022

Typedefs

typedef uint8_t i2c_t#

I2C peripheral index.

Functions

void db_i2c_init(i2c_t i2c, const gpio_t *scl, const gpio_t *sda)#

Initialize the I2C peripheral.

Parameters:
  • i2c[in] i2c reference used

  • scl[in] pointer to struct that represents the SCL pin

  • sda[in] pointer to struct that represents the SDA pin

void db_i2c_begin(i2c_t i2c)#

Begin transmission on I2C.

Parameters:
  • i2c[in] i2c reference used

void db_i2c_end(i2c_t i2c)#

End transmission on I2C.

Parameters:
  • i2c[in] i2c reference used

void db_i2c_read_regs(i2c_t i2c, uint8_t addr, uint8_t reg, void *data, size_t len)#

Read bytes from one register.

Parameters:
  • i2c[in] i2c reference used

  • addr[in] Address of the device on the I2C bus

  • reg[in] Address of the register to read

  • data[out] Pointer to the output byte array

  • len[in] Length of the bytes to read

void db_i2c_write_regs(i2c_t i2c, uint8_t addr, uint8_t reg, const void *data, size_t len)#

Write bytes to register.

Parameters:
  • i2c[in] i2c reference used

  • addr[in] Address of the device on the I2C bus

  • reg[in] Address of the register to write

  • data[out] Pointer to the input byte array

  • len[in] Length of the bytes to write