@@ -573,37 +573,21 @@ fn read(usart: *const SerialRegisterBlock) -> nb::Result<u8, Error> {
573
573
// NOTE(unsafe) write accessor for atomic writes with no side effects
574
574
let icr = unsafe { & ( * usart) . icr } ;
575
575
576
- let err = if isr. pe ( ) . bit_is_set ( ) {
576
+ if isr. pe ( ) . bit_is_set ( ) {
577
577
icr. write ( |w| w. pecf ( ) . set_bit ( ) ) ;
578
- nb:: Error :: Other ( Error :: Parity )
578
+ Err ( nb:: Error :: Other ( Error :: Parity ) )
579
579
} else if isr. fe ( ) . bit_is_set ( ) {
580
580
icr. write ( |w| w. fecf ( ) . set_bit ( ) ) ;
581
- nb:: Error :: Other ( Error :: Framing )
581
+ Err ( nb:: Error :: Other ( Error :: Framing ) )
582
582
} else if isr. nf ( ) . bit_is_set ( ) {
583
583
icr. write ( |w| w. ncf ( ) . set_bit ( ) ) ;
584
- nb:: Error :: Other ( Error :: Noise )
584
+ Err ( nb:: Error :: Other ( Error :: Noise ) )
585
585
} else if isr. ore ( ) . bit_is_set ( ) {
586
586
icr. write ( |w| w. orecf ( ) . set_bit ( ) ) ;
587
- nb:: Error :: Other ( Error :: Overrun )
587
+ Err ( nb:: Error :: Other ( Error :: Overrun ) )
588
588
} else if isr. rxne ( ) . bit_is_set ( ) {
589
- return Ok ( unsafe { ( * usart) . rdr . read ( ) . rdr ( ) . bits ( ) as u8 } ) ;
589
+ Ok ( unsafe { ( * usart) . rdr . read ( ) . rdr ( ) . bits ( ) as u8 } )
590
590
} else {
591
- return Err ( nb:: Error :: WouldBlock ) ;
592
- } ;
593
-
594
- // NOTE(unsafe) atomic write with no side effects other than clearing the errors we've just handled
595
- unsafe {
596
- ( * usart) . icr . write ( |w| {
597
- w. pecf ( )
598
- . set_bit ( )
599
- . fecf ( )
600
- . set_bit ( )
601
- . ncf ( )
602
- . set_bit ( )
603
- . orecf ( )
604
- . set_bit ( )
605
- } )
606
- } ;
607
-
608
- Err ( err)
591
+ Err ( nb:: Error :: WouldBlock )
592
+ }
609
593
}
0 commit comments