mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 12:53:29 +00:00
esp_system: link time, not runtime, dependency on esp_timer
This commit is contained in:
@@ -24,10 +24,27 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "soc/spinlock.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_timer_impl.h"
|
||||
|
||||
#include "esp_private/startup_internal.h"
|
||||
#include "esp_private/esp_timer_private.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rtc.h"
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if defined( CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 ) || \
|
||||
defined( CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 ) || \
|
||||
defined( CONFIG_ESP32S2_TIME_SYSCALL_USE_FRC1 ) || \
|
||||
defined( CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC_FRC1 )
|
||||
#define WITH_FRC 1
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_TIMER_PROFILING
|
||||
#define WITH_PROFILING 1
|
||||
@@ -378,10 +395,11 @@ esp_err_t esp_timer_init(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = esp_timer_timekeeping_impl_init();
|
||||
if (err != ESP_OK) {
|
||||
goto out;
|
||||
}
|
||||
#if WITH_FRC
|
||||
// [refactor-todo] this logic, "esp_rtc_get_time_us() - g_startup_time", is also
|
||||
// the weak definition of esp_system_get_time; find a way to remove this duplication.
|
||||
esp_timer_private_advance(esp_rtc_get_time_us() - g_startup_time);
|
||||
#endif
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
@@ -508,4 +526,27 @@ int64_t IRAM_ATTR esp_timer_get_next_alarm(void)
|
||||
}
|
||||
timer_list_unlock();
|
||||
return next_alarm;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t IRAM_ATTR esp_timer_get_time(void)
|
||||
{
|
||||
if(is_initialized()) {
|
||||
return esp_timer_impl_get_time();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Provides strong definition for system time functions relied upon
|
||||
// by core components.
|
||||
#if WITH_FRC
|
||||
int64_t IRAM_ATTR esp_system_get_time(void)
|
||||
{
|
||||
return esp_timer_get_time();
|
||||
}
|
||||
|
||||
uint32_t IRAM_ATTR esp_system_get_time_resolution(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user