Don't read data register to clear flags on usart v3 ^& v4
This commit is contained in:
parent
d236f3dbf9
commit
b4f96e192c
1 changed files with 4 additions and 2 deletions
|
@ -21,8 +21,10 @@ impl<T: BasicInstance> interrupt::typelevel::Handler<T::Interrupt> for Interrupt
|
|||
// RX
|
||||
unsafe {
|
||||
let sr = sr(r).read();
|
||||
// Reading DR clears the rxne, error and idle interrupt flags on v1.
|
||||
let dr = if sr.ore() || sr.idle() || sr.rxne() {
|
||||
// On v1 & v2, reading DR clears the rxne, error and idle interrupt
|
||||
// flags. Keep this close to the SR read to reduce the chance of a
|
||||
// flag being set in-between.
|
||||
let dr = if sr.rxne() || cfg!(any(usart_v1, usart_v2)) && (sr.ore() || sr.idle()) {
|
||||
Some(rdr(r).read_volatile())
|
||||
} else {
|
||||
None
|
||||
|
|
Loading…
Reference in a new issue