Skip to content

Commit 2057512

Browse files
authored
Merge pull request #91 from jonathanpallant/fix_uart_overflow_sticky
Clear UART overflow bit.
2 parents cb7c827 + 528bfb5 commit 2057512

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212
- Wrong default modes for debug GPIO pins
1313
- Wrong calculation of HCLK prescaler, if using a prescaler value equal or
1414
higher than 64 ([#42](https://github.com/stm32-rs/stm32f3xx-hal/pull/42))
15+
- UART reception error flags not cleared ([#91](https://github.com/stm32-rs/stm32f3xx-hal/pull/91))
1516

1617
## [v0.4.2] - 2020-03-21
1718

src/serial.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,20 @@ macro_rules! hal {
319319
// NOTE(unsafe) atomic read with no side effects
320320
let isr = unsafe { (*$USARTX::ptr()).isr.read() };
321321

322+
// NOTE(unsafe, write) write accessor for atomic writes with no side effects
323+
let icr = unsafe { &(*$USARTX::ptr()).icr };
324+
322325
Err(if isr.pe().bit_is_set() {
326+
icr.write(|w| w.pecf().clear());
323327
nb::Error::Other(Error::Parity)
324328
} else if isr.fe().bit_is_set() {
329+
icr.write(|w| w.fecf().clear());
325330
nb::Error::Other(Error::Framing)
326331
} else if isr.nf().bit_is_set() {
332+
icr.write(|w| w.ncf().clear());
327333
nb::Error::Other(Error::Noise)
328334
} else if isr.ore().bit_is_set() {
335+
icr.write(|w| w.orecf().clear());
329336
nb::Error::Other(Error::Overrun)
330337
} else if isr.rxne().bit_is_set() {
331338
// NOTE(read_volatile) see `write_volatile` below

0 commit comments

Comments
 (0)