diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-04-10 14:49:12 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-04-10 14:49:12 +0000 |
| commit | 53c60df9979f32a7bfca3fe5c30b47850ee295df (patch) | |
| tree | f4040d4134f37a4b877dedcf5f5d86834f75a7c9 | |
| parent | df17a88448752ba73b25f0d09667888b863190ca (diff) | |
| parent | 6760258ec39c629b911a417d0a554bc6167c5b5b (diff) | |
Merge #1346
1346: fix I2C controller problems after NACK r=Dirbaio a=Juravenator
While tinkering with I2C on a NUCLEO-H723ZG, I noticed that when trying to communicate with a non-existent device you do receive a proper NACK error, but afterwards any future communications with any device no longer works as expected.
The use case is auto-detection of devices, in this case a series of Adafruit 24LC32 I2C EEPROM boards.
On closer inspection with a logic analyzer, I observed that after the NACK, any data bytes sent out by the board to the devices are just zeros. Even though the embassy code specifies the correct data in `set_txdata` in `write_internal`. Something seems to be going wrong with the controller or buffers on the board itself.
Then I noticed what seems to be a logic error in `flush_txdr`, which is called when issuing a NACK.
After flipping the if statement, I2C communications keep working as expected after issuing a NACK.
Co-authored-by: Glenn Dirkx <[email protected]>
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 28663fb36..7218f7706 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -262,7 +262,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> { | |||
| 262 | if T::regs().isr().read().txis() { | 262 | if T::regs().isr().read().txis() { |
| 263 | T::regs().txdr().write(|w| w.set_txdata(0)); | 263 | T::regs().txdr().write(|w| w.set_txdata(0)); |
| 264 | } | 264 | } |
| 265 | if T::regs().isr().read().txe() { | 265 | if !T::regs().isr().read().txe() { |
| 266 | T::regs().isr().modify(|w| w.set_txe(true)) | 266 | T::regs().isr().modify(|w| w.set_txe(true)) |
| 267 | } | 267 | } |
| 268 | } | 268 | } |
