From 28a8349fb8fdcdf53faedaa54224aa0dcac30da9 Mon Sep 17 00:00:00 2001 From: Sachin Parekh Date: Mon, 25 Mar 2019 16:08:28 +0530 Subject: [PATCH] timer: port*_CRITICAL vanilla FreeRTOS compliance Signed-off-by: Sachin Parekh --- components/driver/timer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/driver/timer.c b/components/driver/timer.c index a7a17306c..5881a58ac 100644 --- a/components/driver/timer.c +++ b/components/driver/timer.c @@ -39,19 +39,19 @@ static const char* TIMER_TAG = "timer_group"; static timg_dev_t *TG[2] = {&TIMERG0, &TIMERG1}; static portMUX_TYPE timer_spinlock[TIMER_GROUP_MAX] = {portMUX_INITIALIZER_UNLOCKED, portMUX_INITIALIZER_UNLOCKED}; -#define TIMER_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux); -#define TIMER_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux); +#define TIMER_ENTER_CRITICAL(mux) portENTER_CRITICAL_SAFE(mux); +#define TIMER_EXIT_CRITICAL(mux) portEXIT_CRITICAL_SAFE(mux); esp_err_t timer_get_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t* timer_val) { TIMER_CHECK(group_num < TIMER_GROUP_MAX, TIMER_GROUP_NUM_ERROR, ESP_ERR_INVALID_ARG); TIMER_CHECK(timer_num < TIMER_MAX, TIMER_NUM_ERROR, ESP_ERR_INVALID_ARG); TIMER_CHECK(timer_val != NULL, TIMER_PARAM_ADDR_ERROR, ESP_ERR_INVALID_ARG); - portENTER_CRITICAL(&timer_spinlock[group_num]); + portENTER_CRITICAL_SAFE(&timer_spinlock[group_num]); TG[group_num]->hw_timer[timer_num].update = 1; *timer_val = ((uint64_t) TG[group_num]->hw_timer[timer_num].cnt_high << 32) | (TG[group_num]->hw_timer[timer_num].cnt_low); - portEXIT_CRITICAL(&timer_spinlock[group_num]); + portEXIT_CRITICAL_SAFE(&timer_spinlock[group_num]); return ESP_OK; } @@ -154,10 +154,10 @@ esp_err_t timer_get_alarm_value(timer_group_t group_num, timer_idx_t timer_num, TIMER_CHECK(group_num < TIMER_GROUP_MAX, TIMER_GROUP_NUM_ERROR, ESP_ERR_INVALID_ARG); TIMER_CHECK(timer_num < TIMER_MAX, TIMER_NUM_ERROR, ESP_ERR_INVALID_ARG); TIMER_CHECK(alarm_value != NULL, TIMER_PARAM_ADDR_ERROR, ESP_ERR_INVALID_ARG); - portENTER_CRITICAL(&timer_spinlock[group_num]); + portENTER_CRITICAL_SAFE(&timer_spinlock[group_num]); *alarm_value = ((uint64_t) TG[group_num]->hw_timer[timer_num].alarm_high << 32) | (TG[group_num]->hw_timer[timer_num].alarm_low); - portEXIT_CRITICAL(&timer_spinlock[group_num]); + portEXIT_CRITICAL_SAFE(&timer_spinlock[group_num]); return ESP_OK; }