Skip to content

Commit e372320

Browse files
committed
fix(esp32p4): Fix clock sources definitions
1 parent 149edfa commit e372320

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

cores/esp32/esp32-hal-cpu.c

+13-10
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,13 @@ bool removeApbChangeCallback(void *arg, apb_change_cb_t cb) {
163163
}
164164

165165
static uint32_t calculateApb(rtc_cpu_freq_config_t *conf) {
166-
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
167-
return APB_CLK_FREQ;
168-
#else
166+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
169167
if (conf->freq_mhz >= 80) {
170168
return 80 * MHZ;
171169
}
172170
return (conf->source_freq_mhz * MHZ) / conf->div;
171+
#else
172+
return APB_CLK_FREQ;
173173
#endif
174174
}
175175

@@ -250,11 +250,8 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
250250
}
251251
#endif
252252
//Update FreeRTOS Tick Divisor
253-
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
254253

255-
#elif CONFIG_IDF_TARGET_ESP32S3
256-
257-
#else
254+
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
258255
uint32_t fcpu = (conf.freq_mhz >= 80) ? (conf.freq_mhz * MHZ) : (apb);
259256
_xt_tick_divisor = fcpu / XT_TICK_PER_SEC;
260257
#endif
@@ -265,13 +262,19 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
265262
#ifdef SOC_CLK_APLL_SUPPORTED
266263
log_d(
267264
"%s: %u / %u = %u Mhz, APB: %u Hz",
268-
(conf.source == RTC_CPU_FREQ_SRC_PLL) ? "PLL"
269-
: ((conf.source == RTC_CPU_FREQ_SRC_APLL) ? "APLL" : ((conf.source == RTC_CPU_FREQ_SRC_XTAL) ? "XTAL" : "8M")),
265+
(conf.source == SOC_CPU_CLK_SRC_PLL) ? "PLL"
266+
: ((conf.source == SOC_CPU_CLK_SRC_APLL) ? "APLL"
267+
: ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL"
268+
#ifdef CONFIG_IDF_TARGET_ESP32P4
269+
: "17.5M"),
270+
#else
271+
: "8M")),
272+
#endif
270273
conf.source_freq_mhz, conf.div, conf.freq_mhz, apb
271274
);
272275
#else
273276
log_d(
274-
"%s: %u / %u = %u Mhz, APB: %u Hz", (conf.source == RTC_CPU_FREQ_SRC_PLL) ? "PLL" : ((conf.source == RTC_CPU_FREQ_SRC_XTAL) ? "XTAL" : "17.5M"),
277+
"%s: %u / %u = %u Mhz, APB: %u Hz", (conf.source == SOC_CPU_CLK_SRC_PLL) ? "PLL" : ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL" : "17.5M"),
275278
conf.source_freq_mhz, conf.div, conf.freq_mhz, apb
276279
);
277280
#endif

0 commit comments

Comments
 (0)