File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
ports/nrf/common-hal/pulseio Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -196,19 +196,20 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
196
196
197
197
nrf_gpio_cfg_default (self -> pin_number );
198
198
199
- nrf_pwm_disable (self -> pwm );
199
+ NRF_PWM_Type * pwm = self -> pwm ;
200
+ self -> pwm = NULL ;
200
201
201
- self -> pwm -> PSEL .OUT [self -> channel ] = 0xFFFFFFFF ;
202
+ // Disconnect pin from channel.
203
+ pwm -> PSEL .OUT [self -> channel ] = 0xFFFFFFFF ;
202
204
203
- // Re-enable PWM module if there is another active channel.
204
205
for (int i = 0 ; i < CHANNELS_PER_PWM ; i ++ ) {
205
206
if (self -> pwm -> PSEL .OUT [i ] != 0xFFFFFFFF ) {
206
- nrf_pwm_enable ( self -> pwm );
207
- break ;
207
+ // Some channel is still being used, so don't disable.
208
+ return ;
208
209
}
209
210
}
210
211
211
- self -> pwm = NULL ;
212
+ nrf_pwm_disable ( pwm ) ;
212
213
}
213
214
214
215
void common_hal_pulseio_pwmout_set_duty_cycle (pulseio_pwmout_obj_t * self , uint16_t duty_cycle ) {
You can’t perform that action at this time.
0 commit comments