@@ -107,9 +107,18 @@ macro_rules! pwm_hal {
107
107
}
108
108
) +
109
109
} ;
110
+ }
110
111
111
- ( $( $TIMX: ident:
112
- ( $CH: ty, $ccxe: ident, $ccmrx_output: ident, $ocxpe: ident, $ocxm: ident, $ccrx: ident $( , $moe: ident) * ) , ) +
112
+ macro_rules! pwm_advanced_hal {
113
+ ( $( $TIMX: ident: (
114
+ $CH: ty,
115
+ $ccxe: ident $( : $ccxne: ident) * ,
116
+ $ccmrx_output: ident,
117
+ $ocxpe: ident,
118
+ $ocxm: ident,
119
+ $ccrx: ident
120
+ $( , $moe: ident) *
121
+ ) , ) +
113
122
) => {
114
123
$(
115
124
impl hal:: PwmPin for PwmPin <$TIMX, $CH> {
@@ -126,6 +135,9 @@ macro_rules! pwm_hal {
126
135
let tim = & * $TIMX:: ptr( ) ;
127
136
tim. $ccmrx_output( ) . modify( |_, w| w. $ocxpe( ) . set_bit( ) . $ocxm( ) . bits( 6 ) ) ;
128
137
tim. ccer. modify( |_, w| w. $ccxe( ) . set_bit( ) ) ;
138
+ $(
139
+ tim. ccer. modify( |_, w| w. $ccxne( ) . bit( true ) ) ;
140
+ ) *
129
141
$(
130
142
tim. bdtr. modify( |_, w| w. $moe( ) . set_bit( ) ) ;
131
143
) *
@@ -148,14 +160,19 @@ macro_rules! pwm_hal {
148
160
} ;
149
161
}
150
162
151
- pwm_hal ! {
152
- TIM1 : ( Channel1 , cc1e, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
153
- TIM1 : ( Channel2 , cc2e, ccmr1_output, oc2pe, oc2m, ccr2, moe) ,
154
- TIM1 : ( Channel3 , cc3e, ccmr2_output, oc3pe, oc3m, ccr3, moe) ,
163
+ pwm_advanced_hal ! {
164
+ TIM1 : ( Channel1 , cc1e: cc1ne , ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
165
+ TIM1 : ( Channel2 , cc2e: cc2ne , ccmr1_output, oc2pe, oc2m, ccr2, moe) ,
166
+ TIM1 : ( Channel3 , cc3e: cc3ne , ccmr2_output, oc3pe, oc3m, ccr3, moe) ,
155
167
TIM1 : ( Channel4 , cc4e, ccmr2_output, oc4pe, oc4m, ccr4, moe) ,
156
168
TIM14 : ( Channel1 , cc1e, ccmr1_output, oc1pe, oc1m, ccr1) ,
157
- TIM16 : ( Channel1 , cc1e, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
158
- TIM17 : ( Channel1 , cc1e, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
169
+ TIM16 : ( Channel1 , cc1e: cc1ne, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
170
+ TIM17 : ( Channel1 , cc1e: cc1ne, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
171
+ }
172
+
173
+ #[ cfg( any( feature = "stm32g070" , feature = "stm32g071" , feature = "stm32g081" ) ) ]
174
+ pwm_advanced_hal ! {
175
+ TIM15 : ( Channel1 , cc1e: cc1ne, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
159
176
}
160
177
161
178
#[ cfg( feature = "stm32g0x1" ) ]
@@ -164,20 +181,12 @@ pwm_hal! {
164
181
TIM2 : ( Channel2 , cc2e, ccmr1_output, oc2pe, oc2m, ccr2, ccr2_l, ccr2_h) ,
165
182
TIM2 : ( Channel3 , cc3e, ccmr2_output, oc3pe, oc3m, ccr3, ccr3_l, ccr3_h) ,
166
183
TIM2 : ( Channel4 , cc4e, ccmr2_output, oc4pe, oc4m, ccr4, ccr4_l, ccr4_h) ,
167
- }
168
-
169
- pwm_hal ! {
170
184
TIM3 : ( Channel1 , cc1e, ccmr1_output, oc1pe, oc1m, ccr1, ccr1_l, ccr1_h) ,
171
185
TIM3 : ( Channel2 , cc2e, ccmr1_output, oc2pe, oc2m, ccr2, ccr2_l, ccr2_h) ,
172
186
TIM3 : ( Channel3 , cc3e, ccmr2_output, oc3pe, oc3m, ccr3, ccr3_l, ccr3_h) ,
173
187
TIM3 : ( Channel4 , cc4e, ccmr2_output, oc4pe, oc4m, ccr4, ccr4_l, ccr4_h) ,
174
188
}
175
189
176
- #[ cfg( any( feature = "stm32g070" , feature = "stm32g071" , feature = "stm32g081" ) ) ]
177
- pwm_hal ! {
178
- TIM15 : ( Channel1 , cc1e, ccmr1_output, oc1pe, oc1m, ccr1, moe) ,
179
- }
180
-
181
190
pwm ! {
182
191
TIM1 : ( apbenr2, apbrstr2, tim1, tim1en, tim1rst, arr) ,
183
192
TIM3 : ( apbenr1, apbrstr1, tim3, tim3en, tim3rst, arr_l, arr_h) ,
0 commit comments