Closed
Description
I was reading the i2c
code since I want to implement it for another chip. Then I encountered the following loop in the send_byte
function:
// Wait until byte is transferred
loop {
let isr = self.i2c.isr.read();
if isr.berr().bit_is_set() {
self.i2c.icr.write(|w| w.berrcf().set_bit());
return Err(Error::BusError);
} else if isr.arlo().bit_is_set() {
self.i2c.icr.write(|w| w.arlocf().set_bit());
return Err(Error::ArbitrationLost);
} else if isr.nackf().bit_is_set() {
self.i2c.icr.write(|w| w.nackcf().set_bit());
return Err(Error::Nack);
}
return Ok(());
}
Line 188 in f3b3e82
This loop seems wrong as it only ever runs once. Guess it might still work in practice most of the time. I guess the idea was to wait for txe
bit to clear like in two lines above?
Line 183 in f3b3e82
Metadata
Metadata
Assignees
Labels
No labels