diff options
| author | Daniel Trnka <[email protected]> | 2024-08-21 13:15:48 +0200 |
|---|---|---|
| committer | Daniel Trnka <[email protected]> | 2024-08-25 21:49:43 +0200 |
| commit | bea1f34440eff7842c0c04e8b7381cdb429f5005 (patch) | |
| tree | 63b9c0e80de2ea634808e46568892661fcec098b | |
| parent | 1ff1f00d5a1125936d5fd3ba81c0b5c398f4cf33 (diff) | |
stm32/usart: sending break character
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 89d92dda2..cbd4ac3bc 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -520,6 +520,21 @@ impl<'d, M: Mode> UartTx<'d, M> { | |||
| 520 | pub fn blocking_flush(&mut self) -> Result<(), Error> { | 520 | pub fn blocking_flush(&mut self) -> Result<(), Error> { |
| 521 | blocking_flush(self.info) | 521 | blocking_flush(self.info) |
| 522 | } | 522 | } |
| 523 | |||
| 524 | /// Send break character | ||
| 525 | pub fn send_break(&self) { | ||
| 526 | // Busy wait until previous break has been sent | ||
| 527 | #[cfg(any(usart_v1, usart_v2))] | ||
| 528 | while self.info.regs.cr1().read().sbk() {} | ||
| 529 | #[cfg(any(usart_v3, usart_v4))] | ||
| 530 | while self.info.regs.isr().read().sbkf() {} | ||
| 531 | |||
| 532 | // Send break right after completing the current character transmission | ||
| 533 | #[cfg(any(usart_v1, usart_v2))] | ||
| 534 | self.info.regs.cr1().modify(|w| w.set_sbk(true)); | ||
| 535 | #[cfg(any(usart_v3, usart_v4))] | ||
| 536 | self.info.regs.rqr().write(|w| w.set_sbkrq(true)); | ||
| 537 | } | ||
| 523 | } | 538 | } |
| 524 | 539 | ||
| 525 | fn blocking_flush(info: &Info) -> Result<(), Error> { | 540 | fn blocking_flush(info: &Info) -> Result<(), Error> { |
| @@ -1365,6 +1380,11 @@ impl<'d, M: Mode> Uart<'d, M> { | |||
| 1365 | pub fn split(self) -> (UartTx<'d, M>, UartRx<'d, M>) { | 1380 | pub fn split(self) -> (UartTx<'d, M>, UartRx<'d, M>) { |
| 1366 | (self.tx, self.rx) | 1381 | (self.tx, self.rx) |
| 1367 | } | 1382 | } |
| 1383 | |||
| 1384 | /// Send break character | ||
| 1385 | pub fn send_break(&self) { | ||
| 1386 | self.tx.send_break(); | ||
| 1387 | } | ||
| 1368 | } | 1388 | } |
| 1369 | 1389 | ||
| 1370 | fn reconfigure(info: &Info, kernel_clock: Hertz, config: &Config) -> Result<(), ConfigError> { | 1390 | fn reconfigure(info: &Info, kernel_clock: Hertz, config: &Config) -> Result<(), ConfigError> { |
