Skip to content

Commit

Permalink
esp_timer: Adds IRAM_ATTR for esp_timer_restart and esp_timer_is_active
Browse files Browse the repository at this point in the history
Closes #10522
Closes #10859
  • Loading branch information
KonstantinKondrashov committed Apr 19, 2023
1 parent ddb57be commit 91fcced
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 0 additions & 4 deletions components/esp_pm/linker.lf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions components/esp_timer/src/esp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

0 comments on commit 91fcced

Please sign in to comment.