File tree Expand file tree Collapse file tree
ports/nrf/common-hal/pulseio Expand file tree Collapse file tree 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) {
196196
197197 nrf_gpio_cfg_default (self -> pin_number );
198198
199- nrf_pwm_disable (self -> pwm );
199+ NRF_PWM_Type * pwm = self -> pwm ;
200+ self -> pwm = NULL ;
200201
201- self -> pwm -> PSEL .OUT [self -> channel ] = 0xFFFFFFFF ;
202+ // Disconnect pin from channel.
203+ pwm -> PSEL .OUT [self -> channel ] = 0xFFFFFFFF ;
202204
203- // Re-enable PWM module if there is another active channel.
204205 for (int i = 0 ; i < CHANNELS_PER_PWM ; i ++ ) {
205206 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 ;
208209 }
209210 }
210211
211- self -> pwm = NULL ;
212+ nrf_pwm_disable ( pwm ) ;
212213}
213214
214215void 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