diff options
| author | rafael <[email protected]> | 2024-07-14 16:42:54 +0200 |
|---|---|---|
| committer | rafael <[email protected]> | 2024-07-14 16:42:54 +0200 |
| commit | c7f775dc20df2df4ceb3fb75d7228b2e37121e0b (patch) | |
| tree | 3a55516954a8477a38a1aa6e754631622ea9db6c | |
| parent | 08f1454527d832f80f6816f7672d2cb91dd6e848 (diff) | |
stm
| -rw-r--r-- | embassy-stm32/src/usart/buffered.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 33bc009a8..eb639942c 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs | |||
| @@ -436,6 +436,12 @@ impl<'d> BufferedUartRx<'d> { | |||
| 436 | } | 436 | } |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | /// we are ready to read if there is data in the buffer | ||
| 440 | fn read_ready() -> Result<bool, Error> { | ||
| 441 | let state = T::buffered_state(); | ||
| 442 | Ok(!state.rx_buf.is_empty()) | ||
| 443 | } | ||
| 444 | |||
| 439 | /// Reconfigure the driver | 445 | /// Reconfigure the driver |
| 440 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { | 446 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { |
| 441 | reconfigure(self.info, self.kernel_clock, config)?; | 447 | reconfigure(self.info, self.kernel_clock, config)?; |
| @@ -610,6 +616,18 @@ impl<'d> embedded_io_async::Read for BufferedUartRx<'d> { | |||
| 610 | } | 616 | } |
| 611 | } | 617 | } |
| 612 | 618 | ||
| 619 | impl<'d> embedded_io_async::ReadReady for BufferedUart<'d> { | ||
| 620 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | ||
| 621 | BufferedUartRx::<'d>::read_ready() | ||
| 622 | } | ||
| 623 | } | ||
| 624 | |||
| 625 | impl<'d> embedded_io_async::ReadReady for BufferedUartRx<'d> { | ||
| 626 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | ||
| 627 | Self::read_ready() | ||
| 628 | } | ||
| 629 | } | ||
| 630 | |||
| 613 | impl<'d> embedded_io_async::BufRead for BufferedUart<'d> { | 631 | impl<'d> embedded_io_async::BufRead for BufferedUart<'d> { |
| 614 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | 632 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { |
| 615 | self.rx.fill_buf().await | 633 | self.rx.fill_buf().await |
