i2c

group i2c

Driver for the hardware I2C of the board.

Functions

void i2c_init(void)

Configure the hardware I2C instance as well as software-based I2C instance.

bool i2c_write(nrfx_twi_t twi, uint8_t addr, uint8_t *buf, uint8_t sz)

Write a buffer over I2C (hardware-based instance).

Parameters
  • addr – The address at which write the data.

  • buf – The buffer to write.

  • sz – The length of that bufer.

Returns

True if no I2C errors were reported.

bool i2c_write_no_stop(nrfx_twi_t twi, uint8_t addr, uint8_t *buf, uint8_t sz)

Write a buffer over I2C without stop condition.

The I2C transaction will still be ongoing, permitting to more data to be written.

Parameters
  • addr – The address at which write the data.

  • buf – The buffer containing the data to write.

  • sz – The length of that bufer.

Returns

True if no I2C errors were reported.

bool i2c_read(nrfx_twi_t twi, uint8_t addr, uint8_t *readBuffer, uint8_t sz)

Read a buffer from I2C.

Parameters
  • addr – Address of the peripheral.

  • buf – The buffer receiving the data.

  • sz – The length of that bufer.

Returns

True if no I2C errors were reported.

void i2c_scan(nrfx_twi_t twi)

For debugging, scan the twi and expect MBR3@55=0x37 & OV5640@60=0x3C.

Returns

True if all expected addresses were found.

Variables

const nrfx_twi_t i2c0
const nrfx_twi_t i2c1