diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 17e1e45668a..3e34af3bff0 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add Flex / AnyFlex GPIO pin driver (#1659) - Add new `DmaError::UnsupportedMemoryRegion` - used memory regions are checked when preparing a transfer now (#1670) - Add DmaTransactionTxOwned, DmaTransactionRxOwned, DmaTransactionTxRxOwned, functions to do owning transfers added to SPI half-duplex (#1672) +- uart: Implement `embedded_io::ReadReady` for `Uart` and `UartRx` (#1702) ### Fixed diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index cb2b609a482..8fd21dfed81 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -1662,6 +1662,28 @@ where } } +#[cfg(feature = "embedded-io")] +impl embedded_io::ReadReady for Uart<'_, T, M> +where + T: Instance, + M: Mode, +{ + fn read_ready(&mut self) -> Result { + self.rx.read_ready() + } +} + +#[cfg(feature = "embedded-io")] +impl embedded_io::ReadReady for UartRx<'_, T, M> +where + T: Instance, + M: Mode, +{ + fn read_ready(&mut self) -> Result { + Ok(T::get_rx_fifo_count() > 0) + } +} + #[cfg(feature = "embedded-io")] impl embedded_io::Write for Uart<'_, T, M> where