Skip to content

Commit 69f390e

Browse files
committed
fix(build): Update APB frequency set routine
1 parent 72a582b commit 69f390e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cores/esp32/esp32-hal-cpu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "soc/efuse_reg.h"
2727
#include "esp32-hal.h"
2828
#include "esp32-hal-cpu.h"
29+
#include "hal/timer_ll.h"
30+
#include "esp_private/systimer.h"
2931

3032
#include "esp_system.h"
3133
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
@@ -173,7 +175,9 @@ static uint32_t calculateApb(rtc_cpu_freq_config_t *conf) {
173175
#endif
174176
}
175177

178+
#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(LACT_MODULE) && !defined(LACT_TICKS_PER_US)
176179
void esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us); //private in IDF
180+
#endif
177181

178182
bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
179183
rtc_cpu_freq_config_t conf, cconf;
@@ -246,7 +250,13 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
246250
//Update APB Freq REG
247251
rtc_clk_apb_freq_update(apb);
248252
//Update esp_timer divisor
253+
#if CONFIG_IDF_TARGET_ESP32
254+
#if defined(LACT_MODULE) && defined(LACT_TICKS_PER_US)
255+
timer_ll_set_lact_clock_prescale(TIMER_LL_GET_HW(LACT_MODULE), apb / MHZ / LACT_TICKS_PER_US);
256+
#else
249257
esp_timer_impl_update_apb_freq(apb / MHZ);
258+
#endif
259+
#endif
250260
}
251261
#endif
252262
//Update FreeRTOS Tick Divisor

0 commit comments

Comments
 (0)