2021-11-06 17:24:45 +08:00
|
|
|
/*
|
2022-01-18 10:32:56 +08:00
|
|
|
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
2021-11-06 17:24:45 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-06-23 16:46:06 +08:00
|
|
|
|
|
|
|
#include "esp_system.h"
|
|
|
|
#include "esp_attr.h"
|
|
|
|
|
2020-07-14 14:46:13 +08:00
|
|
|
#include "soc/rtc.h"
|
2020-06-23 16:46:06 +08:00
|
|
|
|
2020-08-24 11:33:57 +08:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
|
2020-07-14 14:46:13 +08:00
|
|
|
#include "sdkconfig.h"
|
2020-06-23 16:46:06 +08:00
|
|
|
|
2024-03-14 16:27:29 +08:00
|
|
|
//TODO: IDF-9526, refactor this
|
2020-07-14 14:46:13 +08:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32
|
|
|
|
#include "esp32/rtc.h"
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
|
|
#include "esp32s2/rtc.h"
|
2020-07-29 13:13:51 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
|
|
|
#include "esp32s3/rtc.h"
|
2020-11-26 19:56:13 +11:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
|
|
|
#include "esp32c3/rtc.h"
|
2022-01-18 10:32:56 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C2
|
|
|
|
#include "esp32c2/rtc.h"
|
2022-07-12 20:42:28 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C6
|
|
|
|
#include "esp32c6/rtc.h"
|
2024-03-14 16:27:29 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C61
|
|
|
|
#include "esp32c61/rtc.h"
|
2022-12-06 13:46:03 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32H2
|
|
|
|
#include "esp32h2/rtc.h"
|
2023-07-21 12:36:57 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
|
|
|
#include "esp32p4/rtc.h"
|
2024-01-02 11:16:55 +08:00
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
|
|
#include "esp32c5/rtc.h"
|
2020-07-14 14:46:13 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "esp_private/startup_internal.h"
|
2020-06-23 16:46:06 +08:00
|
|
|
|
2020-07-14 14:46:13 +08:00
|
|
|
// A component in the build should provide strong implementations that make use of
|
|
|
|
// and actual hardware timer to provide timekeeping functions.
|
|
|
|
int64_t IRAM_ATTR __attribute__((weak)) esp_system_get_time(void)
|
2020-06-23 16:46:06 +08:00
|
|
|
{
|
2020-07-14 14:46:13 +08:00
|
|
|
int64_t t = 0;
|
2020-08-24 11:33:57 +08:00
|
|
|
t = (esp_rtc_get_time_us() - g_startup_time);
|
2020-07-14 14:46:13 +08:00
|
|
|
return t;
|
2020-06-23 16:46:06 +08:00
|
|
|
}
|
|
|
|
|
2020-07-14 14:46:13 +08:00
|
|
|
uint32_t IRAM_ATTR __attribute__((weak)) esp_system_get_time_resolution(void)
|
2020-06-23 16:46:06 +08:00
|
|
|
{
|
2020-10-07 17:39:11 +08:00
|
|
|
return 1000000000L / rtc_clk_slow_freq_get_hz();
|
2020-11-10 18:40:01 +11:00
|
|
|
}
|