Skip to content

Commit

Permalink
Merge pull request #712 from jannic/report-break-condition
Browse files Browse the repository at this point in the history
Properly report break conditions
  • Loading branch information
ithinuel authored Jan 6, 2024
2 parents bbdc2e9 + 6a1a0a2 commit 6b040de
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions rp2040-hal/src/uart/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,17 @@ pub(crate) fn read_raw<'b, D: UartDevice>(

let read = device.uartdr.read();

// If multiple status bits are set, report
// the most serious or most specific condition,
// in the following order of precedence:
// overrun > break > parity > framing
if read.oe().bit_is_set() {
error = Some(ReadErrorType::Overrun);
}

if read.be().bit_is_set() {
} else if read.be().bit_is_set() {
error = Some(ReadErrorType::Break);
}

if read.pe().bit_is_set() {
} else if read.pe().bit_is_set() {
error = Some(ReadErrorType::Parity);
}

if read.fe().bit_is_set() {
} else if read.fe().bit_is_set() {
error = Some(ReadErrorType::Framing);
}

Expand Down

0 comments on commit 6b040de

Please sign in to comment.