Skip to content

Commit 70449c5

Browse files
author
Jonathan Pallant (42 Technology)
committed
Clear the other errors too.
1 parent cc8ebb2 commit 70449c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/serial.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,19 @@ macro_rules! hal {
320320
let isr = unsafe { (*$USARTX::ptr()).isr.read() };
321321

322322
Err(if isr.pe().bit_is_set() {
323+
// Clear the bit by writing 1 to the clear register
324+
unsafe { (*$USARTX::ptr()).icr.write(|w| { w.pecf().set_bit() }) };
323325
nb::Error::Other(Error::Parity)
324326
} else if isr.fe().bit_is_set() {
327+
// Clear the bit by writing 1 to the clear register
328+
unsafe { (*$USARTX::ptr()).icr.write(|w| { w.fecf().set_bit() }) };
325329
nb::Error::Other(Error::Framing)
326330
} else if isr.nf().bit_is_set() {
331+
// Clear the bit by writing 1 to the clear register
332+
unsafe { (*$USARTX::ptr()).icr.write(|w| { w.ncf().set_bit() }) };
327333
nb::Error::Other(Error::Noise)
328334
} else if isr.ore().bit_is_set() {
329-
// Clear the bit
335+
// Clear the bit by writing 1 to the clear register
330336
unsafe { (*$USARTX::ptr()).icr.write(|w| { w.orecf().set_bit() }) };
331337
nb::Error::Other(Error::Overrun)
332338
} else if isr.rxne().bit_is_set() {

0 commit comments

Comments
 (0)