aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Martins <[email protected]>2024-10-21 14:48:57 -0300
committerLucas Martins <[email protected]>2024-10-21 14:48:57 -0300
commitc0addc005bb3859436cb1c2931b41a7065703077 (patch)
tree2a80cc5e835c5240c0227cd00f46af308974b6d4
parente782eabff743175b34489401574d1988c370f06f (diff)
add uart permutations usefull for rs485
-rw-r--r--embassy-stm32/src/usart/buffered.rs49
1 files changed, 49 insertions, 0 deletions
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs
index 4fbe33b2e..03c0934f9 100644
--- a/embassy-stm32/src/usart/buffered.rs
+++ b/embassy-stm32/src/usart/buffered.rs
@@ -246,6 +246,55 @@ impl<'d> BufferedUart<'d> {
246 ) 246 )
247 } 247 }
248 248
249
250 /// Create a new bidirectional buffered UART driver with only RTS pin as the DE pin
251 pub fn new_with_rts_as_de<T: Instance>(
252 peri: impl Peripheral<P = T> + 'd,
253 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
254 rx: impl Peripheral<P = impl RxPin<T>> + 'd,
255 tx: impl Peripheral<P = impl TxPin<T>> + 'd,
256 rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
257 tx_buffer: &'d mut [u8],
258 rx_buffer: &'d mut [u8],
259 config: Config,
260 ) -> Result<Self, ConfigError> {
261 Self::new_inner(
262 peri,
263 new_pin!(rx, AfType::input(Pull::None)),
264 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
265 None,
266 None,
267 new_pin!(rts, AfType::input(Pull::None)), // RTS mapped used as DE
268 tx_buffer,
269 rx_buffer,
270 config,
271 )
272 }
273
274 /// Create a new bidirectional buffered UART driver with only the request-to-send pin
275 pub fn new_with_rts<T: Instance>(
276 peri: impl Peripheral<P = T> + 'd,
277 _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd,
278 rx: impl Peripheral<P = impl RxPin<T>> + 'd,
279 tx: impl Peripheral<P = impl TxPin<T>> + 'd,
280 rts: impl Peripheral<P = impl RtsPin<T>> + 'd,
281 tx_buffer: &'d mut [u8],
282 rx_buffer: &'d mut [u8],
283 config: Config,
284 ) -> Result<Self, ConfigError> {
285 Self::new_inner(
286 peri,
287 new_pin!(rx, AfType::input(Pull::None)),
288 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
289 new_pin!(rts, AfType::input(Pull::None)),
290 None, // no RTS
291 None, // no DE
292 tx_buffer,
293 rx_buffer,
294 config,
295 )
296 }
297
249 /// Create a new bidirectional buffered UART driver with a driver-enable pin 298 /// Create a new bidirectional buffered UART driver with a driver-enable pin
250 #[cfg(not(any(usart_v1, usart_v2)))] 299 #[cfg(not(any(usart_v1, usart_v2)))]
251 pub fn new_with_de<T: Instance>( 300 pub fn new_with_de<T: Instance>(