This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I2C: How do I specify a register address to read from when calling nrf_drv_twi_rx()?

I'm using nrf_drv_twi to talk to an accelerometer from an nRF51822 on a custom board. I'm on SDK 10.0.0. I'm following the example from the SDK, peripheral/twi_sensor. And I'm using blocking mode, with no handler.

In the calls to nrf_drv_twi_tx(), I see the example code is using a two element array of uint8_t where the first element is the register address and the second is the value.

register_value_pair[0] = KXTJ2_CTRL_REG1;
register_value_pair[1] = 0b00000000;
err_code = nrf_drv_twi_tx(&m_twi_kionix, KIONIX_SLAVE_ADDRESS, register_value_pair,
		sizeof(register_value_pair), false);
APP_ERROR_CHECK(err_code);

So far so good. But when it comes to the RX, the third param is just data, with no register address. How can the slave device or the driver possibly know which register I'm reading?

Related