Hi! I use ICM-20602 motion sensor that is similar to MPU6050. Its communication type is also I2C.
I made I2C wrapping module for ICM-20602. In the module, I added i2c_write_byte
and i2c_write_bytes
functions like following code.
ret_code_t i2c_write_byte(uint8_t dev_addr, uint8_t reg_addr, uint8_t data)
{
ret_code_t err_code;
uint8_t tx_data[2] = { reg_addr, data };
return nrf_drv_twi_tx(&m_twi_master, dev_addr, tx_data, 2, false);
}
But i2c_write_byte
was not like this code. i2c_write_byte
was like following code.
ret_code_t i2c_write_byte(uint8_t dev_addr, uint8_t reg_addr, uint8_t data)
{
ret_code_t err_code;
err_code = nrf_drv_twi_tx(&m_twi_master, dev_addr, ®_addr, 1, true);
if (err_code != NRF_SUCCESS) return err_code;
err_code = nrf_drv_twi_tx(&m_twi_master, dev_addr, &data, 1, false);
return err_code;
}
But this old i2c_write_byte
function did not work well. I think that operations of these i2c_write_byte
functions must be an exact match. I read and read again API documents. But results of these i2c_write_byte
functions are different.
I don't know why.
Please explain why results of these i2c_write_byte
functions are different.