Don't disable tempoarily in deinit().
This commit is contained in:
parent
91a88cf568
commit
ca737e6f7c
|
@ -196,19 +196,20 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||||
|
|
||||||
nrf_gpio_cfg_default(self->pin_number);
|
nrf_gpio_cfg_default(self->pin_number);
|
||||||
|
|
||||||
nrf_pwm_disable(self->pwm);
|
NRF_PWM_Type* pwm = self->pwm;
|
||||||
|
self->pwm = NULL;
|
||||||
|
|
||||||
self->pwm->PSEL.OUT[self->channel] = 0xFFFFFFFF;
|
// Disconnect pin from channel.
|
||||||
|
pwm->PSEL.OUT[self->channel] = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Re-enable PWM module if there is another active channel.
|
|
||||||
for(int i=0; i < CHANNELS_PER_PWM; i++) {
|
for(int i=0; i < CHANNELS_PER_PWM; i++) {
|
||||||
if (self->pwm->PSEL.OUT[i] != 0xFFFFFFFF) {
|
if (self->pwm->PSEL.OUT[i] != 0xFFFFFFFF) {
|
||||||
nrf_pwm_enable(self->pwm);
|
// Some channel is still being used, so don't disable.
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self->pwm = NULL;
|
nrf_pwm_disable(pwm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty_cycle) {
|
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty_cycle) {
|
||||||
|
|
Loading…
Reference in New Issue