change(esp_hw_support): add interface to calculate slow clock period by clock frequency

This commit is contained in:
Li Shuai
2025-04-01 19:16:17 +08:00
committed by sibeibei
parent 28290c8da3
commit 059c50e8c8
24 changed files with 120 additions and 0 deletions

View File

@@ -476,6 +476,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
/**
* @brief sleep configuration for rtc_sleep_init function
*/

View File

@@ -191,6 +191,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -503,6 +503,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
/**
* @brief Power down flags for rtc_sleep_pd function
*/

View File

@@ -191,6 +191,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -531,6 +531,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
/**
* @brief Power down flags for rtc_sleep_pd function
*/

View File

@@ -194,6 +194,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -411,6 +411,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
#ifdef __cplusplus
}
#endif

View File

@@ -196,6 +196,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -442,6 +442,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
// -------------------------- CLOCK TREE DEFS ALIAS ----------------------------
// **WARNING**: The following are only for backwards compatibility.

View File

@@ -271,6 +271,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -411,6 +411,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
#ifdef __cplusplus
}
#endif

View File

@@ -196,6 +196,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -440,6 +440,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
// -------------------------- CLOCK TREE DEFS ALIAS ----------------------------
// **WARNING**: The following are only for backwards compatibility.
// Please use the declarations in soc/clk_tree_defs.h instead.

View File

@@ -271,6 +271,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -439,6 +439,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
// -------------------------- CLOCK TREE DEFS ALIAS ----------------------------
// **WARNING**: The following are only for backwards compatibility.
// Please use the declarations in soc/clk_tree_defs.h instead.

View File

@@ -274,6 +274,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -443,6 +443,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
#ifdef __cplusplus
}
#endif

View File

@@ -262,6 +262,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -460,6 +460,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
/**
* @brief Enable or disable APLL
*

View File

@@ -222,6 +222,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -564,6 +564,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
/**
* @brief Power down flags for rtc_sleep_pd function
*/

View File

@@ -259,6 +259,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)

View File

@@ -542,6 +542,14 @@ bool rtc_dig_8m_enabled(void);
*/
uint32_t rtc_clk_freq_cal(uint32_t cal_val);
/**
* @brief Calculate the slow clock period value by slow clock frequency
*
* @param freq_hz Frequency of the slow clock in Hz
* @return Fixed point value of slow clock period in microseconds
*/
uint32_t rtc_clk_freq_to_period(uint32_t freq_hz);
/**
* @brief Power up flags for rtc_sleep_pd function
*/

View File

@@ -193,6 +193,8 @@ uint32_t rtc_clk_freq_cal(uint32_t cal_val)
return 1000000ULL * (1 << RTC_CLK_CAL_FRACT) / cal_val;
}
uint32_t rtc_clk_freq_to_period(uint32_t) __attribute__((alias("rtc_clk_freq_cal")));
/// @brief if the calibration is used, we need to enable the timer group0 first
__attribute__((constructor))
static void enable_timer_group0_for_calibration(void)