Struct embassy_stm32::usart::Uart
source · pub struct Uart<'d, T: BasicInstance, TxDma = NoDma, RxDma = NoDma> { /* private fields */ }
Expand description
Bidirectional UART Driver
Implementations§
source§impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma>
impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma>
sourcepub fn new(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
tx_dma: impl Peripheral<P = TxDma> + 'd,
rx_dma: impl Peripheral<P = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, tx_dma: impl Peripheral<P = TxDma> + 'd, rx_dma: impl Peripheral<P = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new bidirectional UART
sourcepub fn new_with_rtscts(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
cts: impl Peripheral<P = impl CtsPin<T>> + 'd,
tx_dma: impl Peripheral<P = TxDma> + 'd,
rx_dma: impl Peripheral<P = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_with_rtscts( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, rts: impl Peripheral<P = impl RtsPin<T>> + 'd, cts: impl Peripheral<P = impl CtsPin<T>> + 'd, tx_dma: impl Peripheral<P = TxDma> + 'd, rx_dma: impl Peripheral<P = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new bidirectional UART with request-to-send and clear-to-send pins
sourcepub fn new_with_de(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
de: impl Peripheral<P = impl DePin<T>> + 'd,
tx_dma: impl Peripheral<P = TxDma> + 'd,
rx_dma: impl Peripheral<P = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_with_de( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, de: impl Peripheral<P = impl DePin<T>> + 'd, tx_dma: impl Peripheral<P = TxDma> + 'd, rx_dma: impl Peripheral<P = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new bidirectional UART with a driver-enable pin
sourcepub fn new_half_duplex(
peri: impl Peripheral<P = T> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
tx_dma: impl Peripheral<P = TxDma> + 'd,
rx_dma: impl Peripheral<P = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_half_duplex( peri: impl Peripheral<P = T> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, tx_dma: impl Peripheral<P = TxDma> + 'd, rx_dma: impl Peripheral<P = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a single-wire half-duplex Uart transceiver on a single Tx pin.
See new_half_duplex_on_rx
if you would prefer to use an Rx pin.
There is no functional difference between these methods, as both allow bidirectional communication.
The pin is always released when no data is transmitted. Thus, it acts as a standard I/O in idle or in reception. Apart from this, the communication protocol is similar to normal USART mode. Any conflict on the line must be managed by software (for instance by using a centralized arbiter).
sourcepub fn new_half_duplex_on_rx(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
tx_dma: impl Peripheral<P = TxDma> + 'd,
rx_dma: impl Peripheral<P = RxDma> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_half_duplex_on_rx( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, tx_dma: impl Peripheral<P = TxDma> + 'd, rx_dma: impl Peripheral<P = RxDma> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a single-wire half-duplex Uart transceiver on a single Rx pin.
See new_half_duplex
if you would prefer to use an Tx pin.
There is no functional difference between these methods, as both allow bidirectional communication.
The pin is always released when no data is transmitted. Thus, it acts as a standard I/O in idle or in reception. Apart from this, the communication protocol is similar to normal USART mode. Any conflict on the line must be managed by software (for instance by using a centralized arbiter).
sourcepub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error>where
TxDma: TxDma<T>,
pub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error>where
TxDma: TxDma<T>,
Initiate an asynchronous write
sourcepub fn blocking_flush(&mut self) -> Result<(), Error>
pub fn blocking_flush(&mut self) -> Result<(), Error>
Block until transmission complete
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 read into buffer
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
Trait Implementations§
source§impl<T, TxDma, RxDma> ErrorType for Uart<'_, T, TxDma, RxDma>where
T: BasicInstance,
impl<T, TxDma, RxDma> ErrorType for Uart<'_, T, TxDma, RxDma>where
T: BasicInstance,
source§impl<'d, T: BasicInstance, TxDma, RxDma> ErrorType for Uart<'d, T, TxDma, RxDma>
impl<'d, T: BasicInstance, TxDma, RxDma> ErrorType for Uart<'d, T, TxDma, RxDma>
source§impl<'d, T: BasicInstance, TxDma, RxDma> Read for Uart<'d, T, TxDma, RxDma>
impl<'d, T: BasicInstance, TxDma, RxDma> Read for Uart<'d, T, TxDma, RxDma>
source§impl<'d, T: BasicInstance, TxDma, RxDma> SetConfig for Uart<'d, T, TxDma, RxDma>
impl<'d, T: BasicInstance, TxDma, RxDma> SetConfig for Uart<'d, T, TxDma, RxDma>
§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config
fails.