File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -133,25 +133,20 @@ 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. pe ( ) . bit_is_set ( ) {
142+ } else if read . be ( ) . bit_is_set ( ) {
143+ error = Some ( ReadErrorType :: Break ) ;
144+ } else if read. pe ( ) . bit_is_set ( ) {
141145 error = Some ( ReadErrorType :: Parity ) ;
142- }
143-
144- if read. fe ( ) . bit_is_set ( ) {
146+ } else if read. fe ( ) . bit_is_set ( ) {
145147 error = Some ( ReadErrorType :: Framing ) ;
146148 }
147149
148- // A break condition is also a framing error.
149- // As it is the more specific code, return
150- // the break error.
151- if read. be ( ) . bit_is_set ( ) {
152- error = Some ( ReadErrorType :: Break ) ;
153- }
154-
155150 if let Some ( err_type) = error {
156151 return Err ( Other ( ReadError {
157152 err_type,
You can’t perform that action at this time.
0 commit comments