embassy-stm32: add rs485 driver enable to uart
This commit is contained in:
parent
58ab829049
commit
236d104844
@ -244,11 +244,13 @@ fn main() {
|
|||||||
(("usart", "CTS"), quote!(crate::usart::CtsPin)),
|
(("usart", "CTS"), quote!(crate::usart::CtsPin)),
|
||||||
(("usart", "RTS"), quote!(crate::usart::RtsPin)),
|
(("usart", "RTS"), quote!(crate::usart::RtsPin)),
|
||||||
(("usart", "CK"), quote!(crate::usart::CkPin)),
|
(("usart", "CK"), quote!(crate::usart::CkPin)),
|
||||||
|
(("usart", "DE"), quote!(crate::usart::DePin)),
|
||||||
(("lpuart", "TX"), quote!(crate::usart::TxPin)),
|
(("lpuart", "TX"), quote!(crate::usart::TxPin)),
|
||||||
(("lpuart", "RX"), quote!(crate::usart::RxPin)),
|
(("lpuart", "RX"), quote!(crate::usart::RxPin)),
|
||||||
(("lpuart", "CTS"), quote!(crate::usart::CtsPin)),
|
(("lpuart", "CTS"), quote!(crate::usart::CtsPin)),
|
||||||
(("lpuart", "RTS"), quote!(crate::usart::RtsPin)),
|
(("lpuart", "RTS"), quote!(crate::usart::RtsPin)),
|
||||||
(("lpuart", "CK"), quote!(crate::usart::CkPin)),
|
(("lpuart", "CK"), quote!(crate::usart::CkPin)),
|
||||||
|
(("lpuart", "DE"), quote!(crate::usart::DePin)),
|
||||||
(("spi", "SCK"), quote!(crate::spi::SckPin)),
|
(("spi", "SCK"), quote!(crate::spi::SckPin)),
|
||||||
(("spi", "MOSI"), quote!(crate::spi::MosiPin)),
|
(("spi", "MOSI"), quote!(crate::spi::MosiPin)),
|
||||||
(("spi", "MISO"), quote!(crate::spi::MisoPin)),
|
(("spi", "MISO"), quote!(crate::spi::MisoPin)),
|
||||||
|
@ -89,6 +89,33 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
|
|||||||
Self::new_inner(state, peri, rx, tx, irq, tx_buffer, rx_buffer, config)
|
Self::new_inner(state, peri, rx, tx, irq, tx_buffer, rx_buffer, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(usart_v1))]
|
||||||
|
pub fn new_with_de(
|
||||||
|
state: &'d mut State<'d, T>,
|
||||||
|
peri: impl Peripheral<P = T> + 'd,
|
||||||
|
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||||
|
tx: impl Peripheral<P = impl TxPin<T>> + 'd,
|
||||||
|
irq: impl Peripheral<P = T::Interrupt> + 'd,
|
||||||
|
de: impl Peripheral<P = impl DePin<T>> + 'd,
|
||||||
|
tx_buffer: &'d mut [u8],
|
||||||
|
rx_buffer: &'d mut [u8],
|
||||||
|
config: Config,
|
||||||
|
) -> BufferedUart<'d, T> {
|
||||||
|
into_ref!(de);
|
||||||
|
|
||||||
|
T::enable();
|
||||||
|
T::reset();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
de.set_as_af(de.af_num(), AFType::OutputPushPull);
|
||||||
|
T::regs().cr3().write(|w| {
|
||||||
|
w.set_dem(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Self::new_inner(state, peri, rx, tx, irq, tx_buffer, rx_buffer, config)
|
||||||
|
}
|
||||||
|
|
||||||
fn new_inner(
|
fn new_inner(
|
||||||
state: &'d mut State<'d, T>,
|
state: &'d mut State<'d, T>,
|
||||||
_peri: impl Peripheral<P = T> + 'd,
|
_peri: impl Peripheral<P = T> + 'd,
|
||||||
|
@ -646,6 +646,31 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
|
|||||||
Self::new_inner(peri, rx, tx, irq, tx_dma, rx_dma, config)
|
Self::new_inner(peri, rx, tx, irq, tx_dma, rx_dma, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(usart_v1))]
|
||||||
|
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 Peripheral<P = T::Interrupt> + '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,
|
||||||
|
) -> Self {
|
||||||
|
into_ref!(de);
|
||||||
|
|
||||||
|
T::enable();
|
||||||
|
T::reset();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
de.set_as_af(de.af_num(), AFType::OutputPushPull);
|
||||||
|
T::regs().cr3().write(|w| {
|
||||||
|
w.set_dem(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Self::new_inner(peri, rx, tx, irq, tx_dma, rx_dma, config)
|
||||||
|
}
|
||||||
|
|
||||||
fn new_inner(
|
fn new_inner(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: impl Peripheral<P = T> + 'd,
|
||||||
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
rx: impl Peripheral<P = impl RxPin<T>> + 'd,
|
||||||
@ -1040,6 +1065,7 @@ pin_trait!(TxPin, BasicInstance);
|
|||||||
pin_trait!(CtsPin, BasicInstance);
|
pin_trait!(CtsPin, BasicInstance);
|
||||||
pin_trait!(RtsPin, BasicInstance);
|
pin_trait!(RtsPin, BasicInstance);
|
||||||
pin_trait!(CkPin, BasicInstance);
|
pin_trait!(CkPin, BasicInstance);
|
||||||
|
pin_trait!(DePin, BasicInstance);
|
||||||
|
|
||||||
dma_trait!(TxDma, BasicInstance);
|
dma_trait!(TxDma, BasicInstance);
|
||||||
dma_trait!(RxDma, BasicInstance);
|
dma_trait!(RxDma, BasicInstance);
|
||||||
|
Loading…
Reference in New Issue
Block a user