diff options
| author | Kenneth Knudsen <[email protected]> | 2024-11-04 15:08:57 +0100 |
|---|---|---|
| committer | Kenneth Knudsen <[email protected]> | 2024-11-04 15:08:57 +0100 |
| commit | aa453caa79a0f612698e0bcb3bfff635a172eb5f (patch) | |
| tree | cb9ae925eb2dddb6fdd43d135fed3a8aabd73ca8 /embassy-stm32/src | |
| parent | 3d8e987bf3ee8370b4532da73c9ba19ac0f437f7 (diff) | |
add split_ref for stm32 uart
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/usart/buffered.rs | 7 | ||||
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 7ba209063..d7ac33d07 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs | |||
| @@ -396,6 +396,13 @@ impl<'d> BufferedUart<'d> { | |||
| 396 | (self.tx, self.rx) | 396 | (self.tx, self.rx) |
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | /// Split the Uart into a transmitter and receiver by mutable reference, | ||
| 400 | /// which is particularly useful when having two tasks correlating to | ||
| 401 | /// transmitting and receiving. | ||
| 402 | pub fn split_ref(&mut self) -> (&mut BufferedUartTx<'d>, &mut BufferedUartRx<'d>) { | ||
| 403 | (&mut self.tx, &mut self.rx) | ||
| 404 | } | ||
| 405 | |||
| 399 | /// Reconfigure the driver | 406 | /// Reconfigure the driver |
| 400 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { | 407 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { |
| 401 | reconfigure(self.rx.info, self.rx.kernel_clock, config)?; | 408 | reconfigure(self.rx.info, self.rx.kernel_clock, config)?; |
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 333e01e36..8152fc560 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -1440,6 +1440,13 @@ impl<'d, M: Mode> Uart<'d, M> { | |||
| 1440 | (self.tx, self.rx) | 1440 | (self.tx, self.rx) |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | /// Split the Uart into a transmitter and receiver by mutable reference, | ||
| 1444 | /// which is particularly useful when having two tasks correlating to | ||
| 1445 | /// transmitting and receiving. | ||
| 1446 | pub fn split_ref(&mut self) -> (&mut UartTx<'d, M>, &mut UartRx<'d, M>) { | ||
| 1447 | (&mut self.tx, &mut self.rx) | ||
| 1448 | } | ||
| 1449 | |||
| 1443 | /// Send break character | 1450 | /// Send break character |
| 1444 | pub fn send_break(&self) { | 1451 | pub fn send_break(&self) { |
| 1445 | self.tx.send_break(); | 1452 | self.tx.send_break(); |
