Merge branch 'bugfix/fix_rtc8m_calibration_fail_after_cpu_core_reset_v4.2' into 'release/v4.2'

rtc_clk: Fix rtc8m calibration failure after cpu/core reset (backport v4.2)

See merge request espressif/esp-idf!20555
This commit is contained in:
morris 2022-10-14 14:06:52 +08:00
commit 6e42e604b2
2 changed files with 8 additions and 0 deletions

View File

@ -49,7 +49,10 @@ static uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cyc
REG_SET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_XTAL32K_EN, 1);
}
bool clk8m_enabled = rtc_clk_8m_enabled();
bool clk8md256_enabled = rtc_clk_8md256_enabled();
if (cal_clk == RTC_CAL_8MD256) {
rtc_clk_8m_enable(true, true);
SET_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_D256_EN);
}
/* Prepare calibration */
@ -100,6 +103,7 @@ static uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cyc
if (cal_clk == RTC_CAL_8MD256) {
CLEAR_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_D256_EN);
rtc_clk_8m_enable(clk8m_enabled, clk8md256_enabled);
}
if (timeout_us == 0) {
/* timed out waiting for calibration */

View File

@ -57,7 +57,10 @@ uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles)
REG_SET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_XTAL32K_EN, 1);
}
bool clk8m_enabled = rtc_clk_8m_enabled();
bool clk8md256_enabled = rtc_clk_8md256_enabled();
if (cal_clk == RTC_CAL_8MD256) {
rtc_clk_8m_enable(true, true);
SET_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_D256_EN);
}
/* There may be another calibration process already running during we call this function,
@ -115,6 +118,7 @@ uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles)
if (cal_clk == RTC_CAL_8MD256) {
CLEAR_PERI_REG_MASK(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_DIG_CLK8M_D256_EN);
rtc_clk_8m_enable(clk8m_enabled, clk8md256_enabled);
}
return cal_val;