]> granicus.if.org Git - esp-idf/commitdiff
esp32/task_wdt: Add esp_task_wdt_isr_user_handler function
authorKonstantin Kondrashov <konstantin@espressif.com>
Mon, 3 Sep 2018 05:33:12 +0000 (13:33 +0800)
committerKonstantin Kondrashov <konstantin@espressif.com>
Mon, 3 Sep 2018 06:31:20 +0000 (14:31 +0800)
Added esp_task_wdt_isr_user_handler function to receive twdt events in
the user code.

Closes https://github.com/espressif/esp-idf/issues/2270

components/esp32/task_wdt.c
docs/en/api-reference/system/wdts.rst

index fb10aac05e66f0dae4e3fe38d3e1db66721a8529..2da2156ac48adae25a46e9c10c5083913467c4ee 100644 (file)
@@ -116,6 +116,17 @@ static void reset_hw_timer()
     }
 }
 
+/*
+ * This function is called by task_wdt_isr function (ISR for when TWDT times out).
+ * It can be redefined in user code to handle twdt events.
+ * Note: It has the same limitations as the interrupt function.
+ *       Do not use ESP_LOGI functions inside.
+ */
+void __attribute__((weak)) esp_task_wdt_isr_user_handler(void)
+{
+
+}
+
 /*
  * ISR for when TWDT times out. Checks for which tasks have not reset. Also
  * triggers panic if configured to do so
@@ -153,6 +164,7 @@ static void task_wdt_isr(void *arg)
         ets_printf("CPU %d: %s\n", x, pcTaskGetTaskName(xTaskGetCurrentTaskHandleForCPU(x)));
     }
 
+    esp_task_wdt_isr_user_handler();
     if (twdt_config->panic){     //Trigger Panic if configured to do so
         ets_printf("Aborting.\n");
         portEXIT_CRITICAL(&twdt_spinlock);
index e790a5df4207b8d1ff7177e4c2a7d1689bdc5419..5a5252c2231b4a51dd5c60b8f69317a5cdb9ef36 100644 (file)
@@ -44,7 +44,9 @@ elect to be watched by the TWDT. Each watched task must 'reset' the TWDT
 periodically to indicate that they have been allocated CPU time. If a task does 
 not reset within the TWDT timeout period, a warning will be printed with 
 information about which tasks failed to reset the TWDT in time and which 
-tasks are currently running on the ESP32 CPUs and.
+tasks are currently running on the ESP32 CPUs. 
+And also there is a possibility to redefine the function `esp_task_wdt_isr_user_handler` 
+in the user code to receive this event.
 
 The TWDT is built around the Hardware Watchdog Timer in Timer Group 0. The TWDT
 can be initialized by calling :cpp:func:`esp_task_wdt_init` which will configure