Эх сурвалжийг харах

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
KonstantinKondrashov 2 жил өмнө
parent
commit
91fcced0fb

+ 0 - 4
components/esp_pm/linker.lf

@@ -46,10 +46,6 @@ entries:
 archive: libesp_timer.a
 archive: libesp_timer.a
 entries:
 entries:
     if PM_SLP_IRAM_OPT = y:
     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:
         if ESP_TIMER_IMPL_TG0_LAC = y:
             esp_timer_impl_lac:esp_timer_impl_lock (noflash)
             esp_timer_impl_lac:esp_timer_impl_lock (noflash)
             esp_timer_impl_lac:esp_timer_impl_unlock (noflash)
             esp_timer_impl_lac:esp_timer_impl_unlock (noflash)

+ 11 - 2
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;
     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;
     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;
     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);
     return timer_armed(timer);
 }
 }