diff --git a/components/esp_hw_support/port/esp32h2/rtc_clk.c b/components/esp_hw_support/port/esp32h2/rtc_clk.c index 6102b32bb1..9c0c4abed5 100644 --- a/components/esp_hw_support/port/esp32h2/rtc_clk.c +++ b/components/esp_hw_support/port/esp32h2/rtc_clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -356,7 +356,7 @@ uint32_t rtc_clk_ahb_freq_get() rtc_cpu_freq_config_t cpu_config; uint32_t ahb_div = REG_GET_FIELD(SYSTEM_BUSCLK_CONF_REG, SYSTEM_AHB_DIV_NUM) + 1; rtc_clk_cpu_freq_get_config(&cpu_config) ; - return cpu_config.freq_mhz / ahb_div; + return cpu_config.freq_mhz * MHZ / ahb_div; } uint32_t rtc_clk_ahb_freq_set(uint32_t div) diff --git a/components/esp_hw_support/port/esp32h2/rtc_clk_init.c b/components/esp_hw_support/port/esp32h2/rtc_clk_init.c index ff7f67767a..77fa166ea9 100644 --- a/components/esp_hw_support/port/esp32h2/rtc_clk_init.c +++ b/components/esp_hw_support/port/esp32h2/rtc_clk_init.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -62,7 +62,7 @@ void rtc_clk_init(rtc_clk_config_t cfg) rtc_xtal_freq_t xtal_freq = cfg.xtal_freq; esp_rom_uart_tx_wait_idle(0); rtc_clk_xtal_freq_update(xtal_freq); - rtc_clk_apb_freq_update(rtc_clk_apb_freq_get() * MHZ); + rtc_clk_apb_freq_update(rtc_clk_apb_freq_get()); /* Set CPU frequency */ rtc_clk_cpu_freq_get_config(&old_config); diff --git a/components/soc/esp32h2/include/soc/rtc.h b/components/soc/esp32h2/include/soc/rtc.h index d04d815ae2..5bfaf03e37 100644 --- a/components/soc/esp32h2/include/soc/rtc.h +++ b/components/soc/esp32h2/include/soc/rtc.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -487,6 +487,11 @@ void rtc_clk_apb_freq_update(uint32_t apb_freq); uint32_t rtc_clk_apb_freq_get(void); void rtc_clk_cpu_freq_set(uint32_t source, uint32_t div); + +/** + * @brief Get the current stored AHB frequency. + * @return The AHB frequency value as last set via rtc_clk_ahb_freq_set(), in Hz. + */ uint32_t rtc_clk_ahb_freq_get(void);