summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-10-09 21:23:47 -0400
committerDan Halbert <halbert@halwitz.org>2018-10-09 21:23:47 -0400
commitca737e6f7c6cd6ba3601230ac86bf9cce36f2da0 (patch)
tree03104440d902c7b81da7e62192d963f4a8ec7c36
parent91a88cf5685b88708cae501f4f7dbf0e8a4e6e17 (diff)
Don't disable tempoarily in deinit().
-rw-r--r--ports/nrf/common-hal/pulseio/PWMOut.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c
index 7b5741e35..5d94bab79 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.c
+++ b/ports/nrf/common-hal/pulseio/PWMOut.c
@@ -196,19 +196,20 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
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++) {
if (self->pwm->PSEL.OUT[i] != 0xFFFFFFFF) {
- nrf_pwm_enable(self->pwm);
- break;
+ // Some channel is still being used, so don't disable.
+ 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) {