diff --git a/rp2040-hal/src/uart/peripheral.rs b/rp2040-hal/src/uart/peripheral.rs index 20b5f555a..0ef341f1a 100644 --- a/rp2040-hal/src/uart/peripheral.rs +++ b/rp2040-hal/src/uart/peripheral.rs @@ -490,6 +490,15 @@ impl> embedded_io::Read for UartPeripheral< } } } + +impl> embedded_io::ReadReady + for UartPeripheral +{ + fn read_ready(&mut self) -> Result { + Ok(self.uart_is_readable()) + } +} + impl> embedded_io::Write for UartPeripheral { fn write(&mut self, buf: &[u8]) -> Result { self.write_full_blocking(buf); @@ -500,3 +509,11 @@ impl> embedded_io::Write for UartPeripheral Ok(()) } } + +impl> embedded_io::WriteReady + for UartPeripheral +{ + fn write_ready(&mut self) -> Result { + Ok(self.uart_is_writable()) + } +} diff --git a/rp2040-hal/src/uart/reader.rs b/rp2040-hal/src/uart/reader.rs index 11829f90d..6be1e2fac 100644 --- a/rp2040-hal/src/uart/reader.rs +++ b/rp2040-hal/src/uart/reader.rs @@ -244,6 +244,12 @@ impl> embedded_io::Read for Reader { } } +impl> embedded_io::ReadReady for Reader { + fn read_ready(&mut self) -> Result { + Ok(is_readable(&self.device)) + } +} + impl> Read02 for Reader { type Error = ReadErrorType; diff --git a/rp2040-hal/src/uart/writer.rs b/rp2040-hal/src/uart/writer.rs index 747e1d620..5be6dd89b 100644 --- a/rp2040-hal/src/uart/writer.rs +++ b/rp2040-hal/src/uart/writer.rs @@ -223,6 +223,12 @@ impl> embedded_io::Write for Writer { } } +impl> embedded_io::WriteReady for Writer { + fn write_ready(&mut self) -> Result { + Ok(uart_is_writable(&self.device)) + } +} + impl> Write02 for Writer { type Error = Infallible;