I've noticed that when attempting to clear i2c receive interrupts utilising the clear_irq function, that this is essentially a no op.
Clearing the rxie interrupt involves reading data from the rxdr register, and the clear_irq does not do this.
I would suggest having the clear_irq function return a Option, something like this:
/// Clears interrupt flag for `event`
pub fn clear_irq(&mut self, event: Event) -> Option<u8> {
self.i2c.icr.write(|w| {
match event {
Event::Stop => w.stopcf().set_bit(),
Event::Errors => w
.berrcf().set_bit()
.arlocf().set_bit()
.ovrcf().set_bit(),
Event::NotAcknowledge => w.nackcf().set_bit(),
_ => w
}
});
let _ = self.i2c.isr.read();
let _ = self.i2c.isr.read(); // Delay 2 peripheral clocks
if event == Event::Receive {
return Some(self.i2c.rxdr.read().rxdata().bits());
}
None
}
I've noticed that when attempting to clear i2c receive interrupts utilising the
clear_irq
function, that this is essentially a no op. Clearing the rxie interrupt involves reading data from therxdr
register, and theclear_irq
does not do this.I would suggest having the, something like this:
clear_irq
function return a Option