mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-24 15:52:34 +00:00
add uart permutations usefull for rs485
This commit is contained in:
parent
e782eabff7
commit
c0addc005b
@ -246,6 +246,55 @@ impl<'d> BufferedUart<'d> {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
/// Create a new bidirectional buffered UART driver with only 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 RTS
|
||||
None, // no DE
|
||||
tx_buffer,
|
||||
rx_buffer,
|
||||
config,
|
||||
)
|
||||
}
|
||||
|
||||
/// Create a new bidirectional buffered UART driver with a driver-enable pin
|
||||
#[cfg(not(any(usart_v1, usart_v2)))]
|
||||
pub fn new_with_de<T: Instance>(
|
||||
|
Loading…
Reference in New Issue
Block a user