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