aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Vahter <[email protected]>2024-01-19 20:28:29 +0200
committerDario Nieuwenhuis <[email protected]>2024-01-20 00:15:40 +0100
commitec2e3de0f493cd0cc116f5f67a814ae7c457d9b1 (patch)
tree570558ac922ec1125b66033a83bba6659622459e
parent534c53c901345f8af517b8991a4bcd99d290c11c (diff)
stm32 uart: fix buffered flush for usart_v1, usart_v2
There is one caveat. For some reason with first send using usart_v1/usart_v2 TC flag appears right after first byte from buffer is written to DR. Consecutive transfers work as expected - TC flag appears when last byte is fully transferred to wire.
-rw-r--r--embassy-stm32/src/usart/buffered.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs
index abc766bc7..c78752883 100644
--- a/embassy-stm32/src/usart/buffered.rs
+++ b/embassy-stm32/src/usart/buffered.rs
@@ -68,11 +68,16 @@ impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for Interrupt
68 // indicates that all bytes are pushed out from the FIFO. 68 // indicates that all bytes are pushed out from the FIFO.
69 // For other usart variants it shows that last byte from the buffer was just sent. 69 // For other usart variants it shows that last byte from the buffer was just sent.
70 if sr_val.tc() { 70 if sr_val.tc() {
71 // For others it is cleared above with `clear_interrupt_flags`.
72 #[cfg(any(usart_v1, usart_v2))]
73 sr(r).modify(|w| w.set_tc(false));
74
71 r.cr1().modify(|w| { 75 r.cr1().modify(|w| {
72 w.set_tcie(false); 76 w.set_tcie(false);
73 }); 77 });
78
74 state.tx_done.store(true, Ordering::Release); 79 state.tx_done.store(true, Ordering::Release);
75 state.rx_waker.wake(); 80 state.tx_waker.wake();
76 } 81 }
77 82
78 // TX 83 // TX