From 826b976ba539c43fbf7179bb18af60ded14452e1 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 12 Apr 2021 09:40:46 +0800 Subject: [PATCH] timer: add IRAM_ATTR to spinlock give/take API Closes https://github.com/espressif/esp-idf/issues/6824 --- components/driver/include/driver/timer.h | 8 ++++++-- components/driver/timer.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/driver/include/driver/timer.h b/components/driver/include/driver/timer.h index 1a4c074a64..609d1006ad 100644 --- a/components/driver/include/driver/timer.h +++ b/components/driver/include/driver/timer.h @@ -432,6 +432,8 @@ void timer_group_clr_intr_sta_in_isr(timer_group_t group_num, timer_intr_t intr_ bool timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t timer_num); /** @brief Take timer spinlock to enter critical protect + * + * @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main * * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1 * @@ -439,9 +441,11 @@ bool timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t tim * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ -esp_err_t timer_spinlock_take(timer_group_t group_num); +esp_err_t timer_spinlock_take(timer_group_t group_num) __attribute__ ((deprecated)); /** @brief Give timer spinlock to exit critical protect + * + * @note Deprecated, the recommended way is to use ISR callbacks instead, see timer_group_example_main * * @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1 * @@ -449,7 +453,7 @@ esp_err_t timer_spinlock_take(timer_group_t group_num); * - ESP_OK Success * - ESP_ERR_INVALID_ARG Parameter error */ -esp_err_t timer_spinlock_give(timer_group_t group_num); +esp_err_t timer_spinlock_give(timer_group_t group_num) __attribute__ ((deprecated)); #ifdef __cplusplus } diff --git a/components/driver/timer.c b/components/driver/timer.c index 19ecdb9b9a..f7a6161b16 100644 --- a/components/driver/timer.c +++ b/components/driver/timer.c @@ -474,14 +474,14 @@ bool IRAM_ATTR timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer return timer_hal_get_auto_reload(&(p_timer_obj[group_num][timer_num]->hal)); } -esp_err_t timer_spinlock_take(timer_group_t group_num) +esp_err_t IRAM_ATTR timer_spinlock_take(timer_group_t group_num) { TIMER_CHECK(group_num < TIMER_GROUP_MAX, TIMER_GROUP_NUM_ERROR, ESP_ERR_INVALID_ARG); TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]); return ESP_OK; } -esp_err_t timer_spinlock_give(timer_group_t group_num) +esp_err_t IRAM_ATTR timer_spinlock_give(timer_group_t group_num) { TIMER_CHECK(group_num < TIMER_GROUP_MAX, TIMER_GROUP_NUM_ERROR, ESP_ERR_INVALID_ARG); TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);