Struct embassy_stm32::usart::UartRx
source · pub struct UartRx<'d, T: BasicInstance, RxDma = NoDma> { /* private fields */ }
Expand description
Rx-only UART Driver
Implementations§
source§impl<'d, T: BasicInstance, RxDma: RxDma<T>> UartRx<'d, T, RxDma>
impl<'d, T: BasicInstance, RxDma: RxDma<T>> UartRx<'d, T, RxDma>
sourcepub fn into_ring_buffered(
self,
dma_buf: &'d mut [u8]
) -> RingBufferedUartRx<'d, T, RxDma>
pub fn into_ring_buffered( self, dma_buf: &'d mut [u8] ) -> RingBufferedUartRx<'d, T, RxDma>
Turn the UartRx
into a buffered uart which can continously receive in the background
without the possibility of losing bytes. The dma_buf
is a buffer registered to the
DMA controller, and must be large enough to prevent overflows.
source§impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma>
impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma>
sourcepub fn new(
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 = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new( 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 = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power.
sourcepub fn new_with_rts(
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 = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_with_rts( 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 = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new rx-only UART with a request-to-send pin
sourcepub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>
Reconfigure the driver
sourcepub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>where
RxDma: RxDma<T>,
pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>where
RxDma: RxDma<T>,
Initiate an asynchronous UART read
sourcepub fn nb_read(&mut self) -> Result<u8, Error<Error>>
pub fn nb_read(&mut self) -> Result<u8, Error<Error>>
Read a single u8 if there is one available, otherwise return WouldBlock
Trait Implementations§
source§impl<'d, T: BasicInstance, TxDma> Drop for UartRx<'d, T, TxDma>
impl<'d, T: BasicInstance, TxDma> Drop for UartRx<'d, T, TxDma>
source§impl<'d, T: BasicInstance, RxDma> ErrorType for UartRx<'d, T, RxDma>
impl<'d, T: BasicInstance, RxDma> ErrorType for UartRx<'d, T, RxDma>
source§impl<'d, T: BasicInstance, RxDma> Read for UartRx<'d, T, RxDma>
impl<'d, T: BasicInstance, RxDma> Read for UartRx<'d, T, RxDma>
source§impl<'d, T: BasicInstance, RxDma> SetConfig for UartRx<'d, T, RxDma>
impl<'d, T: BasicInstance, RxDma> SetConfig for UartRx<'d, T, RxDma>
§type ConfigError = ConfigError
type ConfigError = ConfigError
The error type that can occur if
set_config
fails.source§fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
Set the configuration of the driver.
Auto Trait Implementations§
impl<'d, T, RxDma> RefUnwindSafe for UartRx<'d, T, RxDma>where
RxDma: RefUnwindSafe,
T: RefUnwindSafe,
impl<'d, T, RxDma> Send for UartRx<'d, T, RxDma>where
RxDma: Send,
impl<'d, T, RxDma> Sync for UartRx<'d, T, RxDma>
impl<'d, T, RxDma> Unpin for UartRx<'d, T, RxDma>
impl<'d, T, RxDma = NoDma> !UnwindSafe for UartRx<'d, T, RxDma>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more