Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uart_is_busy() method for UART devices #711

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rp2040-hal/src/uart/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ impl<D: UartDevice, P: ValidUartPinout<D>> UartPeripheral<Enabled, D, P> {
super::writer::uart_is_writable(&self.device)
}

/// Is the UART still busy transmitting data?
pub fn uart_is_busy(&self) -> bool {
super::writer::uart_is_busy(&self.device)
}

/// Is there data in the UART RX FIFO ready to be read?
pub fn uart_is_readable(&self) -> bool {
super::reader::is_readable(&self.device)
Expand Down
6 changes: 6 additions & 0 deletions rp2040-hal/src/uart/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ pub(crate) fn uart_is_writable(rb: &RegisterBlock) -> bool {
rb.uartfr.read().txff().bit_is_clear()
}

/// Returns `true` if the UART is busy transmitting data, `false` after all
/// bits (including stop bits) have been transmitted.
pub(crate) fn uart_is_busy(rb: &RegisterBlock) -> bool {
rb.uartfr.read().busy().bit_is_set()
}

/// Writes bytes to the UART.
///
/// This function writes as long as it can. As soon that the FIFO is full,
Expand Down
Loading