mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
fix(esp_hw_support): update systimer step immediately when XTAL changes on esp32s2
This commit is contained in:
@ -20,6 +20,10 @@
|
|||||||
#include "esp_hw_log.h"
|
#include "esp_hw_log.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "hal/clk_tree_ll.h"
|
#include "hal/clk_tree_ll.h"
|
||||||
|
#ifndef BOOTLOADER_BUILD
|
||||||
|
#include "esp_private/systimer.h"
|
||||||
|
#include "hal/systimer_ll.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char *TAG = "rtc_clk";
|
static const char *TAG = "rtc_clk";
|
||||||
|
|
||||||
@ -454,6 +458,9 @@ static void rtc_clk_cpu_freq_to_xtal(int cpu_freq, int div)
|
|||||||
/* no need to adjust the REF_TICK, default register value already set it to 1MHz with any cpu clock source */
|
/* no need to adjust the REF_TICK, default register value already set it to 1MHz with any cpu clock source */
|
||||||
/* switch clock source */
|
/* switch clock source */
|
||||||
clk_ll_cpu_set_src(SOC_CPU_CLK_SRC_XTAL);
|
clk_ll_cpu_set_src(SOC_CPU_CLK_SRC_XTAL);
|
||||||
|
#ifndef BOOTLOADER_BUILD
|
||||||
|
systimer_ll_set_step_for_xtal(&SYSTIMER, systimer_us_to_ticks(1) / cpu_freq);
|
||||||
|
#endif
|
||||||
rtc_clk_apb_freq_update(cpu_freq * MHZ);
|
rtc_clk_apb_freq_update(cpu_freq * MHZ);
|
||||||
|
|
||||||
/* lower the voltage
|
/* lower the voltage
|
||||||
|
@ -567,15 +567,6 @@ void IRAM_ATTR esp_pm_impl_switch_mode(pm_mode_t mode,
|
|||||||
*/
|
*/
|
||||||
static void IRAM_ATTR on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_per_us)
|
static void IRAM_ATTR on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_per_us)
|
||||||
{
|
{
|
||||||
#if !CONFIG_IDF_TARGET_ESP32
|
|
||||||
uint32_t old_apb_ticks_per_us = MIN(old_ticks_per_us, 80);
|
|
||||||
uint32_t apb_ticks_per_us = MIN(ticks_per_us, 80);
|
|
||||||
/* Update APB frequency value used by the timer */
|
|
||||||
if (old_apb_ticks_per_us != apb_ticks_per_us) {
|
|
||||||
esp_timer_private_update_apb_freq(apb_ticks_per_us);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
|
#ifdef CONFIG_FREERTOS_SYSTICK_USES_CCOUNT
|
||||||
#ifdef XT_RTOS_TIMER_INT
|
#ifdef XT_RTOS_TIMER_INT
|
||||||
/* Calculate new tick divisor */
|
/* Calculate new tick divisor */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -24,16 +24,6 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Notify esp_timer implementation that APB frequency has changed
|
|
||||||
*
|
|
||||||
* Called by the frequency switching code.
|
|
||||||
*
|
|
||||||
* @param apb_ticks_per_us new number of APB clock ticks per microsecond
|
|
||||||
*/
|
|
||||||
void esp_timer_private_update_apb_freq(uint32_t apb_ticks_per_us);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set esp_timer time to a certain value
|
* @brief Set esp_timer time to a certain value
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -69,15 +69,6 @@ void esp_timer_impl_set_alarm(uint64_t timestamp);
|
|||||||
*/
|
*/
|
||||||
void esp_timer_impl_set_alarm_id(uint64_t timestamp, unsigned alarm_id);
|
void esp_timer_impl_set_alarm_id(uint64_t timestamp, unsigned alarm_id);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Notify esp_timer implementation that APB frequency has changed
|
|
||||||
*
|
|
||||||
* Called by the frequency switching code.
|
|
||||||
*
|
|
||||||
* @param apb_ticks_per_us new number of APB clock ticks per microsecond
|
|
||||||
*/
|
|
||||||
void esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adjust current esp_timer time by a certain value
|
* @brief Adjust current esp_timer time by a certain value
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -129,13 +129,6 @@ static void IRAM_ATTR timer_alarm_isr(void *arg)
|
|||||||
#endif // ISR_HANDLERS != 1
|
#endif // ISR_HANDLERS != 1
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRAM_ATTR esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us)
|
|
||||||
{
|
|
||||||
#if !SOC_SYSTIMER_FIXED_DIVIDER
|
|
||||||
systimer_hal_on_apb_freq_update(&systimer_hal, apb_ticks_per_us);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void esp_timer_impl_set(uint64_t new_us)
|
void esp_timer_impl_set(uint64_t new_us)
|
||||||
{
|
{
|
||||||
portENTER_CRITICAL_SAFE(&s_time_update_lock);
|
portENTER_CRITICAL_SAFE(&s_time_update_lock);
|
||||||
@ -249,6 +242,5 @@ uint64_t esp_timer_impl_get_alarm_reg(void)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_timer_private_update_apb_freq(uint32_t apb_ticks_per_us) __attribute__((alias("esp_timer_impl_update_apb_freq")));
|
|
||||||
void esp_timer_private_set(uint64_t new_us) __attribute__((alias("esp_timer_impl_set")));
|
void esp_timer_private_set(uint64_t new_us) __attribute__((alias("esp_timer_impl_set")));
|
||||||
void esp_timer_private_advance(int64_t time_diff_us) __attribute__((alias("esp_timer_impl_advance")));
|
void esp_timer_private_advance(int64_t time_diff_us) __attribute__((alias("esp_timer_impl_advance")));
|
||||||
|
Reference in New Issue
Block a user