feat(esp_timer): Updates systimer and esp_timer

This commit is contained in:
Konstantin Kondrashov 2024-09-10 14:49:55 +03:00 committed by BOT
parent 00991f1bf5
commit 3081a4ea49
10 changed files with 15 additions and 42 deletions

View File

@ -15,36 +15,12 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "freertos/semphr.h" #include "freertos/semphr.h"
#include "esp_ipc.h"
#include "esp_timer.h" #include "esp_timer.h"
#include "esp_timer_impl.h" #include "esp_timer_impl.h"
#include "esp_compiler.h" #include "esp_compiler.h"
#include "esp_private/startup_internal.h" #include "esp_private/startup_internal.h"
#include "esp_private/esp_timer_private.h" #include "esp_private/esp_timer_private.h"
#include "esp_private/system_internal.h" #include "esp_private/system_internal.h"
//TODO: IDF-9526, refactor this
#if CONFIG_IDF_TARGET_ESP32
#include "esp32/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S3
#include "esp32s3/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32C2
#include "esp32c2/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32C6
#include "esp32c6/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32C61
#include "esp32c61/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32H2
#include "esp32h2/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32P4
#include "esp32p4/rtc.h"
#endif
#include "sdkconfig.h" #include "sdkconfig.h"
#ifdef CONFIG_ESP_TIMER_PROFILING #ifdef CONFIG_ESP_TIMER_PROFILING

View File

@ -388,7 +388,6 @@ TEST_CASE("esp_timer for very short intervals", "[esp_timer]")
vTaskDelay(3); // wait for the esp_timer task to delete all timers vTaskDelay(3); // wait for the esp_timer task to delete all timers
} }
#if !CONFIG_IDF_TARGET_ESP32C61 // TODO: IDF-10955, test fail
static void IRAM_ATTR test_esp_timer_get_time_performance(void) static void IRAM_ATTR test_esp_timer_get_time_performance(void)
{ {
int64_t begin = esp_timer_get_time(); int64_t begin = esp_timer_get_time();
@ -405,7 +404,6 @@ TEST_CASE("esp_timer_get_time call takes less than 1us", "[esp_timer]")
{ {
test_esp_timer_get_time_performance(); test_esp_timer_get_time_performance();
} }
#endif
static int64_t IRAM_ATTR __attribute__((noinline)) get_clock_diff(void) static int64_t IRAM_ATTR __attribute__((noinline)) get_clock_diff(void)
{ {

View File

@ -12,8 +12,6 @@
#include "soc/pcr_struct.h" #include "soc/pcr_struct.h"
#include "hal/assert.h" #include "hal/assert.h"
// TODO: [ESP32C61] IDF-9307, inherit from C6
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define IDF_PERFORMANCE_MAX_ESP_TIMER_GET_TIME_PER_CALL 1200 #define IDF_PERFORMANCE_MAX_ESP_TIMER_GET_TIME_PER_CALL 1300

View File

@ -37,7 +37,7 @@
#define SOC_GPSPI_SUPPORTED 1 #define SOC_GPSPI_SUPPORTED 1
#define SOC_I2C_SUPPORTED 1 #define SOC_I2C_SUPPORTED 1
#define SOC_LEDC_SUPPORTED 1 #define SOC_LEDC_SUPPORTED 1
#define SOC_SYSTIMER_SUPPORTED 1 //TODO: [ESP32C61] IDF-9307, IDF-9308 #define SOC_SYSTIMER_SUPPORTED 1
// \#define SOC_SUPPORT_COEXISTENCE 1 // \#define SOC_SUPPORT_COEXISTENCE 1
// \#define SOC_SHA_SUPPORTED 1 //TODO: [ESP32C61] IDF-9234 // \#define SOC_SHA_SUPPORTED 1 //TODO: [ESP32C61] IDF-9234
#define SOC_ECC_SUPPORTED 1 #define SOC_ECC_SUPPORTED 1

View File

@ -5,7 +5,7 @@ ESP Timer (High Resolution Timer)
{IDF_TARGET_HR_TIMER:default = "SYSTIMER", esp32 = "LAC timer"} {IDF_TARGET_HR_TIMER:default = "SYSTIMER", esp32 = "LAC timer"}
{IDF_TARGET_HR_TIMER_Resolution:default = "Not updated", esp32 = "64", esp32s2 = "64", esp32c3 = "52", esp32s3 = "52", esp32c2 = "52", esp32c5 = "52", esp32c6 = "52", esp32h2 = "52", esp32p4 = "52"} {IDF_TARGET_HR_TIMER_Resolution:default = "52", esp32 = "64", esp32s2 = "64"}
.. only:: html .. only:: html

View File

@ -5,7 +5,7 @@ ESP 定时器(高分辨率定时器)
{IDF_TARGET_HR_TIMER:default = "SYSTIMER", esp32 = "LAC 定时器"} {IDF_TARGET_HR_TIMER:default = "SYSTIMER", esp32 = "LAC 定时器"}
{IDF_TARGET_HR_TIMER_Resolution:default = "未更新", esp32 = "64", esp32s2 = "64", esp32c3 = "52", esp32s3 = "52", esp32c2 = "52", esp32c5 = "52", esp32c6 = "52", esp32h2 = "52", esp32p4 = "52"} {IDF_TARGET_HR_TIMER_Resolution:default = "52", esp32 = "64", esp32s2 = "64"}
.. only:: html .. only:: html

View File

@ -51,8 +51,6 @@ examples/system/efuse:
- bootloader_support - bootloader_support
examples/system/esp_timer: examples/system/esp_timer:
disable:
- if: SOC_LIGHT_SLEEP_SUPPORTED != 1
depends_components: depends_components:
- esp_timer - esp_timer

View File

@ -58,6 +58,7 @@ void app_main(void)
usleep(2000000); usleep(2000000);
} }
#if SOC_LIGHT_SLEEP_SUPPORTED
/* Timekeeping continues in light sleep, and timers are scheduled /* Timekeeping continues in light sleep, and timers are scheduled
* correctly after light sleep. * correctly after light sleep.
*/ */
@ -71,6 +72,7 @@ void app_main(void)
ESP_LOGI(TAG, "Woke up from light sleep, time since boot: %lld us", t2); ESP_LOGI(TAG, "Woke up from light sleep, time since boot: %lld us", t2);
assert(llabs((t2 - t1) - 500000) < 1200); assert(llabs((t2 - t1) - 500000) < 1200);
#endif
/* Let the timer run for a little bit more */ /* Let the timer run for a little bit more */
usleep(2000000); usleep(2000000);

View File

@ -71,16 +71,17 @@ def test_esp_timer(dut: Dut) -> None:
logging.info('Callback #{}, time: {} us, diff: {} us'.format(i, cur_time, diff)) logging.info('Callback #{}, time: {} us, diff: {} us'.format(i, cur_time, diff))
assert abs(diff) < 100 assert abs(diff) < 100
match = dut.expect(LIGHT_SLEEP_ENTER_REGEX, timeout=2) if dut.app.sdkconfig.get('SOC_LIGHT_SLEEP_SUPPORTED'):
sleep_enter_time = int(match.group(1)) match = dut.expect(LIGHT_SLEEP_ENTER_REGEX, timeout=2)
match = dut.expect(LIGHT_SLEEP_EXIT_REGEX, timeout=2) sleep_enter_time = int(match.group(1))
sleep_exit_time = int(match.group(1)) match = dut.expect(LIGHT_SLEEP_EXIT_REGEX, timeout=2)
sleep_time = sleep_exit_time - sleep_enter_time sleep_exit_time = int(match.group(1))
sleep_time = sleep_exit_time - sleep_enter_time
logging.info('Enter sleep: {}, exit sleep: {}, slept: {}'.format( logging.info('Enter sleep: {}, exit sleep: {}, slept: {}'.format(
sleep_enter_time, sleep_exit_time, sleep_time)) sleep_enter_time, sleep_exit_time, sleep_time))
assert abs(sleep_time - LIGHT_SLEEP_TIME) < 1200 assert abs(sleep_time - LIGHT_SLEEP_TIME) < 1200
for i in range(5, 7): for i in range(5, 7):
match = dut.expect(PERIODIC_TIMER_REGEX, timeout=2) match = dut.expect(PERIODIC_TIMER_REGEX, timeout=2)