Files
the-waterinator/firmware/esp32/source/main.cpp
T
2025-10-10 23:59:39 +02:00

40 lines
938 B
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <iostream>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"
#include "esp_pm.h"
volatile bool critical_error_flag = false;
static void watchdogTask(void pvParameters*) {
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(30000);
for(;;) {
if (critical_error_flag) {
ESPLOGE("Critical error flag raised. Rebooting.");
esp_restart();
}
esp_task_wdt_reset();
vTaskDelay(keepAlivePeriod);
}
}
extern "C" void app_main(void)
{
ESP_LOGI("BOOT", "Hello from user land bootloader worked yay!");
static const esp_pm_configure_t pm_cfg = {
.max_freq_mhz = 80,
.min_freq_mhz = 10,
.light_sleep_enable = true,
.deep_sleep_enable = true
};
esp_pm_configure(&pm_cfg);
xTaskCreate(watchdogTask, "wdt", 256, NULL, configMAX_PRIORITIES-1, NULL);
}