-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Reading from a peripheral, it appears that the I2C driver for MAX32670 causes a double read.
What I Did
Connect an ADXL345 to I2C1 on MAX32670 EVKit. I am running the I2C example, and simply added the below source code before the main test runs...
// FIXME: For testing
uint8_t my_adxl_tx[1] = {0x0}; // ADXL ID Register
uint8_t my_adxl_rx[2] = {0x0};
mxc_i2c_req_t reqMaster = {
.i2c = I2C_MASTER,
.addr = 0x1D, // ADXL345 I2C Addr
.tx_buf = my_adxl_tx,
.rx_buf = my_adxl_rx,
.tx_len = 1,
.rx_len = 1,
.callback = NULL,
};
I2C_FLAG=1;
MXC_I2C_MasterTransaction(&reqMaster);Outcome
The above shows a repeated start and a double read of the register despite only attempting to read once.
I am trying to use MAX32670 with a No-OS Project using ADXL345 that I built. I have actually seen this condition cause infinite loops where the I2C bus sends out clocks forever and waits for data that will not come.
This happens because the i2c_reva.c MasterTransaction function erroneously sets the Restart bit and attempt to read again, when no more data will come back from the peripheral. It looks like an attempt was made to address this in commit #1211 but it may have been put off until further notice.
