daniel-thompson / i2c-star

A clone of the i2c-tiny-usb based upon STM32 and libopencm3
GNU General Public License v3.0
125 stars 31 forks source link

librfm3: i2c_ctx: Fixed I2C read for reads > 1 byte #3

Closed cyrozap closed 7 years ago

cyrozap commented 7 years ago

I was having trouble using this code with a TI TMP102 temperature sensor, where it would stop reading after sending the address + read. After looking at the signals with a logic analyzer, it appeared that the STM32 wasn't transmitting the clock at all, which explained why the reads were failing. After some more investigation, I traced the issue back to this single flag inversion. Since temperature reads from the TMP102 are two bytes wide, the code would branch to what should have been an ACK-enable, but the inverted flag would enable every other flag instead. Getting rid of that one tilde fixed the whole issue, and now it works perfectly.