diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 8a0c85d2c..ea727b010 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -743,7 +743,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { T::enable_and_reset(); T::enable_and_reset(); - Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config) + Self::new_inner_configure(peri, rx, tx, tx_dma, rx_dma, config) } /// Create a new bidirectional UART with request-to-send and clear-to-send pins @@ -770,7 +770,7 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { w.set_rtse(true); w.set_ctse(true); }); - Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config) + Self::new_inner_configure(peri, rx, tx, tx_dma, rx_dma, config) } #[cfg(not(any(usart_v1, usart_v2)))] @@ -795,10 +795,76 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> { T::regs().cr3().write(|w| { w.set_dem(true); }); - Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config) + Self::new_inner_configure(peri, rx, tx, tx_dma, rx_dma, config) } - fn new_inner( + /// 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). + #[cfg(not(any(usart_v1, usart_v2)))] + #[doc(alias("HDSEL"))] + pub fn new_half_duplex( + peri: impl Peripheral
+ 'd, + tx: impl Peripheral
> + 'd,
+ _irq: impl interrupt::typelevel::Binding + 'd,
+ rx_dma: impl Peripheral + 'd,
+ mut config: Config,
+ ) -> Result + 'd,
+ rx: impl Peripheral > + 'd,
+ _irq: impl interrupt::typelevel::Binding + 'd,
+ rx_dma: impl Peripheral + 'd,
+ mut config: Config,
+ ) -> Result + 'd,
rx: impl Peripheral > + 'd,
tx: impl Peripheral > + 'd,
@@ -808,8 +874,6 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
) -> Result