Struct embassy_stm32::usart::Uart
source · pub struct Uart<'d, T: BasicInstance, 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: BasicInstance> Uart<'d, T, Async>
impl<'d, T: BasicInstance> Uart<'d, T, Async>
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 = impl TxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + '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 = impl TxDma<T>> + 'd, rx_dma: impl Peripheral<P = impl RxDma<T>> + '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 = impl TxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + '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 = impl TxDma<T>> + 'd, rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new bidirectional UART with request-to-send and clear-to-send pins
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 = impl TxDma<T>> + 'd,
rx_dma: impl Peripheral<P = impl RxDma<T>> + '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 = impl TxDma<T>> + 'd, rx_dma: impl Peripheral<P = impl RxDma<T>> + '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
][Self::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 async fn write(&mut self, buffer: &[u8]) -> Result<(), Error>
pub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error>
Perform an asynchronous write
source§impl<'d, T: BasicInstance> Uart<'d, T, Blocking>
impl<'d, T: BasicInstance> Uart<'d, T, Blocking>
sourcepub fn new_blocking(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_blocking( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new blocking bidirectional UART.
sourcepub fn new_blocking_with_rtscts(
peri: impl Peripheral<P = T> + 'd,
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
cts: impl Peripheral<P = impl CtsPin<T>> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_blocking_with_rtscts( peri: impl Peripheral<P = T> + 'd, rx: impl Peripheral<P = impl RxPin<T>> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + 'd, rts: impl Peripheral<P = impl RtsPin<T>> + 'd, cts: impl Peripheral<P = impl CtsPin<T>> + 'd, config: Config ) -> Result<Self, ConfigError>
Create a new bidirectional UART with request-to-send and clear-to-send pins
sourcepub fn new_blocking_half_duplex(
peri: impl Peripheral<P = T> + 'd,
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
config: Config
) -> Result<Self, ConfigError>
pub fn new_blocking_half_duplex( peri: impl Peripheral<P = T> + 'd, tx: impl Peripheral<P = impl TxPin<T>> + '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
][Self::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).
Trait Implementations§
source§impl<'d, T: BasicInstance, M: Mode> SetConfig for Uart<'d, T, M>
impl<'d, T: BasicInstance, M: Mode> SetConfig for Uart<'d, T, M>
§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config
fails.