From e129a97d48a00d7923886ab3faa82357b2369f13 Mon Sep 17 00:00:00 2001 From: Mathias Date: Tue, 27 Sep 2022 07:45:10 +0200 Subject: Fix bufferedUart read and write tests --- embassy-rp/src/uart/buffered.rs | 88 +++++++++++++++++++---------------------- embassy-rp/src/uart/mod.rs | 7 +++- 2 files changed, 46 insertions(+), 49 deletions(-) (limited to 'embassy-rp') diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index 81ac61ee..87e16f0e 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs @@ -228,39 +228,39 @@ where fn on_interrupt(&mut self) { let r = T::regs(); unsafe { - let ris = r.uartmis().read(); + let ris = r.uartris().read(); // Clear interrupt flags r.uarticr().modify(|w| { w.set_rxic(true); w.set_rtic(true); }); - if ris.rxmis() { - if ris.pemis() { - warn!("Parity error"); - r.uarticr().modify(|w| { - w.set_peic(true); - }); - } - if ris.femis() { - warn!("Framing error"); - r.uarticr().modify(|w| { - w.set_feic(true); - }); - } - if ris.bemis() { - warn!("Break error"); - r.uarticr().modify(|w| { - w.set_beic(true); - }); - } - if ris.oemis() { - warn!("Overrun error"); - r.uarticr().modify(|w| { - w.set_oeic(true); - }); - } + if ris.peris() { + warn!("Parity error"); + r.uarticr().modify(|w| { + w.set_peic(true); + }); + } + if ris.feris() { + warn!("Framing error"); + r.uarticr().modify(|w| { + w.set_feic(true); + }); + } + if ris.beris() { + warn!("Break error"); + r.uarticr().modify(|w| { + w.set_beic(true); + }); + } + if ris.oeris() { + warn!("Overrun error"); + r.uarticr().modify(|w| { + w.set_oeic(true); + }); + } + if !r.uartfr().read().rxfe() { let buf = self.buf.push_buf(); if !buf.is_empty() { buf[0] = r.uartdr().read().data(); @@ -274,7 +274,7 @@ where } } - if ris.rtmis() { + if ris.rtris() { self.waker.wake(); }; } @@ -318,27 +318,19 @@ where fn on_interrupt(&mut self) { let r = T::regs(); unsafe { - let ris = r.uartris().read(); - // Clear interrupt flags - r.uarticr().write(|w| { - w.set_rtic(true); - }); - - if ris.txris() { - let buf = self.buf.pop_buf(); - if !buf.is_empty() { - r.uartimsc().modify(|w| { - w.set_txim(true); - }); - r.uartdr().write(|w| w.set_data(buf[0].into())); - self.buf.pop(1); - self.waker.wake(); - } else { - // Disable interrupt until we have something to transmit again - r.uartimsc().modify(|w| { - w.set_txim(false); - }); - } + let buf = self.buf.pop_buf(); + if !buf.is_empty() { + r.uartimsc().modify(|w| { + w.set_txim(true); + }); + r.uartdr().write(|w| w.set_data(buf[0].into())); + self.buf.pop(1); + self.waker.wake(); + } else { + // Disable interrupt until we have something to transmit again + r.uartimsc().modify(|w| { + w.set_txim(false); + }); } } } diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index 76ecdf7a..d9285ee5 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs @@ -343,7 +343,12 @@ impl<'d, T: Instance, M: Mode> Uart<'d, T, M> { w.set_stp2(config.stop_bits == StopBits::STOP2); w.set_pen(pen); w.set_eps(eps); - w.set_fen(false); + w.set_fen(true); + }); + + r.uartifls().write(|w| { + w.set_rxiflsel(0b000); + w.set_txiflsel(0b000); }); r.uartcr().write(|w| { -- cgit v1.2.3