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>

source

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>

source

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.

source

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

source

pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError>

Reconfigure the driver

source

pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error>
where RxDma: RxDma<T>,

Initiate an asynchronous UART read

source

pub fn nb_read(&mut self) -> Result<u8, Error<Error>>

Read a single u8 if there is one available, otherwise return WouldBlock

source

pub fn blocking_read(&mut self, buffer: &mut [u8]) -> Result<(), Error>

Perform a blocking read into buffer

source

pub async fn read_until_idle( &mut self, buffer: &mut [u8] ) -> Result<usize, Error>
where RxDma: RxDma<T>,

Initiate an asynchronous read with idle line detection enabled

Trait Implementations§

source§

impl<'d, T: BasicInstance, TxDma> Drop for UartRx<'d, T, TxDma>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'d, T: BasicInstance, RxDma> ErrorType for UartRx<'d, T, RxDma>

§

type Error = Error

Error type
source§

impl<'d, T: BasicInstance, RxDma> Read for UartRx<'d, T, RxDma>

source§

fn read(&mut self) -> Result<u8, Self::Error>

Reads a single word from the serial interface
source§

impl<'d, T: BasicInstance, RxDma> SetConfig for UartRx<'d, T, RxDma>

§

type Config = Config

The configuration type used by this driver.
§

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>

Set the configuration of the driver.
source§

impl<'d, T: BasicInstance, RxDma> Read<u8> for UartRx<'d, T, RxDma>

§

type Error = Error

Read error
source§

fn read(&mut self) -> Result<u8, Error<Self::Error>>

Reads a single word from the serial interface

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>
where RxDma: Sync, T: Sync,

§

impl<'d, T, RxDma> Unpin for UartRx<'d, T, RxDma>
where RxDma: Unpin, T: Unpin,

§

impl<'d, T, RxDma = NoDma> !UnwindSafe for UartRx<'d, T, RxDma>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.