Fix watchdog initialization and parameters
This commit is contained in:
@@ -56,6 +56,9 @@ $RECYCLE.BIN/
|
|||||||
# VS Code
|
# VS Code
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
# Zed
|
||||||
|
.zed
|
||||||
|
|
||||||
# Backup files
|
# Backup files
|
||||||
*~
|
*~
|
||||||
*.orig
|
*.orig
|
||||||
@@ -63,3 +66,9 @@ $RECYCLE.BIN/
|
|||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# EDA
|
||||||
|
eda/atmega/atmega-backups
|
||||||
|
|
||||||
|
# Personal
|
||||||
|
*-debug.sh
|
||||||
|
|||||||
@@ -4,17 +4,28 @@
|
|||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
|
#include "esp_task_wdt.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
|
||||||
volatile bool critical_error_flag = false;
|
volatile bool critical_error_flag = false;
|
||||||
|
|
||||||
static void watchdogTask(void pvParameters*) {
|
static void watchdogTask(void *pvParameters) {
|
||||||
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(30000);
|
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(;;) {
|
for(;;) {
|
||||||
if (critical_error_flag) {
|
if (critical_error_flag) {
|
||||||
ESPLOGE("Critical error flag raised. Rebooting.");
|
ESP_LOGE("Critical error flag raised. Rebooting.");
|
||||||
esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
|
|
||||||
vTaskDelay(keepAlivePeriod);
|
vTaskDelay(keepAlivePeriod);
|
||||||
@@ -35,5 +46,5 @@ extern "C" void app_main(void)
|
|||||||
|
|
||||||
heap_caps_init();
|
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