Compare commits

..

No commits in common. "c955eaae7fccf8fb7121c4553a0270507643a0bc" and "e047c2900b0da0244aa05c22afd410106ef5636f" have entirely different histories.

3 changed files with 7 additions and 7 deletions

View File

@ -29,6 +29,6 @@ impl log::Log for Logger {
} }
fn flush(&self) { fn flush(&self) {
let uart = stdio::get_uart(); let uart = stdio::get_uart();
while !uart.tx_idle() {} while !uart.tx_fifo_empty() {}
} }
} }

View File

@ -63,7 +63,6 @@ macro_rules! println {
let mut uart = $crate::stdio::get_uart(); let mut uart = $crate::stdio::get_uart();
let _ = write!(uart, $($arg)*); let _ = write!(uart, $($arg)*);
let _ = write!(uart, "\n"); let _ = write!(uart, "\n");
// flush after the newline while !uart.tx_fifo_empty() {}
while !uart.tx_idle() {}
}) })
} }

View File

@ -192,14 +192,15 @@ impl Uart {
self.regs.channel_sts.read().txfull() self.regs.channel_sts.read().txfull()
} }
pub fn tx_idle(&self) -> bool { pub fn tx_fifo_empty(&self) -> bool {
let status = self.regs.channel_sts.read(); self.regs.channel_sts.read().txempty()
status.txempty() && !status.tactive()
} }
} }
impl fmt::Write for Uart { impl fmt::Write for Uart {
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
while !self.tx_fifo_empty() {}
for b in s.bytes() { for b in s.bytes() {
self.write_byte(b); self.write_byte(b);
} }
@ -221,7 +222,7 @@ impl embedded_hal::serial::Write<u8> for Uart {
} }
fn flush(&mut self) -> nb::Result<(), Void> { fn flush(&mut self) -> nb::Result<(), Void> {
if self.tx_idle() { if self.tx_fifo_empty() {
Ok(()) Ok(())
} else { } else {
Err(nb::Error::WouldBlock) Err(nb::Error::WouldBlock)