Skip to content

Commit

Permalink
implement embedded_io::ReadReady for Uart & UartRx (esp-rs#1702)
Browse files Browse the repository at this point in the history
* implement `embedded_io::ReadReady` for `Uart` & `UartRx`

* update CHANGELOG.md
  • Loading branch information
felixwrt authored Jun 21, 2024
1 parent eee20de commit 9691141
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,28 @@ where
}
}

#[cfg(feature = "embedded-io")]
impl<T, M> embedded_io::ReadReady for Uart<'_, T, M>
where
T: Instance,
M: Mode,
{
fn read_ready(&mut self) -> Result<bool, Self::Error> {
self.rx.read_ready()
}
}

#[cfg(feature = "embedded-io")]
impl<T, M> embedded_io::ReadReady for UartRx<'_, T, M>
where
T: Instance,
M: Mode,
{
fn read_ready(&mut self) -> Result<bool, Self::Error> {
Ok(T::get_rx_fifo_count() > 0)
}
}

#[cfg(feature = "embedded-io")]
impl<T, M> embedded_io::Write for Uart<'_, T, M>
where
Expand Down

0 comments on commit 9691141

Please sign in to comment.