stm32/uart impl ReadReady for RingbufferdUart
This commit is contained in:
parent
8803128707
commit
be50b62677
@ -260,6 +260,8 @@ pub enum Error {
|
|||||||
Parity,
|
Parity,
|
||||||
/// Buffer too large for DMA
|
/// Buffer too large for DMA
|
||||||
BufferTooLong,
|
BufferTooLong,
|
||||||
|
// TODO: ask what this is and document it (dvdsk)
|
||||||
|
DmaUnsynced,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ReadCompletionEvent {
|
enum ReadCompletionEvent {
|
||||||
@ -1689,6 +1691,7 @@ impl embedded_hal_nb::serial::Error for Error {
|
|||||||
Self::Overrun => embedded_hal_nb::serial::ErrorKind::Overrun,
|
Self::Overrun => embedded_hal_nb::serial::ErrorKind::Overrun,
|
||||||
Self::Parity => embedded_hal_nb::serial::ErrorKind::Parity,
|
Self::Parity => embedded_hal_nb::serial::ErrorKind::Parity,
|
||||||
Self::BufferTooLong => embedded_hal_nb::serial::ErrorKind::Other,
|
Self::BufferTooLong => embedded_hal_nb::serial::ErrorKind::Other,
|
||||||
|
Self::DmaUnsynced => embedded_hal_nb::serial::ErrorKind::Other,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ use core::task::Poll;
|
|||||||
|
|
||||||
use embassy_embedded_hal::SetConfig;
|
use embassy_embedded_hal::SetConfig;
|
||||||
use embassy_hal_internal::PeripheralRef;
|
use embassy_hal_internal::PeripheralRef;
|
||||||
|
use embedded_io_async::ReadReady;
|
||||||
use futures_util::future::{select, Either};
|
use futures_util::future::{select, Either};
|
||||||
|
|
||||||
use super::{clear_interrupt_flags, rdr, reconfigure, sr, Config, ConfigError, Error, Info, State, UartRx};
|
use super::{clear_interrupt_flags, rdr, reconfigure, sr, Config, ConfigError, Error, Info, State, UartRx};
|
||||||
@ -262,3 +263,13 @@ impl embedded_io_async::Read for RingBufferedUartRx<'_> {
|
|||||||
self.read(buf).await
|
self.read(buf).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ReadReady for RingBufferedUartRx<'_> {
|
||||||
|
fn read_ready(&mut self) -> Result<bool, Self::Error> {
|
||||||
|
let len = self.ring_buf.len().map_err(|e| match e {
|
||||||
|
crate::dma::ringbuffer::Error::Overrun => Self::Error::Overrun,
|
||||||
|
crate::dma::ringbuffer::Error::DmaUnsynced => Self::Error::DmaUnsynced,
|
||||||
|
})?;
|
||||||
|
Ok(len > 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user