1 /* 2 * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "esp_system.h" 8 #include "esp_attr.h" 9 10 #include "soc/rtc.h" 11 12 #include "freertos/FreeRTOS.h" 13 14 #include "sdkconfig.h" 15 16 #if CONFIG_IDF_TARGET_ESP32 17 #include "esp32/rtc.h" 18 #elif CONFIG_IDF_TARGET_ESP32S2 19 #include "esp32s2/rtc.h" 20 #elif CONFIG_IDF_TARGET_ESP32S3 21 #include "esp32s3/rtc.h" 22 #elif CONFIG_IDF_TARGET_ESP32C3 23 #include "esp32c3/rtc.h" 24 #elif CONFIG_IDF_TARGET_ESP32C2 25 #include "esp32c2/rtc.h" 26 #elif CONFIG_IDF_TARGET_ESP32C6 27 #include "esp32c6/rtc.h" 28 #elif CONFIG_IDF_TARGET_ESP32H2 29 #include "esp32h2/rtc.h" 30 #endif 31 32 #include "esp_private/startup_internal.h" 33 34 // A component in the build should provide strong implementations that make use of 35 // and actual hardware timer to provide timekeeping functions. esp_system_get_time(void)36int64_t IRAM_ATTR __attribute__((weak)) esp_system_get_time(void) 37 { 38 int64_t t = 0; 39 t = (esp_rtc_get_time_us() - g_startup_time); 40 return t; 41 } 42 esp_system_get_time_resolution(void)43uint32_t IRAM_ATTR __attribute__((weak)) esp_system_get_time_resolution(void) 44 { 45 return 1000000000L / rtc_clk_slow_freq_get_hz(); 46 } 47