@@ -75,6 +75,9 @@ pins_impl!(
75
75
( P2 ) , ( PinC2 ) , ( C2 ) ;
76
76
( P3 ) , ( PinC3 ) , ( C3 ) ;
77
77
( P4 ) , ( PinC4 ) , ( C4 ) ;
78
+ ( P1N ) , ( PinC1N ) , ( C1N ) ;
79
+ ( P2N ) , ( PinC2N ) , ( C2N ) ;
80
+ ( P3N ) , ( PinC3N ) , ( C3N ) ;
78
81
) ;
79
82
80
83
impl < TIM , P1 : PinC1 < TIM > , P2 : PinC1 < TIM > > PinC1 < TIM > for ( P1 , P2 ) { }
@@ -803,7 +806,7 @@ macro_rules! pwm_1_channel_with_complementary_outputs {
803
806
rcc. regs. $apbrstr. modify( |_, w| w. $timXrst( ) . set_bit( ) ) ;
804
807
rcc. regs. $apbrstr. modify( |_, w| w. $timXrst( ) . clear_bit( ) ) ;
805
808
806
- if PINS :: C1 {
809
+ if PINS :: C1 || PINS :: C1N {
807
810
tim. ccmr1_output( ) . modify( |_, w| w. oc1pe( ) . set_bit( ) . oc1m( ) . bits( 6 ) ) ;
808
811
}
809
812
@@ -868,6 +871,35 @@ macro_rules! pwm_1_channel_with_complementary_outputs {
868
871
unsafe { ( * $TIMX:: ptr( ) ) . ccr1. write( |w| w. ccr( ) . bits( duty. into( ) ) ) }
869
872
}
870
873
}
874
+
875
+ impl hal:: PwmPin for PwmChannels <$TIMX, C1N > {
876
+ type Duty = u16 ;
877
+
878
+ //NOTE(unsafe) atomic write with no side effects
879
+ fn disable( & mut self ) {
880
+ unsafe { ( * ( $TIMX:: ptr( ) ) ) . ccer. modify( |_, w| w. cc1ne( ) . clear_bit( ) ) } ;
881
+ }
882
+
883
+ //NOTE(unsafe) atomic write with no side effects
884
+ fn enable( & mut self ) {
885
+ unsafe { ( * ( $TIMX:: ptr( ) ) ) . ccer. modify( |_, w| w. cc1ne( ) . set_bit( ) ) } ;
886
+ }
887
+
888
+ //NOTE(unsafe) atomic read with no side effects
889
+ fn get_duty( & self ) -> u16 {
890
+ unsafe { ( * $TIMX:: ptr( ) ) . ccr1. read( ) . ccr( ) . bits( ) as u16 }
891
+ }
892
+
893
+ //NOTE(unsafe) atomic read with no side effects
894
+ fn get_max_duty( & self ) -> u16 {
895
+ unsafe { ( * $TIMX:: ptr( ) ) . arr. read( ) . arr( ) . bits( ) as u16 }
896
+ }
897
+
898
+ //NOTE(unsafe) atomic write with no side effects
899
+ fn set_duty( & mut self , duty: u16 ) {
900
+ unsafe { ( * $TIMX:: ptr( ) ) . ccr1. write( |w| w. ccr( ) . bits( duty. into( ) ) ) }
901
+ }
902
+ }
871
903
) +
872
904
} ;
873
905
}
0 commit comments