Skip to content

Commit b722a2b

Browse files
committed
espressif: pwmout: get rid of not_first_reset special case
1 parent fae6d47 commit b722a2b

File tree

1 file changed

+2
-4
lines changed
  • ports/espressif/common-hal/pwmio

1 file changed

+2
-4
lines changed

ports/espressif/common-hal/pwmio/PWMOut.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@
3232

3333
#define INDEX_EMPTY 0xFF
3434

35-
STATIC bool not_first_reset = false;
3635
STATIC uint32_t reserved_timer_freq[LEDC_TIMER_MAX];
3736
STATIC bool varfreq_timers[LEDC_TIMER_MAX];
38-
STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX];
37+
STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX] = { [0 ... LEDC_CHANNEL_MAX - 1] = INDEX_EMPTY};
3938
STATIC bool never_reset_tim[LEDC_TIMER_MAX];
4039
STATIC bool never_reset_chan[LEDC_CHANNEL_MAX];
4140

@@ -56,7 +55,7 @@ STATIC uint32_t calculate_duty_cycle(uint32_t frequency) {
5655

5756
void pwmout_reset(void) {
5857
for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++) {
59-
if (reserved_channels[i] != INDEX_EMPTY && not_first_reset) {
58+
if (reserved_channels[i] != INDEX_EMPTY) {
6059
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
6160
}
6261
if (!never_reset_chan[i]) {
@@ -72,7 +71,6 @@ void pwmout_reset(void) {
7271
varfreq_timers[i] = false;
7372
}
7473
}
75-
not_first_reset = true;
7674
}
7775

7876
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,

0 commit comments

Comments
 (0)