From c955eaae7fccf8fb7121c4553a0270507643a0bc Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 2 May 2020 23:32:01 +0200 Subject: [PATCH] libboard_zynq: flush Uart by waiting for tx idle --- libboard_zynq/src/logger.rs | 2 +- libboard_zynq/src/stdio.rs | 3 ++- libboard_zynq/src/uart/mod.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libboard_zynq/src/logger.rs b/libboard_zynq/src/logger.rs index 0caf014..8d633df 100644 --- a/libboard_zynq/src/logger.rs +++ b/libboard_zynq/src/logger.rs @@ -29,6 +29,6 @@ impl log::Log for Logger { } fn flush(&self) { let uart = stdio::get_uart(); - while !uart.tx_fifo_empty() {} + while !uart.tx_idle() {} } } diff --git a/libboard_zynq/src/stdio.rs b/libboard_zynq/src/stdio.rs index ffe239b..393fe68 100644 --- a/libboard_zynq/src/stdio.rs +++ b/libboard_zynq/src/stdio.rs @@ -63,6 +63,7 @@ macro_rules! println { let mut uart = $crate::stdio::get_uart(); let _ = write!(uart, $($arg)*); let _ = write!(uart, "\n"); - while !uart.tx_fifo_empty() {} + // flush after the newline + while !uart.tx_idle() {} }) } diff --git a/libboard_zynq/src/uart/mod.rs b/libboard_zynq/src/uart/mod.rs index d7e376e..b052119 100644 --- a/libboard_zynq/src/uart/mod.rs +++ b/libboard_zynq/src/uart/mod.rs @@ -221,7 +221,7 @@ impl embedded_hal::serial::Write for Uart { } fn flush(&mut self) -> nb::Result<(), Void> { - if self.tx_fifo_empty() { + if self.tx_idle() { Ok(()) } else { Err(nb::Error::WouldBlock)