pub struct UartRx<'d, M, T = AnyUart> { /* private fields */ }Expand description
UART (Receive)
Implementations§
Source§impl<'d, M, T> UartRx<'d, M, T>
impl<'d, M, T> UartRx<'d, M, T>
Sourcepub fn with_cts(
self,
cts: impl Peripheral<P = impl PeripheralInput> + 'd,
) -> Self
pub fn with_cts( self, cts: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Self
Configure CTS pin
Sourcepub fn apply_config(&mut self, config: &Config) -> Result<(), Error>
pub fn apply_config(&mut self, config: &Config) -> Result<(), Error>
Change the configuration.
Note that this also changes the configuration of the TX half.
Sourcepub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Error>
pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Error>
Fill a buffer with received bytes
Sourcepub fn drain_fifo(&mut self, buf: &mut [u8]) -> usize
pub fn drain_fifo(&mut self, buf: &mut [u8]) -> usize
Read all available bytes from the RX FIFO into the provided buffer and returns the number of read bytes. Never blocks
Source§impl<'d> UartRx<'d, Blocking>
impl<'d> UartRx<'d, Blocking>
Sourcepub fn new(
uart: impl Peripheral<P = impl Instance> + 'd,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
) -> Result<Self, Error>
pub fn new( uart: impl Peripheral<P = impl Instance> + 'd, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>
Create a new UART RX instance in Blocking mode.
Sourcepub fn new_with_config(
uart: impl Peripheral<P = impl Instance> + 'd,
config: Config,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
) -> Result<Self, Error>
pub fn new_with_config( uart: impl Peripheral<P = impl Instance> + 'd, config: Config, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>
Create a new UART RX instance with configuration options in
Blocking mode.
Source§impl<'d, T> UartRx<'d, Blocking, T>where
T: Instance,
impl<'d, T> UartRx<'d, Blocking, T>where
T: Instance,
Sourcepub fn new_typed(
uart: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
) -> Result<Self, Error>
pub fn new_typed( uart: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>
Create a new UART RX instance in Blocking mode.
Sourcepub fn new_with_config_typed(
uart: impl Peripheral<P = T> + 'd,
config: Config,
rx: impl Peripheral<P = impl PeripheralInput> + 'd,
) -> Result<Self, Error>
pub fn new_with_config_typed( uart: impl Peripheral<P = T> + 'd, config: Config, rx: impl Peripheral<P = impl PeripheralInput> + 'd, ) -> Result<Self, Error>
Create a new UART RX instance with configuration options in
Blocking mode.
Sourcepub fn into_async(self) -> UartRx<'d, Async, T>
pub fn into_async(self) -> UartRx<'d, Async, T>
Reconfigures the driver to operate in Async mode.
Source§impl<'d, T> UartRx<'d, Async, T>where
T: Instance,
impl<'d, T> UartRx<'d, Async, T>where
T: Instance,
Sourcepub fn into_blocking(self) -> UartRx<'d, Blocking, T>
pub fn into_blocking(self) -> UartRx<'d, Blocking, T>
Reconfigures the driver to operate in Blocking mode.
Source§impl<T> UartRx<'_, Async, T>where
T: Instance,
impl<T> UartRx<'_, Async, T>where
T: Instance,
Sourcepub async fn read_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn read_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Read async to buffer slice buf.
Waits until at least one byte is in the Rx FiFo
and one of the following interrupts occurs:
RXFIFO_FULLRXFIFO_OVFAT_CMD_CHAR_DET(only ifset_at_cmdwas called)RXFIFO_TOUT(only if `set_rx_timeout was called)
The interrupts in question are enabled during the body of this function. The method immediately returns when the interrupt has already occurred before calling this method (e.g. status bit set, but interrupt not enabled)
§Params
bufbuffer slice to write the bytes into
§Ok
When successful, returns the number of bytes written to buf. This method will never return Ok(0)
Trait Implementations§
Source§impl<T> Read for UartRx<'_, Async, T>where
T: Instance,
impl<T> Read for UartRx<'_, Async, T>where
T: Instance,
Source§async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
In contrast to the documentation of embedded_io_async::Read, this method blocks until an uart interrupt occurs. See UartRx::read_async for more details.
Source§async fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read moreSource§impl<T, M> Read for UartRx<'_, M, T>
impl<T, M> Read for UartRx<'_, M, T>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Source§fn read_exact(
&mut self,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
buf. Read moreSource§impl<M, T> SetConfig for UartRx<'_, M, T>
impl<M, T> SetConfig for UartRx<'_, M, T>
Source§type ConfigError = Error
type ConfigError = Error
set_config fails.