10000 esp32/machine_pwm: codeformat update. · micropython/micropython@a60f5bb · GitHub
[go: up one dir, main page]

Skip to content

Commit a60f5bb

Browse files
committed
esp32/machine_pwm: codeformat update.
codeformat passed. Signed-off-by: Yoann Darche <yoannd@hotmail.com>
1 parent e848554 commit a60f5bb

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

ports/esp32/machine_pwm.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ static ledc_timer_config_t timers[PWM_TIMER_MAX];
119119
enum { PWM_AUTO_CLK, PWM_APB_CLK, PWM_RC_FAST_CLK, PWM_REF_TICK, PWM_XTAL_CLK, PWM_PLL_CLK, _PWM_LAST_CLK_IDX };
120120
static const ledc_clk_cfg_t clk_source_map[] = {
121121
-2,
122+
#if SOC_LEDC_SUPPORT_APB_CLOCK
122123
LEDC_USE_APB_CLK,
124+
#else
125+
-1,
126+
#endif
123127
LEDC_USE_RC_FAST_CLK, // LEDC_USE_RC_FAST_CLK == LEDC_USE_RTC8M_CLK
124128
#if SOC_LEDC_SUPPORT_REF_TICK
125129
LEDC_USE_REF_TICK,
@@ -480,9 +484,13 @@ static int find_clock_in_use() {
480484

481485
if (found_clk == LEDC_AUTO_CLK) {
482486
return PWM_AUTO_CLK;
483-
} else if (found_clk == LEDC_USE_APB_CLK) {
487+
}
488+
#if SOC_LEDC_SUPPORT_APB_CLOCK
489+
else if (found_clk == LEDC_USE_APB_CLK) {
484490
return PWM_APB_CLK;
485-
} else if (found_clk == LEDC_USE_RC_FAST_CLK) {
491+
}
492+
#endif
493+
else if (found_clk == LEDC_USE_RC_FAST_CLK) {
486494
return PWM_RC_FAST_CLK;
487495
}
488496
#if SOC_LEDC_SUPPORT_REF_TICK
@@ -551,11 +559,14 @@ static void mp_machine_pwm_print(const mp_print_t *print, mp_obj_t self_in, mp_p
551559
mp_printf(print, ", mode=%d, channel=%d, timer=%d", self->mode, self->channel, self->timer);
552560

553561
int clk_src = timers[TIMER_IDX(self->mode, self->timer)].clk_cfg;
554-
if (clk_src == LEDC_USE_APB_CLK) {
555-
mp_printf(print, ", clock=PWM_APB_CLK(%d)", PWM_APB_CLK);
556-
} else if (clk_src == LEDC_USE_RC_FAST_CLK) {
562+
if (clk_src == LEDC_USE_RC_FAST_CLK) {
557563
mp_printf(print, ", clock=PWM_RC_FAST_CLK(%d)", PWM_RC_FAST_CLK);
558564
}
565+
#if SOC_LEDC_SUPPORT_APB_CLOCK
566+
else if (clk_src == LEDC_USE_APB_CLK) {
567+
mp_printf(print, ", clock=PWM_APB_CLK(%d)", PWM_APB_CLK);
568+
}
569+
#endif
559570
#if SOC_LEDC_SUPPORT_XTAL_CLOCK
560571
else if (clk_src == LEDC_USE_XTAL_CLK) {
561572
mp_printf(print, ", clock=PWM_XTAL_CLK(%d)", PWM_XTAL_CLK);
@@ -570,7 +581,7 @@ static void mp_machine_pwm_print(const mp_print_t *print, mp_obj_t self_in, mp_p
570581
else if (clk_src == LEDC_USE_PLL_DIV_CLK) {
571582
mp_printf(print, ", clock=PWM_PLL_CLK(%d)", PWM_PLL_CLK);
572583
}
573-
#endif
584+
#endif
574585
else {
575586
mp_printf(print, ", clock=UNKNOWN");
576587
}
@@ -645,18 +656,18 @@ static void mp_machine_pwm_init_helper(machine_pwm_obj_t *self,
645656
#endif
646657
}
647658
#else
648-
#if SOC_LEDC_SUPPORT_PLL_DIV_CLOCK
649-
pwm_src_clock = PWM_PLL_CLK;
650-
#endif
651-
#if SOC_LEDC_SUPPORT_APB_CLOCK
652-
pwm_src_clock = PWM_APB_CLK;
653-
#endif
659+
#if SOC_LEDC_SUPPORT_PLL_DIV_CLOCK
660+
pwm_src_clock = PWM_PLL_CLK;
661+
#endif
662+
#if SOC_LEDC_SUPPORT_APB_CLOCK
663+
pwm_src_clock = PWM_APB_CLK;
664+
#endif
654665

655-
#if SOC_LEDC_SUPPORT_REF_TICK
656-
if (freq < EMPIRIC_FREQ) {
657-
pwm_src_clock = PWM_REF_TICK; // 1 MHz
658-
}
659-
#endif
666+
#if SOC_LEDC_SUPPORT_REF_TICK
667+
if (freq < EMPIRIC_FREQ) {
668+
pwm_src_clock = PWM_REF_TICK; // 1 MHz
669+
}
670+
#endif
660671
#endif
661672
}
662673
#if !(PWM_SUPPORT_INDEP_CLOCK_SRC)

0 commit comments

Comments
 (0)
0