Fix watchdog initialization and parameters
This commit is contained in:
@@ -56,6 +56,9 @@ $RECYCLE.BIN/
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# Zed
|
||||
.zed
|
||||
|
||||
# Backup files
|
||||
*~
|
||||
*.orig
|
||||
@@ -63,3 +66,9 @@ $RECYCLE.BIN/
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# EDA
|
||||
eda/atmega/atmega-backups
|
||||
|
||||
# Personal
|
||||
*-debug.sh
|
||||
|
||||
@@ -4,17 +4,28 @@
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
volatile bool critical_error_flag = false;
|
||||
|
||||
static void watchdogTask(void pvParameters*) {
|
||||
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(30000);
|
||||
static void watchdogTask(void *pvParameters) {
|
||||
esp_task_wdt_config_t twdt_config = {
|
||||
.timeout_ms = 12000,
|
||||
.idle_core_mask = 0,
|
||||
.trigger_panic = true,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_task_wdt_init(&config));
|
||||
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
|
||||
|
||||
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(8000);
|
||||
|
||||
for(;;) {
|
||||
if (critical_error_flag) {
|
||||
ESPLOGE("Critical error flag raised. Rebooting.");
|
||||
ESP_LOGE("Critical error flag raised. Rebooting.");
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
esp_task_wdt_reset();
|
||||
|
||||
vTaskDelay(keepAlivePeriod);
|
||||
@@ -35,5 +46,5 @@ extern "C" void app_main(void)
|
||||
|
||||
heap_caps_init();
|
||||
|
||||
xTaskCreate(watchdogTask, "wdt", 256, NULL, configMAX_PRIORITIES-1, NULL);
|
||||
xTaskCreate(watchdogTask, "wdt", 2048, NULL, configMAX_PRIORITIES-1, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user