diff options
| author | xoviat <[email protected]> | 2025-10-29 17:46:44 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-10-29 17:46:44 -0500 |
| commit | cc2bb1c348b595c9bd17e0807f377d04406367dd (patch) | |
| tree | 3ed0e6de519d29995d48a2553007842679a4c176 /embassy-stm32/src/usart | |
| parent | 1bbf35bdf47fa031181a8e8539f0641585672c81 (diff) | |
stm32/uart: fix rb uart race
closes #4682
Diffstat (limited to 'embassy-stm32/src/usart')
| -rw-r--r-- | embassy-stm32/src/usart/ringbuffered.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs index 20bfefd9e..710272e4e 100644 --- a/embassy-stm32/src/usart/ringbuffered.rs +++ b/embassy-stm32/src/usart/ringbuffered.rs | |||
| @@ -7,7 +7,9 @@ use embassy_embedded_hal::SetConfig; | |||
| 7 | use embedded_io_async::ReadReady; | 7 | use embedded_io_async::ReadReady; |
| 8 | use futures_util::future::{Either, select}; | 8 | use futures_util::future::{Either, select}; |
| 9 | 9 | ||
| 10 | use super::{Config, ConfigError, Error, Info, State, UartRx, rdr, reconfigure, set_baudrate, sr}; | 10 | use super::{ |
| 11 | Config, ConfigError, Error, Info, State, UartRx, clear_interrupt_flags, rdr, reconfigure, set_baudrate, sr, | ||
| 12 | }; | ||
| 11 | use crate::Peri; | 13 | use crate::Peri; |
| 12 | use crate::dma::ReadableRingBuffer; | 14 | use crate::dma::ReadableRingBuffer; |
| 13 | use crate::gpio::{AnyPin, SealedPin as _}; | 15 | use crate::gpio::{AnyPin, SealedPin as _}; |
| @@ -343,19 +345,12 @@ fn check_idle_and_errors(r: Regs) -> Result<bool, Error> { | |||
| 343 | // SAFETY: read only and we only use Rx related flags | 345 | // SAFETY: read only and we only use Rx related flags |
| 344 | let sr = sr(r).read(); | 346 | let sr = sr(r).read(); |
| 345 | 347 | ||
| 346 | #[cfg(any(usart_v3, usart_v4))] | ||
| 347 | r.icr().write(|w| { | ||
| 348 | w.set_idle(true); | ||
| 349 | w.set_pe(true); | ||
| 350 | w.set_fe(true); | ||
| 351 | w.set_ne(true); | ||
| 352 | w.set_ore(true); | ||
| 353 | }); | ||
| 354 | #[cfg(not(any(usart_v3, usart_v4)))] | 348 | #[cfg(not(any(usart_v3, usart_v4)))] |
| 355 | unsafe { | 349 | unsafe { |
| 356 | // This read also clears the error and idle interrupt flags on v1 (TODO and v2?) | 350 | // This read also clears the error and idle interrupt flags on v1 (TODO and v2?) |
| 357 | rdr(r).read_volatile() | 351 | rdr(r).read_volatile() |
| 358 | }; | 352 | }; |
| 353 | clear_interrupt_flags(r, sr); | ||
| 359 | sr | 354 | sr |
| 360 | }); | 355 | }); |
| 361 | if sr.pe() { | 356 | if sr.pe() { |
