Skip to content

Commit

Permalink
A better fix and Change log update.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyma98 committed Jul 2, 2023
1 parent 2b27903 commit 7cd25a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- move gpio, dma impls, adc pins in subdir, remove unused `From` impls [#658] [#664]
- Bump `embedded-hal` to `1.0.0-alpha.10`. See [their changelog][embedded-hal-1.0.0-alpha.10] for further details. Note that this included breaking changes to the previous alpha APIs. [#663]
- Fix race condition in sending start condition in I2C. [#662]

[#658]: https://github.com/stm32-rs/stm32f4xx-hal/pull/658
[#662]: https://github.com/stm32-rs/stm32f4xx-hal/pull/662
[#663]: https://github.com/stm32-rs/stm32f4xx-hal/pull/663
[#664]: https://github.com/stm32-rs/stm32f4xx-hal/pull/664
[embedded-hal-1.0.0-alpha.10]: https://github.com/rust-embedded/embedded-hal/blob/v1.0.0-alpha.10/embedded-hal/CHANGELOG.md
Expand Down
9 changes: 7 additions & 2 deletions src/i2c/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,15 @@ where

fn send_start(&mut self, read: bool) -> Result<(), super::Error> {
let i2c = &self.hal_i2c.i2c;

// Make sure the ack and start bit is set together in a single
// read-modify-write operation to avoid race condition.
// See PR: https://github.com/stm32-rs/stm32f4xx-hal/pull/662
if read {
i2c.cr1.modify(|_, w| w.ack().set_bit());
i2c.cr1.modify(|_, w| w.ack().set_bit().start().set_bit());
} else {
i2c.cr1.modify(|_, w| w.start().set_bit());
}
i2c.cr1.modify(|_, w| w.start().set_bit());

// Wait until START condition was generated
while self
Expand Down

0 comments on commit 7cd25a5

Please sign in to comment.