@@ -137,6 +137,8 @@ pub enum Event {
137137 // /// [`Serial::set_wakeup_from_stopmode_reason()`]
138138 // #[doc(alias = "WUF")]
139139 // WakeupFromStopMode,
140+ /// Any of the above events occurred
141+ Any ,
140142}
141143
142144/// Serial error
@@ -490,7 +492,8 @@ where
490492 self . configure_interrupt ( event, Switch :: Off ) ;
491493 }
492494
493- /// Enable or disable the interrupt for the specified [`Event`].
495+ /// Enable or disable the interrupt for the specified [`Event`], if passing [`Event::Any`]
496+ /// , it will be apply to all events.
494497 #[ inline]
495498 pub fn configure_interrupt ( & mut self , event : Event , enable : impl Into < Switch > ) {
496499 // Do a round way trip to be convert Into<Switch> -> bool
@@ -513,7 +516,28 @@ where
513516 Event :: ReceiverTimeout => self . usart . cr1 . modify ( |_, w| w. rtoie ( ) . bit ( enable) ) ,
514517 // Event::EndOfBlock => self.usart.cr1.modify(|_, w| w.eobie().bit(enable)),
515518 // Event::WakeupFromStopMode => self.usart.cr3.modify(|_, w| w.wufie().bit(enable)),
519+ Event :: Any => {
520+ self . usart . cr1 . modify ( |_, w| {
521+ w. txeie ( ) . bit ( enable) ;
522+ w. tcie ( ) . bit ( enable) ;
523+ w. rxneie ( ) . bit ( enable) ;
524+ w. peie ( ) . bit ( enable) ;
525+ w. idleie ( ) . bit ( enable) ;
526+ w. cmie ( ) . bit ( enable) ;
527+ w. rtoie ( ) . bit ( enable)
528+ // w.eobie().bit(enable);
529+ } ) ;
530+ self . usart . cr2 . modify ( |_, w| {
531+ w. lbdie ( ) . bit ( enable)
532+ } ) ;
533+ self . usart . cr3 . modify ( |_, w| {
534+ w. ctsie ( ) . bit ( enable) ;
535+ w. eie ( ) . bit ( enable)
536+ // w.wufie().bit(enable);
537+ } )
538+ }
516539 } ;
540+
517541 }
518542
519543 /// Enable or disable interrupt for the specified [`Event`]s.
@@ -588,6 +612,8 @@ where
588612 Event :: ReceiverTimeout => isr. rtof ( ) . bit ( ) ,
589613 // Event::EndOfBlock => isr.eobf().bit(),
590614 // Event::WakeupFromStopMode => isr.wuf().bit(),
615+ Event :: Any => isr. bits ( ) != 0 , // TODO: should we return true if any of ISR bit is 1?
616+
591617 }
592618 }
593619
@@ -640,6 +666,21 @@ where
640666 // Do nothing with this event (only useful for Smartcard, which is not
641667 // supported right now)
642668 Event :: TransmitDataRegisterEmtpy => w,
669+ Event :: Any => {
670+ w. ctscf ( ) . clear ( ) ;
671+ w. tccf ( ) . clear ( ) ;
672+ w. orecf ( ) . clear ( ) ;
673+ w. idlecf ( ) . clear ( ) ;
674+ w. pecf ( ) . clear ( ) ;
675+ w. pecf ( ) . clear ( ) ;
676+ w. lbdcf ( ) . clear ( ) ;
677+ w. ncf ( ) . clear ( ) ;
678+ w. fecf ( ) . clear ( ) ;
679+ w. cmcf ( ) . clear ( ) ;
680+ w. rtocf ( ) . clear ( ) ;
681+ self . usart . rqr . write ( |w| w. rxfrq ( ) . set_bit ( ) ) ;
682+ w
683+ }
643684 } ) ;
644685 }
645686
0 commit comments