esp_system: introduce system time functions
- Introduce system time function and concept of system time provider. esp_timer is system time provider when present. - Set the reference point for system time, g_startup_time. - Use the system time functions in newlib instead of calling esp_timer functions directly
This commit is contained in:
@@ -64,6 +64,10 @@ static __attribute__((used)) esp_system_init_fn_t _SECTION_ATTR_IMPL(".esp_syste
|
||||
static __attribute__((used)) __VA_ARGS__ void __esp_system_init_fn_##f(void) // [refactor-todo] this can be made public API if we allow components to declare init functions,
|
||||
// instead of calling them explicitly
|
||||
|
||||
extern uint64_t g_startup_time; // Startup time that serves as the point of origin for system time. Should be set by the entry
|
||||
// function in the port layer. May be 0 as well if this is not backed by a persistent counter, in which case
|
||||
// startup time = system time = 0 at the point the entry function sets this variable.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int64_t (*esp_system_time_fn_t)(void);
|
||||
|
||||
typedef enum {
|
||||
ESP_MAC_WIFI_STA,
|
||||
ESP_MAC_WIFI_SOFTAP,
|
||||
@@ -286,6 +288,20 @@ typedef struct {
|
||||
*/
|
||||
void esp_chip_info(esp_chip_info_t* out_info);
|
||||
|
||||
/**
|
||||
* @brief Get the time in microseconds since startup
|
||||
*
|
||||
* @returns time since startup in microseconds
|
||||
*/
|
||||
int64_t esp_system_get_time(void);
|
||||
|
||||
/**
|
||||
* @brief Get the resolution of the time returned by `esp_system_get_time`.
|
||||
*
|
||||
* @returns the resolution in microseconds
|
||||
*/
|
||||
uint32_t esp_system_get_time_resolution(void);
|
||||
|
||||
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
||||
/**
|
||||
* @brief Cache lock bug exists or not
|
||||
|
||||
Reference in New Issue
Block a user