From 5b12cd4a7603ddd17ce222df21fd189d513b6012 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 23 Apr 2021 10:28:42 +1000 Subject: [PATCH] esp_hw_support: Fix ESP32-C3/S3 APB frequency Regression in e6edf34e82c6d1d45ff808ae9eb052e03af9ca8f, APB frequency accidentally set at 81MHz not 80MHz. --- components/esp_hw_support/esp_clk.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/esp_hw_support/esp_clk.c b/components/esp_hw_support/esp_clk.c index 4342c95d05..fc9ca207d8 100644 --- a/components/esp_hw_support/esp_clk.c +++ b/components/esp_hw_support/esp_clk.c @@ -50,22 +50,23 @@ extern uint32_t g_ticks_per_us_app; static _lock_t s_esp_rtc_time_lock; static RTC_DATA_ATTR uint64_t s_esp_rtc_time_us = 0, s_rtc_last_ticks = 0; -int IRAM_ATTR esp_clk_cpu_freq(void) +inline static int IRAM_ATTR s_get_cpu_freq_mhz(void) { #if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 - return ets_get_cpu_frequency() * MHZ; + return ets_get_cpu_frequency(); #else - return g_ticks_per_us_pro * MHZ; + return g_ticks_per_us_pro; #endif } +int IRAM_ATTR esp_clk_cpu_freq(void) +{ + return s_get_cpu_freq_mhz() * MHZ; +} + int IRAM_ATTR esp_clk_apb_freq(void) { -#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 - return MIN(ets_get_cpu_frequency(), 81) * MHZ; -#else - return MIN(g_ticks_per_us_pro, 80) * MHZ; -#endif + return MIN(s_get_cpu_freq_mhz(), 80) * MHZ; } int IRAM_ATTR esp_clk_xtal_freq(void)