aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorrafael <rafael>2024-07-10 22:54:48 +0200
committerrafael <rafael>2024-07-10 22:54:48 +0200
commit68b3fbe3481cdbc562d0aa3fdb082514517abde8 (patch)
tree780a9e6b97310c4876817005ba3fd228cd5d191a /embassy-rp
parent6636a5835b27f82abea9000c9f3e93b4455b29c8 (diff)
implement read_ready method in BufferedUart
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/src/uart/buffered.rs18
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..36a11279e 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
320impl<'d, T: Instance> BufferedUartTx<'d, T> { 326impl<'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
630impl<'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
636impl<'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
624impl<'d, T: Instance + 'd> embedded_io_async::BufRead for BufferedUart<'d, T> { 642impl<'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