Skip to content

Commit 6b040de

Browse files
authored
Merge pull request #712 from jannic/report-break-condition
Properly report break conditions
2 parents bbdc2e9 + 6a1a0a2 commit 6b040de

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

rp2040-hal/src/uart/reader.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,17 @@ pub(crate) fn read_raw<'b, D: UartDevice>(
133133

134134
let read = device.uartdr.read();
135135

136+
// If multiple status bits are set, report
137+
// the most serious or most specific condition,
138+
// in the following order of precedence:
139+
// overrun > break > parity > framing
136140
if read.oe().bit_is_set() {
137141
error = Some(ReadErrorType::Overrun);
138-
}
139-
140-
if read.be().bit_is_set() {
142+
} else if read.be().bit_is_set() {
141143
error = Some(ReadErrorType::Break);
142-
}
143-
144-
if read.pe().bit_is_set() {
144+
} else if read.pe().bit_is_set() {
145145
error = Some(ReadErrorType::Parity);
146-
}
147-
148-
if read.fe().bit_is_set() {
146+
} else if read.fe().bit_is_set() {
149147
error = Some(ReadErrorType::Framing);
150148
}
151149

0 commit comments

Comments
 (0)