]> granicus.if.org Git - esp-idf/commitdiff
timer: port*_CRITICAL vanilla FreeRTOS compliance
authorSachin Parekh <sachin.parekh@espressif.com>
Mon, 25 Mar 2019 10:38:28 +0000 (16:08 +0530)
committerbot <bot@espressif.com>
Tue, 25 Jun 2019 04:33:32 +0000 (04:33 +0000)
Signed-off-by: Sachin Parekh <sachin.parekh@espressif.com>
components/driver/timer.c

index a7a17306c62ce0e68d7fd30ca0071eac5dee8ddc..5881a58acc6089d9532c12f424a6eda914e397e5 100644 (file)
@@ -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;
 }