esp_system: link time, not runtime, dependency on esp_timer

This commit is contained in:
Renz Bagaporo
2020-07-14 14:46:13 +08:00
parent 346cf4430d
commit da88671491
12 changed files with 73 additions and 103 deletions

View File

@@ -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