Skip to content

Commit fbb7e79

Browse files
authored
Merge pull request #713 from jannic/flush_should_check_busy
Fix UART transmit_flushed method
2 parents a640cf0 + 34200ed commit fbb7e79

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

rp2040-hal/src/uart/writer.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ pub fn set_tx_watermark(rb: &RegisterBlock, watermark: FifoWatermark) {
2626
rb.uartifls.modify(|_r, w| unsafe { w.txiflsel().bits(wm) });
2727
}
2828

29-
/// Returns `Err(WouldBlock)` if the UART TX FIFO still has data in it or
30-
/// `Ok(())` if the FIFO is empty.
29+
/// Returns `Err(WouldBlock)` if the UART is still busy transmitting data.
30+
/// It returns Ok(()) when the TX fifo and the transmit shift register are empty
31+
/// and the last stop bit is sent.
3132
pub(crate) fn transmit_flushed(rb: &RegisterBlock) -> nb::Result<(), Infallible> {
32-
if rb.uartfr.read().txfe().bit_is_set() {
33-
Ok(())
34-
} else {
33+
if rb.uartfr.read().busy().bit_is_set() {
3534
Err(WouldBlock)
35+
} else {
36+
Ok(())
3637
}
3738
}
3839

0 commit comments

Comments
 (0)