mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
esp_rom: add common ROM API to update CPU tick rate
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "esp_private/rtc_clk.h"
|
||||
@@ -215,14 +214,14 @@ static void rtc_clk_cpu_freq_to_pll_mhz(int cpu_freq_mhz)
|
||||
/* switch clock source */
|
||||
clk_ll_cpu_set_src(SOC_CPU_CLK_SRC_PLL);
|
||||
rtc_clk_apb_freq_update(80 * MHZ);
|
||||
ets_update_cpu_frequency(cpu_freq_mhz);
|
||||
esp_rom_set_cpu_ticks_per_us(cpu_freq_mhz);
|
||||
} else {
|
||||
clk_ll_cpu_set_freq_mhz_from_pll(cpu_freq_mhz);
|
||||
clk_ll_cpu_set_divider(1);
|
||||
/* switch clock source */
|
||||
clk_ll_cpu_set_src(SOC_CPU_CLK_SRC_PLL);
|
||||
rtc_clk_apb_freq_update(80 * MHZ);
|
||||
ets_update_cpu_frequency(cpu_freq_mhz);
|
||||
esp_rom_set_cpu_ticks_per_us(cpu_freq_mhz);
|
||||
REG_SET_FIELD(RTC_CNTL_DATE_REG, RTC_CNTL_SLAVE_PD, DEFAULT_LDO_SLAVE >> pd_slave);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +379,7 @@ void rtc_clk_cpu_freq_to_xtal(int cpu_freq, int div)
|
||||
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_RTC_DREG, g_rtc_dbias_pvt_non_240m);
|
||||
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_DIG_DREG, g_dig_dbias_pvt_non_240m);
|
||||
esp_rom_delay_us(40);
|
||||
ets_update_cpu_frequency(cpu_freq);
|
||||
esp_rom_set_cpu_ticks_per_us(cpu_freq);
|
||||
/* Set divider from XTAL to APB clock. Need to set divider to 1 (reg. value 0) first. */
|
||||
clk_ll_cpu_set_divider(1);
|
||||
clk_ll_cpu_set_divider(div);
|
||||
@@ -392,7 +391,7 @@ void rtc_clk_cpu_freq_to_xtal(int cpu_freq, int div)
|
||||
|
||||
static void rtc_clk_cpu_freq_to_8m(void)
|
||||
{
|
||||
ets_update_cpu_frequency(20);
|
||||
esp_rom_set_cpu_ticks_per_us(20);
|
||||
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_RTC_DREG, g_rtc_dbias_pvt_non_240m);
|
||||
REGI2C_WRITE_MASK(I2C_DIG_REG, I2C_DIG_REG_EXT_DIG_DREG, g_dig_dbias_pvt_non_240m);
|
||||
esp_rom_delay_us(40);
|
||||
|
Reference in New Issue
Block a user