Skip to content

Commit a181da1

Browse files
authored
Merge pull request #794 from jagenheim/bugfix_i2c_read
I2C read address fix
2 parents 910163d + b5be7ac commit a181da1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/i2c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<I2C: Instance> I2c<I2C> {
344344
Address::Seven(addr) => {
345345
self.i2c
346346
.dr()
347-
.write(|w| unsafe { w.bits((u32::from(addr) << 1) & 1) });
347+
.write(|w| unsafe { w.bits((u32::from(addr) << 1) | 1) });
348348
}
349349
Address::Ten(addr) => {
350350
let [msbs, lsbs] = addr.to_be_bytes();
@@ -357,7 +357,7 @@ impl<I2C: Instance> I2c<I2C> {
357357
self.i2c.cr1().modify(|_, w| w.start().set_bit());
358358
// Wait until START condition was generated
359359
while self.i2c.sr1().read().sb().bit_is_clear() {}
360-
dr.write(|w| unsafe { w.bits(u32::from(msbs & 1)) });
360+
dr.write(|w| unsafe { w.bits(u32::from(msbs | 1)) });
361361
}
362362
}
363363

0 commit comments

Comments
 (0)