From 3081a4ea49724afe7fbf1ee59b286dd1acb8f509 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Tue, 10 Sep 2024 14:49:55 +0300 Subject: [PATCH] feat(esp_timer): Updates systimer and esp_timer --- components/esp_timer/src/esp_timer.c | 24 ------------------- .../esp_timer/test_apps/main/test_esp_timer.c | 2 -- .../hal/esp32c61/include/hal/systimer_ll.h | 2 -- .../include/esp32c61/idf_performance_target.h | 2 +- .../soc/esp32c61/include/soc/soc_caps.h | 2 +- docs/en/api-reference/system/esp_timer.rst | 2 +- docs/zh_CN/api-reference/system/esp_timer.rst | 2 +- examples/system/.build-test-rules.yml | 2 -- .../esp_timer/main/esp_timer_example_main.c | 2 ++ examples/system/esp_timer/pytest_esp_timer.py | 17 ++++++------- 10 files changed, 15 insertions(+), 42 deletions(-) diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index 71698b335e..9e841ef808 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -15,36 +15,12 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" -#include "esp_ipc.h" #include "esp_timer.h" #include "esp_timer_impl.h" #include "esp_compiler.h" - #include "esp_private/startup_internal.h" #include "esp_private/esp_timer_private.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" #ifdef CONFIG_ESP_TIMER_PROFILING diff --git a/components/esp_timer/test_apps/main/test_esp_timer.c b/components/esp_timer/test_apps/main/test_esp_timer.c index afe70bed30..d126b4b26d 100644 --- a/components/esp_timer/test_apps/main/test_esp_timer.c +++ b/components/esp_timer/test_apps/main/test_esp_timer.c @@ -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 } -#if !CONFIG_IDF_TARGET_ESP32C61 // TODO: IDF-10955, test fail static void IRAM_ATTR test_esp_timer_get_time_performance(void) { 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(); } -#endif static int64_t IRAM_ATTR __attribute__((noinline)) get_clock_diff(void) { diff --git a/components/hal/esp32c61/include/hal/systimer_ll.h b/components/hal/esp32c61/include/hal/systimer_ll.h index f44db9031d..10143837e7 100644 --- a/components/hal/esp32c61/include/hal/systimer_ll.h +++ b/components/hal/esp32c61/include/hal/systimer_ll.h @@ -12,8 +12,6 @@ #include "soc/pcr_struct.h" #include "hal/assert.h" -// TODO: [ESP32C61] IDF-9307, inherit from C6 - #ifdef __cplusplus extern "C" { #endif diff --git a/components/idf_test/include/esp32c61/idf_performance_target.h b/components/idf_test/include/esp32c61/idf_performance_target.h index 0d4bb53b3d..1053cbef3d 100644 --- a/components/idf_test/include/esp32c61/idf_performance_target.h +++ b/components/idf_test/include/esp32c61/idf_performance_target.h @@ -6,4 +6,4 @@ #pragma once -#define IDF_PERFORMANCE_MAX_ESP_TIMER_GET_TIME_PER_CALL 1200 +#define IDF_PERFORMANCE_MAX_ESP_TIMER_GET_TIME_PER_CALL 1300 diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 6ab137ee9e..6c3bf434a5 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -37,7 +37,7 @@ #define SOC_GPSPI_SUPPORTED 1 #define SOC_I2C_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_SHA_SUPPORTED 1 //TODO: [ESP32C61] IDF-9234 #define SOC_ECC_SUPPORTED 1 diff --git a/docs/en/api-reference/system/esp_timer.rst b/docs/en/api-reference/system/esp_timer.rst index ab8fc6e758..bc56847bc8 100644 --- a/docs/en/api-reference/system/esp_timer.rst +++ b/docs/en/api-reference/system/esp_timer.rst @@ -5,7 +5,7 @@ ESP Timer (High Resolution 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 diff --git a/docs/zh_CN/api-reference/system/esp_timer.rst b/docs/zh_CN/api-reference/system/esp_timer.rst index 6a9e51eb8c..7e0493be8e 100644 --- a/docs/zh_CN/api-reference/system/esp_timer.rst +++ b/docs/zh_CN/api-reference/system/esp_timer.rst @@ -5,7 +5,7 @@ ESP 定时器(高分辨率定时器) {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 diff --git a/examples/system/.build-test-rules.yml b/examples/system/.build-test-rules.yml index e5c40421bd..088649e37b 100644 --- a/examples/system/.build-test-rules.yml +++ b/examples/system/.build-test-rules.yml @@ -51,8 +51,6 @@ examples/system/efuse: - bootloader_support examples/system/esp_timer: - disable: - - if: SOC_LIGHT_SLEEP_SUPPORTED != 1 depends_components: - esp_timer diff --git a/examples/system/esp_timer/main/esp_timer_example_main.c b/examples/system/esp_timer/main/esp_timer_example_main.c index 2aae52d86f..e2c2d26a89 100644 --- a/examples/system/esp_timer/main/esp_timer_example_main.c +++ b/examples/system/esp_timer/main/esp_timer_example_main.c @@ -58,6 +58,7 @@ void app_main(void) usleep(2000000); } +#if SOC_LIGHT_SLEEP_SUPPORTED /* Timekeeping continues in light sleep, and timers are scheduled * 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); assert(llabs((t2 - t1) - 500000) < 1200); +#endif /* Let the timer run for a little bit more */ usleep(2000000); diff --git a/examples/system/esp_timer/pytest_esp_timer.py b/examples/system/esp_timer/pytest_esp_timer.py index 929df5ccf1..595cecb7c9 100644 --- a/examples/system/esp_timer/pytest_esp_timer.py +++ b/examples/system/esp_timer/pytest_esp_timer.py @@ -71,16 +71,17 @@ def test_esp_timer(dut: Dut) -> None: logging.info('Callback #{}, time: {} us, diff: {} us'.format(i, cur_time, diff)) assert abs(diff) < 100 - match = dut.expect(LIGHT_SLEEP_ENTER_REGEX, timeout=2) - sleep_enter_time = int(match.group(1)) - match = dut.expect(LIGHT_SLEEP_EXIT_REGEX, timeout=2) - sleep_exit_time = int(match.group(1)) - sleep_time = sleep_exit_time - sleep_enter_time + if dut.app.sdkconfig.get('SOC_LIGHT_SLEEP_SUPPORTED'): + match = dut.expect(LIGHT_SLEEP_ENTER_REGEX, timeout=2) + sleep_enter_time = int(match.group(1)) + match = dut.expect(LIGHT_SLEEP_EXIT_REGEX, timeout=2) + sleep_exit_time = int(match.group(1)) + sleep_time = sleep_exit_time - sleep_enter_time - logging.info('Enter sleep: {}, exit sleep: {}, slept: {}'.format( - sleep_enter_time, sleep_exit_time, sleep_time)) + logging.info('Enter sleep: {}, exit sleep: {}, slept: {}'.format( + 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): match = dut.expect(PERIODIC_TIMER_REGEX, timeout=2)