@@ -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.
@@ -640,6 +664,21 @@ where
640664 // Do nothing with this event (only useful for Smartcard, which is not
641665 // supported right now)
642666 Event :: TransmitDataRegisterEmtpy => w,
667+ Event :: Any => {
668+ w. ctscf ( ) . clear ( ) ;
669+ w. tccf ( ) . clear ( ) ;
670+ w. orecf ( ) . clear ( ) ;
671+ w. idlecf ( ) . clear ( ) ;
672+ w. pecf ( ) . clear ( ) ;
673+ w. pecf ( ) . clear ( ) ;
674+ w. lbdcf ( ) . clear ( ) ;
675+ w. ncf ( ) . clear ( ) ;
676+ w. fecf ( ) . clear ( ) ;
677+ w. cmcf ( ) . clear ( ) ;
678+ w. rtocf ( ) . clear ( ) ;
679+ self . usart . rqr . write ( |w| w. rxfrq ( ) . set_bit ( ) ) ;
680+ w
681+ }
643682 } ) ;
644683 }
645684
0 commit comments