diff options
| author | James Munns <[email protected]> | 2024-07-10 21:40:36 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-10 21:40:36 +0000 |
| commit | ed3da1721a4f704d3f2a8a1cf84d9fc051c71945 (patch) | |
| tree | 847df0a6225e15fad0397615cd49abf21d62463c | |
| parent | 6636a5835b27f82abea9000c9f3e93b4455b29c8 (diff) | |
| parent | d8821dd7d78223552af38781054b8d9c6a9a25bb (diff) | |
Merge pull request #3165 from 1-rafael-1/impl-ReadReady-for-BufferedUart-in-embassy-rp
Impl read ready for buffered uart in embassy rp
| -rw-r--r-- | embassy-rp/src/uart/buffered.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index c94164040..cfbd82ccf 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs | |||
| @@ -315,6 +315,12 @@ impl<'d, T: Instance> BufferedUartRx<'d, T> { | |||
| 315 | w.set_rtim(true); | 315 | w.set_rtim(true); |
| 316 | }); | 316 | }); |
| 317 | } | 317 | } |
| 318 | |||
| 319 | /// we are ready to read if there is data in the buffer | ||
| 320 | fn read_ready() -> Result<bool, Error> { | ||
| 321 | let state = T::buffered_state(); | ||
| 322 | Ok(!state.rx_buf.is_empty()) | ||
| 323 | } | ||
| 318 | } | 324 | } |
| 319 | 325 | ||
| 320 | impl<'d, T: Instance> BufferedUartTx<'d, T> { | 326 | impl<'d, T: Instance> BufferedUartTx<'d, T> { |
| @@ -621,6 +627,18 @@ impl<'d, T: Instance + 'd> embedded_io_async::Read for BufferedUartRx<'d, T> { | |||
| 621 | } | 627 | } |
| 622 | } | 628 | } |
| 623 | 629 | ||
| 630 | impl<'d, T: Instance + 'd> embedded_io_async::ReadReady for BufferedUart<'d, T> { | ||
| 631 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | ||
| 632 | BufferedUartRx::<'d, T>::read_ready() | ||
| 633 | } | ||
| 634 | } | ||
| 635 | |||
| 636 | impl<'d, T: Instance + 'd> embedded_io_async::ReadReady for BufferedUartRx<'d, T> { | ||
| 637 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | ||
| 638 | Self::read_ready() | ||
| 639 | } | ||
| 640 | } | ||
| 641 | |||
| 624 | impl<'d, T: Instance + 'd> embedded_io_async::BufRead for BufferedUart<'d, T> { | 642 | impl<'d, T: Instance + 'd> embedded_io_async::BufRead for BufferedUart<'d, T> { |
| 625 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | 643 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { |
| 626 | BufferedUartRx::<'d, T>::fill_buf().await | 644 | BufferedUartRx::<'d, T>::fill_buf().await |
