@@ -823,6 +823,49 @@ macro_rules! tim_hal {
823823 ) ?
824824 }
825825
826+ impl <F > PwmControl <$TIMX, F > {
827+ /// Start listening for `event`
828+ pub fn listen( & mut self , event: Event ) {
829+ match event {
830+ Event :: TimeOut => {
831+ let tim = unsafe { <$TIMX>:: steal( ) } ;
832+ // Enable update event interrupt
833+ tim. dier( ) . write( |w| w. uie( ) . set_bit( ) ) ;
834+ }
835+ }
836+ }
837+
838+ /// Stop listening for `event`
839+ pub fn unlisten( & mut self , event: Event ) {
840+ match event {
841+ Event :: TimeOut => {
842+ let tim = unsafe { <$TIMX>:: steal( ) } ;
843+ // Disable update event interrupt
844+ tim. dier( ) . write( |w| w. uie( ) . clear_bit( ) ) ;
845+ let _ = tim. dier( ) . read( ) ;
846+ let _ = tim. dier( ) . read( ) ; // Delay 2 peripheral clocks
847+ }
848+ }
849+ }
850+
851+ /// Check if Update Interrupt flag is cleared
852+ pub fn is_irq_clear( & mut self ) -> bool {
853+ let tim = unsafe { <$TIMX>:: steal( ) } ;
854+ tim. sr( ) . read( ) . uif( ) . bit_is_clear( )
855+ }
856+
857+ /// Clears interrupt flag
858+ pub fn clear_irq( & mut self ) {
859+ let tim = unsafe { <$TIMX>:: steal( ) } ;
860+ tim. sr( ) . modify( |_, w| {
861+ // Clears timeout event
862+ w. uif( ) . clear_bit( )
863+ } ) ;
864+ let _ = tim. sr( ) . read( ) ;
865+ let _ = tim. sr( ) . read( ) ; // Delay 2 peripheral clocks
866+ }
867+ }
868+
826869 // Timers with break/fault, dead time, and complimentary capabilities
827870 $(
828871 impl <PINS , CHANNEL , COMP > PwmBuilder <$TIMX, PINS , CHANNEL , FaultDisabled , COMP , $typ> {
@@ -842,49 +885,6 @@ macro_rules! tim_hal {
842885 }
843886 }
844887
845- impl <F > PwmControl <$TIMX, F > {
846- /// Start listening for `event`
847- pub fn listen( & mut self , event: Event ) {
848- match event {
849- Event :: TimeOut => {
850- let tim = unsafe { <$TIMX>:: steal( ) } ;
851- // Enable update event interrupt
852- tim. dier( ) . write( |w| w. uie( ) . set_bit( ) ) ;
853- }
854- }
855- }
856-
857- /// Stop listening for `event`
858- pub fn unlisten( & mut self , event: Event ) {
859- match event {
860- Event :: TimeOut => {
861- let tim = unsafe { <$TIMX>:: steal( ) } ;
862- // Disable update event interrupt
863- tim. dier( ) . write( |w| w. uie( ) . clear_bit( ) ) ;
864- let _ = tim. dier( ) . read( ) ;
865- let _ = tim. dier( ) . read( ) ; // Delay 2 peripheral clocks
866- }
867- }
868- }
869-
870- /// Check if Update Interrupt flag is cleared
871- pub fn is_irq_clear( & mut self ) -> bool {
872- let tim = unsafe { <$TIMX>:: steal( ) } ;
873- tim. sr( ) . read( ) . uif( ) . bit_is_clear( )
874- }
875-
876- /// Clears interrupt flag
877- pub fn clear_irq( & mut self ) {
878- let tim = unsafe { <$TIMX>:: steal( ) } ;
879- tim. sr( ) . modify( |_, w| {
880- // Clears timeout event
881- w. uif( ) . clear_bit( )
882- } ) ;
883- let _ = tim. sr( ) . read( ) ;
884- let _ = tim. sr( ) . read( ) ; // Delay 2 peripheral clocks
885- }
886- }
887-
888888 impl FaultMonitor for PwmControl <$TIMX, FaultEnabled > {
889889 fn is_fault_active( & self ) -> bool {
890890 let tim = unsafe { & * <$TIMX>:: ptr( ) } ;
0 commit comments