|
|
@@ -135,3 +135,20 @@ uint64_t rtc_time_get()
|
|
|
t |= ((uint64_t) READ_PERI_REG(RTC_CNTL_TIME1_REG)) << 32;
|
|
|
return t;
|
|
|
}
|
|
|
+
|
|
|
+void rtc_clk_wait_for_slow_cycle()
|
|
|
+{
|
|
|
+ REG_CLR_BIT(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_START_CYCLING | TIMG_RTC_CALI_START);
|
|
|
+ REG_CLR_BIT(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_RDY);
|
|
|
+ REG_SET_FIELD(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_CLK_SEL, RTC_CAL_RTC_MUX);
|
|
|
+ /* Request to run calibration for 0 slow clock cycles.
|
|
|
+ * RDY bit will be set on the nearest slow clock cycle.
|
|
|
+ */
|
|
|
+ REG_SET_FIELD(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_MAX, 0);
|
|
|
+ REG_SET_BIT(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_START);
|
|
|
+ ets_delay_us(1); /* RDY needs some time to go low */
|
|
|
+ while (!GET_PERI_REG_MASK(TIMG_RTCCALICFG_REG(0), TIMG_RTC_CALI_RDY)) {
|
|
|
+ ets_delay_us(1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|