Skip to content

Commit

Permalink
Merge pull request #713 from jannic/flush_should_check_busy
Browse files Browse the repository at this point in the history
Fix UART transmit_flushed method
  • Loading branch information
jannic authored Nov 5, 2023
2 parents a640cf0 + 34200ed commit fbb7e79
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rp2040-hal/src/uart/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ pub fn set_tx_watermark(rb: &RegisterBlock, watermark: FifoWatermark) {
rb.uartifls.modify(|_r, w| unsafe { w.txiflsel().bits(wm) });
}

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

Expand Down

0 comments on commit fbb7e79

Please sign in to comment.