Skip to content

Commit

Permalink
stm32 uart: fix buffered flush for usart_v1, usart_v2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andresv authored and Dirbaio committed Jan 19, 2024
1 parent 534c53c commit ec2e3de
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion embassy-stm32/src/usart/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for Interrupt
// indicates that all bytes are pushed out from the FIFO.
// For other usart variants it shows that last byte from the buffer was just sent.
if sr_val.tc() {
// For others it is cleared above with `clear_interrupt_flags`.
#[cfg(any(usart_v1, usart_v2))]
sr(r).modify(|w| w.set_tc(false));

r.cr1().modify(|w| {
w.set_tcie(false);
});

state.tx_done.store(true, Ordering::Release);
state.rx_waker.wake();
state.tx_waker.wake();
}

// TX
Expand Down

0 comments on commit ec2e3de

Please sign in to comment.