Merge pull request #3441 from Luctins/chore/usart-add-rts-only-new

STM32: Add BufferedUart::new permutations usefull for RS485
This commit is contained in:
Dario Nieuwenhuis 2024-10-22 09:55:59 +00:00 committed by GitHub
commit 398119ae43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -246,6 +246,54 @@ impl<'d> BufferedUart<'d> {
) )
} }
/// Create a new bidirectional buffered UART driver with only the RTS pin as the DE pin
pub fn new_with_rts_as_de<T: Instance>(
peri: impl Peripheral<P = T> + 'd,
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<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,
tx_buffer: &'d mut [u8],
rx_buffer: &'d mut [u8],
config: Config,
) -> Result<Self, ConfigError> {
Self::new_inner(
peri,
new_pin!(rx, AfType::input(Pull::None)),
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
None,
None,
new_pin!(rts, AfType::input(Pull::None)), // RTS mapped used as DE
tx_buffer,
rx_buffer,
config,
)
}
/// Create a new bidirectional buffered UART driver with only the request-to-send pin
pub fn new_with_rts<T: Instance>(
peri: impl Peripheral<P = T> + 'd,
_irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<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,
tx_buffer: &'d mut [u8],
rx_buffer: &'d mut [u8],
config: Config,
) -> Result<Self, ConfigError> {
Self::new_inner(
peri,
new_pin!(rx, AfType::input(Pull::None)),
new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
new_pin!(rts, AfType::input(Pull::None)),
None, // no CTS
None, // no DE
tx_buffer,
rx_buffer,
config,
)
}
/// Create a new bidirectional buffered UART driver with a driver-enable pin /// Create a new bidirectional buffered UART driver with a driver-enable pin
#[cfg(not(any(usart_v1, usart_v2)))] #[cfg(not(any(usart_v1, usart_v2)))]
pub fn new_with_de<T: Instance>( pub fn new_with_de<T: Instance>(