diff options
| author | Peter Gibson <[email protected]> | 2023-06-18 08:45:58 +1000 |
|---|---|---|
| committer | Peter Gibson <[email protected]> | 2023-06-18 08:45:58 +1000 |
| commit | b4f96e192cd8c86f437e1d155388a860dcd3e1fd (patch) | |
| tree | 8e792a6d965e2880f4ac3f58eb34c5bad52e0d42 | |
| parent | d236f3dbf9b53c5e646020946d8da1458eb591a1 (diff) | |
Don't read data register to clear flags on usart v3 ^& v4
| -rw-r--r-- | embassy-stm32/src/usart/buffered.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 530760bd1..086196a2c 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs | |||
| @@ -21,8 +21,10 @@ impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for Interrupt | |||
| 21 | // RX | 21 | // RX |
| 22 | unsafe { | 22 | unsafe { |
| 23 | let sr = sr(r).read(); | 23 | let sr = sr(r).read(); |
| 24 | // Reading DR clears the rxne, error and idle interrupt flags on v1. | 24 | // On v1 & v2, reading DR clears the rxne, error and idle interrupt |
| 25 | let dr = if sr.ore() || sr.idle() || sr.rxne() { | 25 | // flags. Keep this close to the SR read to reduce the chance of a |
| 26 | // flag being set in-between. | ||
| 27 | let dr = if sr.rxne() || cfg!(any(usart_v1, usart_v2)) && (sr.ore() || sr.idle()) { | ||
| 26 | Some(rdr(r).read_volatile()) | 28 | Some(rdr(r).read_volatile()) |
| 27 | } else { | 29 | } else { |
| 28 | None | 30 | None |
