Skip to main content

Uart

Struct Uart 

Source
pub struct Uart<'d, T: Instance, M: Mode> { /* private fields */ }
Expand description

Bidirectional UART Driver, which acts as a combination of UartTx and UartRx.

§Notes on [embedded_io::Read]

embedded_io::Read requires guarantees that the base UartRx cannot provide.

See UartRx for more details, and see [BufferedUart] and RingBufferedUartRx as alternatives that do provide the necessary guarantees for embedded_io::Read.

Implementations§

Source§

impl<'d, T: Instance, M: Mode> Uart<'d, T, M>

Source

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

Source

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

Perform a blocking write

Source

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

Block until transmission complete

Source

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

Perform a blocking read into buffer

Source

pub fn split(self) -> (UartTx<'d, T, M>, UartRx<'d, T, M>)

Split the Uart into a transmitter and receiver, which is particularly useful when having two tasks correlating to transmitting and receiving.

Source§

impl<'d, T: Instance> Uart<'d, T, Async>

Source

pub fn new<const REMAP: u8>( peri: Peri<'d, T>, rx: Peri<'d, impl RxPin<T, REMAP>>, tx: Peri<'d, impl TxPin<T, REMAP>>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, tx_dma: Peri<'d, impl TxDma<T>>, rx_dma: Peri<'d, impl RxDma<T>>, config: Config, ) -> Result<Self, ConfigError>

Create a new bidirectional UARTUart

Source

pub fn new_with_rtscts<const REMAP: u8>( peri: Peri<'d, T>, rx: Peri<'d, impl RxPin<T, REMAP>>, tx: Peri<'d, impl TxPin<T, REMAP>>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, rts: Peri<'d, impl RtsPin<T, REMAP>>, cts: Peri<'d, impl CtsPin<T, REMAP>>, tx_dma: Peri<'d, impl TxDma<T>>, rx_dma: Peri<'d, impl RxDma<T>>, config: Config, ) -> Result<Self, ConfigError>

Create a new bidirectional UART with request-to-send and clear-to-send pins

Source

pub fn new_half_duplex<const REMAP: u8>( _peri: Peri<'d, T>, tx: Peri<'d, impl TxPin<T, REMAP>>, tx_dma: Peri<'d, impl TxDma<T>>, rx_dma: Peri<'d, impl RxDma<T>>, config: Config, ) -> Result<Self, ConfigError>

Half-duplex

Note: Half duplex requires TX pin to have a pull-up resistor

Source§

impl<'d, T: Instance> Uart<'d, T, Blocking>

Source

pub fn new_blocking<const REMAP: u8>( peri: Peri<'d, T>, rx: Peri<'d, impl RxPin<T, REMAP>>, tx: Peri<'d, impl TxPin<T, REMAP>>, config: Config, ) -> Result<Self, ConfigError>

Create a new blocking bidirectional UART.

Source

pub fn new_blocking_with_rtscts<const REMAP: u8>( peri: Peri<'d, T>, rx: Peri<'d, impl RxPin<T, REMAP>>, tx: Peri<'d, impl TxPin<T, REMAP>>, rts: Peri<'d, impl RtsPin<T, REMAP>>, cts: Peri<'d, impl CtsPin<T, REMAP>>, config: Config, ) -> Result<Self, ConfigError>

Create a new bidirectional UART with request-to-send and clear-to-send pins

Source

pub fn new_blocking_half_duplex<const REMAP: u8>( peri: Peri<'d, T>, tx: Peri<'d, impl TxPin<T, REMAP>>, config: Config, ) -> Result<Self, ConfigError>

Trait Implementations§

Source§

impl<'d, T: Instance> Write for Uart<'d, T, Blocking>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a [char] into this writer, returning whether the write succeeded. Read more
1.0.0§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the [write!] macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'d, T, M> !UnwindSafe for Uart<'d, T, M>

§

impl<'d, T, M> Freeze for Uart<'d, T, M>

§

impl<'d, T, M> RefUnwindSafe for Uart<'d, T, M>
where T: RefUnwindSafe, M: RefUnwindSafe,

§

impl<'d, T, M> Send for Uart<'d, T, M>
where M: Send,

§

impl<'d, T, M> Sync for Uart<'d, T, M>
where T: Sync, M: Sync,

§

impl<'d, T, M> Unpin for Uart<'d, T, M>
where T: Unpin, M: Unpin,

§

impl<'d, T, M> UnsafeUnpin for Uart<'d, T, M>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.