From b722a2bca1af2a17b6eeacfe98ee8144077c02e9 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 6 Dec 2021 09:52:55 -0600 Subject: [PATCH] espressif: pwmout: get rid of not_first_reset special case --- ports/espressif/common-hal/pwmio/PWMOut.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ports/espressif/common-hal/pwmio/PWMOut.c b/ports/espressif/common-hal/pwmio/PWMOut.c index 71cf5c19d0..9ca39c223b 100644 --- a/ports/espressif/common-hal/pwmio/PWMOut.c +++ b/ports/espressif/common-hal/pwmio/PWMOut.c @@ -32,10 +32,9 @@ #define INDEX_EMPTY 0xFF -STATIC bool not_first_reset = false; STATIC uint32_t reserved_timer_freq[LEDC_TIMER_MAX]; STATIC bool varfreq_timers[LEDC_TIMER_MAX]; -STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX]; +STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX] = { [0 ... LEDC_CHANNEL_MAX - 1] = INDEX_EMPTY}; STATIC bool never_reset_tim[LEDC_TIMER_MAX]; STATIC bool never_reset_chan[LEDC_CHANNEL_MAX]; @@ -56,7 +55,7 @@ STATIC uint32_t calculate_duty_cycle(uint32_t frequency) { void pwmout_reset(void) { for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++) { - if (reserved_channels[i] != INDEX_EMPTY && not_first_reset) { + if (reserved_channels[i] != INDEX_EMPTY) { ledc_stop(LEDC_LOW_SPEED_MODE, i, 0); } if (!never_reset_chan[i]) { @@ -72,7 +71,6 @@ void pwmout_reset(void) { varfreq_timers[i] = false; } } - not_first_reset = true; } pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,