pub struct UartRx<'d, M: Mode> { /* private fields */ }
Expand description
Rx-only UART Driver.
Can be obtained from Uart::split
, or can be constructed independently,
if you do not need the transmitting half of the driver.
§Notes on embedded_io::Read
embedded_io::Read
requires guarantees that this struct cannot provide:
- Any data received between calls to
UartRx::read
orUartRx::blocking_read
will be thrown away, asUartRx
is unbuffered. Users ofembedded_io::Read
are likely to not expect this behavior (for instance if they read multiple small chunks in a row). UartRx::read
andUartRx::blocking_read
only return once the entire buffer has been filled, whereasembedded_io::Read
requires us to fill the buffer with what we already received, and only block/wait until the first byte arrived.
WhileUartRx::read_until_idle
does return early, it will still eagerly wait for data until the buffer is full or no data has been transmitted in a while, which may not be what users ofembedded_io::Read
expect.
[UartRx::into_ring_buffered
] can be called to equip UartRx
with a buffer,
that it can then use to store data received between calls to read
,
provided you are using DMA already.
Alternatively, you can use BufferedUartRx
, which is interrupt-based and which can also
store data received between calls.
Also see this github comment.
Implementations§
Source§impl<'d> UartRx<'d, Async>
impl<'d> UartRx<'d, Async>
Sourcepub fn new<T: Instance>(
peri: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new<T: Instance>( peri: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create a new rx-only UART with no hardware flow control.
Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power.
Sourcepub fn new_with_rts<T: Instance>(
peri: impl Peripheral<P = T> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_with_rts<T: Instance>( peri: impl Peripheral<P = T> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, rts: impl Peripheral<P = impl RtsPin<T>> + 'd, rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create a new rx-only UART with a request-to-send pin
Source§impl<'d> UartRx<'d, Blocking>
impl<'d> UartRx<'d, Blocking>
Sourcepub fn new_blocking<T: Instance>(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_blocking<T: Instance>( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create a new rx-only UART with no hardware flow control.
Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power.
Sourcepub fn new_blocking_with_rts<T: Instance>(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
config: Config,
) -> Result<Self, ConfigError>
pub fn new_blocking_with_rts<T: Instance>( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, rts: impl Peripheral<P = impl RtsPin<T>> + 'd, config: Config, ) -> Result<Self, ConfigError>
Create a new rx-only UART with a request-to-send pin
Source§impl<'d, M: Mode> UartRx<'d, M>
impl<'d, M: Mode> UartRx<'d, M>
Sourcepub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
Reconfigure the driver
Sourcepub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
Perform a blocking read into buffer
Sourcepub fn set_baudrate(&self, baudrate: u32) -> Result<(), ConfigError>
pub fn set_baudrate(&self, baudrate: u32) -> Result<(), ConfigError>
Set baudrate
Trait Implementations§
Source§impl<'d, M: Mode> SetConfig for UartRx<'d, M>
impl<'d, M: Mode> SetConfig for UartRx<'d, M>
Source§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config
fails.