Skip to content

Commit 571c3a3

Browse files
committed
clear error flags on start
1 parent 88c5843 commit 571c3a3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/i2c.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ impl<I2C: Instance> I2c<I2C> {
264264
// to start a new transaction.
265265
while self.i2c.cr1().read().stop().bit_is_set() {}
266266

267+
// Clear all pending error bits
268+
self.i2c.sr1().write(|w| unsafe { w.bits(0) });
267269
// Send a START condition
268270
self.i2c.cr1().modify(|_, w| w.start().set_bit());
269271

@@ -325,6 +327,8 @@ impl<I2C: Instance> I2c<I2C> {
325327
// to start a new transaction.
326328
while self.i2c.cr1().read().stop().bit_is_set() {}
327329

330+
// Clear all pending error bits
331+
self.i2c.sr1().write(|w| unsafe { w.bits(0) });
328332
// Send a START condition and set ACK bit
329333
self.i2c
330334
.cr1()

0 commit comments

Comments
 (0)