Merge pull request #4634 from fwolter/fix-i2c-stop

stm32/i2c: fix failure of subsequent transmissions after NACK
This commit is contained in:
Dario Nieuwenhuis 2025-09-02 19:46:43 +00:00 committed by GitHub
commit 2ef9dfb512
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- fix: Fixed STM32H5 builds requiring time feature
- feat: Derive Clone, Copy for QSPI Config
- fix: stm32/i2c in master mode (blocking): subsequent transmissions failed after a NACK was received
## 0.4.0 - 2025-08-26

View File

@ -454,7 +454,8 @@ impl<'d, M: Mode, IM: MasterMode> I2c<'d, M, IM> {
// (START has been ACKed or last byte when
// through)
if let Err(err) = self.wait_txis(timeout) {
if send_stop {
if send_stop && err != Error::Nack {
// STOP is sent automatically if a NACK was received
self.master_stop();
}
return Err(err);
@ -548,7 +549,9 @@ impl<'d, M: Mode, IM: MasterMode> I2c<'d, M, IM> {
(idx != last_slice_index) || (slice_len > 255),
timeout,
) {
self.master_stop();
if err != Error::Nack {
self.master_stop();
}
return Err(err);
}
}
@ -561,7 +564,9 @@ impl<'d, M: Mode, IM: MasterMode> I2c<'d, M, IM> {
(number != last_chunk_idx) || (idx != last_slice_index),
timeout,
) {
self.master_stop();
if err != Error::Nack {
self.master_stop();
}
return Err(err);
}
}
@ -571,7 +576,9 @@ impl<'d, M: Mode, IM: MasterMode> I2c<'d, M, IM> {
// (START has been ACKed or last byte when
// through)
if let Err(err) = self.wait_txis(timeout) {
self.master_stop();
if err != Error::Nack {
self.master_stop();
}
return Err(err);
}