Kubos Linux I2C API

int hal_i2c_bus[K_NUM_I2CS]

Static array of I2C bus file descriptors.

KI2CStatus kprv_i2c_dev_init(KI2CNum i2c)

Low level hal device initialization.

Return
KI2CStatus I2C_OK on success, I2C_ERROR_* on error
Parameters
  • i2c: I2C bus to initialize

KI2CStatus kprv_i2c_dev_terminate(KI2CNum i2c)

Low level HAL I2C termination.

Return
KI2CStatus I2C_OK on success, I2C_ERROR on error
Parameters
  • i2c: I2C bus to terminate

KI2CStatus kprv_i2c_master_write(KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len)

Low level HAL I2C write (as master)

Return
KI2CStatus I2C_OK on success, I2C_ERROR on error
Parameters
  • i2c: I2C bus to write from
  • addr: I2C addr to write to
  • ptr: data buffer
  • len: length of data in buffer

KI2CStatus kprv_i2c_master_read(KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len)

Low level HAL I2C read (as master) This is implemented by the device specific hal.

Return
KI2CStatus I2C_OK on success, I2C_ERROR on error
Parameters
  • i2c: I2C bus to read from
  • addr: I2C addr to read from
  • ptr: data buffer
  • len: length of data expected to read

KI2CStatus kprv_i2c_slave_write(KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len)

Low level HAL I2C write (as slave)

Warning
Not currently implemented
Return
KI2CStatus I2C_OK on success, I2C_ERROR on error
Parameters
  • i2c: I2C bus to write from
  • addr: I2C addr to write to
  • ptr: data buffer
  • len: length of data in buffer

KI2CStatus kprv_i2c_slave_read(KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len)

Low level HAL I2C read (as slave)

Warning
Not currently implemented
Return
KI2CStatus I2C_OK on success, I2C_ERROR on error
Parameters
  • i2c: I2C bus to read from
  • addr: I2C addr to read from
  • ptr: data buffer
  • len: length of data expected to read

STRINGIFY(s)
TOSTRING(s)