@@ -685,6 +685,18 @@ where
685
685
<Usart as Instance >:: INTERRUPT
686
686
}
687
687
688
+ /// Enable the interrupt for the specified [`Event`].
689
+ #[ inline]
690
+ pub fn enable_interrupt ( & mut self , event : Event ) {
691
+ self . configure_interrupt ( event, Toggle :: On ) ;
692
+ }
693
+
694
+ /// Disable the interrupt for the specified [`Event`].
695
+ #[ inline]
696
+ pub fn disable_interrupt ( & mut self , event : Event ) {
697
+ self . configure_interrupt ( event, Toggle :: Off ) ;
698
+ }
699
+
688
700
/// Enable or disable the interrupt for the specified [`Event`].
689
701
#[ inline]
690
702
pub fn configure_interrupt ( & mut self , event : Event , enable : impl Into < Toggle > ) -> & mut Self {
@@ -712,18 +724,6 @@ where
712
724
self
713
725
}
714
726
715
- /// Enable the interrupt for the specified [`Event`].
716
- #[ inline]
717
- pub fn enable_interrupt ( & mut self , event : Event ) {
718
- self . configure_interrupt ( event, Toggle :: On ) ;
719
- }
720
-
721
- /// Disable the interrupt for the specified [`Event`].
722
- #[ inline]
723
- pub fn disable_interrupt ( & mut self , event : Event ) {
724
- self . configure_interrupt ( event, Toggle :: Off ) ;
725
- }
726
-
727
727
/// Enable or disable interrupt for the specified [`Event`]s.
728
728
///
729
729
/// Like [`Serial::configure_interrupt`], but instead using an enumset. The corresponding
@@ -742,19 +742,26 @@ where
742
742
self
743
743
}
744
744
745
- /// Enable or disable overrun detection
746
- ///
747
- /// When overrun detection is disabled and new data is received while the
748
- /// [`Event::ReceiveDataRegisterNotEmpty`] flag is still set,
749
- /// the [`Event::OverrunError`] flag is not set and the new received data overwrites the
750
- /// previous content of the RDR register.
751
- #[ doc( alias = "OVRDIS" ) ]
745
+ /// Check if an interrupt event happend.
752
746
#[ inline]
753
- pub fn detect_overrun ( & mut self , enable : bool ) {
754
- let uart_enabled = self . usart . cr1 . read ( ) . ue ( ) . bit ( ) ;
755
- self . usart . cr1 . modify ( |_, w| w. ue ( ) . disabled ( ) ) ;
756
- self . usart . cr3 . modify ( |_, w| w. ovrdis ( ) . bit ( !enable) ) ;
757
- self . usart . cr1 . modify ( |_, w| w. ue ( ) . bit ( uart_enabled) ) ;
747
+ pub fn is_event_triggered ( & self , event : Event ) -> bool {
748
+ let isr = self . usart . isr . read ( ) ;
749
+ match event {
750
+ Event :: TransmitDataRegisterEmtpy => isr. txe ( ) . bit ( ) ,
751
+ Event :: CtsInterrupt => isr. ctsif ( ) . bit ( ) ,
752
+ Event :: TransmissionComplete => isr. tc ( ) . bit ( ) ,
753
+ Event :: ReceiveDataRegisterNotEmpty => isr. rxne ( ) . bit ( ) ,
754
+ Event :: OverrunError => isr. ore ( ) . bit ( ) ,
755
+ Event :: Idle => isr. idle ( ) . bit ( ) ,
756
+ Event :: ParityError => isr. pe ( ) . bit ( ) ,
757
+ Event :: LinBreak => isr. lbdf ( ) . bit ( ) ,
758
+ Event :: NoiseError => isr. nf ( ) . bit ( ) ,
759
+ Event :: FramingError => isr. fe ( ) . bit ( ) ,
760
+ Event :: CharacterMatch => isr. cmf ( ) . bit ( ) ,
761
+ Event :: ReceiverTimeout => isr. rtof ( ) . bit ( ) ,
762
+ // Event::EndOfBlock => isr.eobf().bit(),
763
+ // Event::WakeupFromStopMode => isr.wuf().bit(),
764
+ }
758
765
}
759
766
760
767
/// Get an [`EnumSet`] of all fired interrupt events.
@@ -782,13 +789,6 @@ where
782
789
events
783
790
}
784
791
785
- /// Clear **all** interrupt events.
786
- #[ inline]
787
- pub fn clear_events ( & mut self ) {
788
- // SAFETY: This atomic write clears all flags and ignores the reserverd bit fields.
789
- self . usart . icr . write ( |w| unsafe { w. bits ( u32:: MAX ) } ) ;
790
- }
791
-
792
792
/// Clear the given interrupt event flag.
793
793
#[ inline]
794
794
pub fn clear_event ( & mut self , event : Event ) {
@@ -816,26 +816,26 @@ where
816
816
} ) ;
817
817
}
818
818
819
- /// Check if an interrupt event happend .
819
+ /// Clear **all** interrupt events .
820
820
#[ inline]
821
- pub fn is_event_triggered ( & self , event : Event ) -> bool {
822
- let isr = self . usart . isr . read ( ) ;
823
- match event {
824
- Event :: TransmitDataRegisterEmtpy => isr . txe ( ) . bit ( ) ,
825
- Event :: CtsInterrupt => isr . ctsif ( ) . bit ( ) ,
826
- Event :: TransmissionComplete => isr . tc ( ) . bit ( ) ,
827
- Event :: ReceiveDataRegisterNotEmpty => isr . rxne ( ) . bit ( ) ,
828
- Event :: OverrunError => isr . ore ( ) . bit ( ) ,
829
- Event :: Idle => isr . idle ( ) . bit ( ) ,
830
- Event :: ParityError => isr . pe ( ) . bit ( ) ,
831
- Event :: LinBreak => isr . lbdf ( ) . bit ( ) ,
832
- Event :: NoiseError => isr . nf ( ) . bit ( ) ,
833
- Event :: FramingError => isr . fe ( ) . bit ( ) ,
834
- Event :: CharacterMatch => isr . cmf ( ) . bit ( ) ,
835
- Event :: ReceiverTimeout => isr . rtof ( ) . bit ( ) ,
836
- // Event::EndOfBlock => isr.eobf ().bit(),
837
- // Event::WakeupFromStopMode => isr.wuf ().bit(),
838
- }
821
+ pub fn clear_events ( & mut self ) {
822
+ // SAFETY: This atomic write clears all flags and ignores the reserverd bit fields.
823
+ self . usart . icr . write ( |w| unsafe { w . bits ( u32 :: MAX ) } ) ;
824
+ }
825
+
826
+ /// Enable or disable overrun detection
827
+ ///
828
+ /// When overrun detection is disabled and new data is received while the
829
+ /// [` Event::ReceiveDataRegisterNotEmpty`] flag is still set ,
830
+ /// the [`Event::OverrunError`] flag is not set and the new received data overwrites the
831
+ /// previous content of the RDR register.
832
+ # [ doc ( alias = "OVRDIS" ) ]
833
+ # [ inline ]
834
+ pub fn detect_overrun ( & mut self , enable : bool ) {
835
+ let uart_enabled = self . usart . cr1 . read ( ) . ue ( ) . bit ( ) ;
836
+ self . usart . cr1 . modify ( |_ , w| w . ue ( ) . disabled ( ) ) ;
837
+ self . usart . cr3 . modify ( |_ , w| w . ovrdis ( ) . bit ( !enable ) ) ;
838
+ self . usart . cr1 . modify ( |_ , w| w . ue ( ) . bit ( uart_enabled ) ) ;
839
839
}
840
840
841
841
/// Configuring the UART to match each received character,
0 commit comments