From 91fcced0fb24efb443b4975232c9feaba68d89ef Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Wed, 1 Mar 2023 19:54:38 +0800 Subject: [PATCH] esp_timer: Adds IRAM_ATTR for esp_timer_restart and esp_timer_is_active Closes https://github.com/espressif/esp-idf/issues/10522 Closes https://github.com/espressif/esp-idf/issues/10859 --- components/esp_pm/linker.lf | 4 ---- components/esp_timer/src/esp_timer.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/components/esp_pm/linker.lf b/components/esp_pm/linker.lf index be988f0a0e33..f17e24e8a2b3 100644 --- a/components/esp_pm/linker.lf +++ b/components/esp_pm/linker.lf @@ -46,10 +46,6 @@ entries: archive: libesp_timer.a entries: if PM_SLP_IRAM_OPT = y: - # esp_timer_restart is called from task_wdt_timer_feed, so put it - # in IRAM if task_wdt_timer_feed itself is in IRAM. - if ESP_TASK_WDT_USE_ESP_TIMER = y: - esp_timer:esp_timer_restart (noflash) if ESP_TIMER_IMPL_TG0_LAC = y: esp_timer_impl_lac:esp_timer_impl_lock (noflash) esp_timer_impl_lac:esp_timer_impl_unlock (noflash) diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index 095ea37d6cee..27dcf35c694f 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -146,7 +146,13 @@ esp_err_t esp_timer_create(const esp_timer_create_args_t* args, return ESP_OK; } -esp_err_t esp_timer_restart(esp_timer_handle_t timer, uint64_t timeout_us) +/* + * We have placed this function in IRAM to ensure consistency with the esp_timer API. + * esp_timer_start_once, esp_timer_start_periodic and esp_timer_stop are in IRAM. + * But actually in IDF esp_timer_restart is used only in one place, which requires keeping + * in IRAM when PM_SLP_IRAM_OPT = y and ESP_TASK_WDT USE ESP_TIMER = y. +*/ +esp_err_t IRAM_ATTR esp_timer_restart(esp_timer_handle_t timer, uint64_t timeout_us) { esp_err_t ret = ESP_OK; @@ -728,7 +734,10 @@ esp_err_t IRAM_ATTR esp_timer_get_expiry_time(esp_timer_handle_t timer, uint64_t return ESP_OK; } -bool esp_timer_is_active(esp_timer_handle_t timer) +bool IRAM_ATTR esp_timer_is_active(esp_timer_handle_t timer) { + if (timer == NULL) { + return false; + } return timer_armed(timer); }