Fix power management API and variable naming for ESP32-C3 compatibility

This commit is contained in:
2025-10-11 23:46:33 +02:00
parent 4a9a3ef805
commit c0758b071e
+8 -10
View File
@@ -1,4 +1,3 @@
#include <iostream>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
@@ -8,6 +7,8 @@
#include "esp_task_wdt.h"
#include "wifi.hpp"
static const char* TAG = "MAIN";
volatile bool criticalErrorFlag = false;
static void watchdogTask(void *pvParameters) {
@@ -16,14 +17,14 @@ static void watchdogTask(void *pvParameters) {
.idle_core_mask = 0,
.trigger_panic = true,
};
ESP_ERROR_CHECK(esp_task_wdt_init(&config));
ESP_ERROR_CHECK(esp_task_wdt_init(&twdt_config));
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(8000);
for(;;) {
if (critical_error_flag) {
ESP_LOGE("Critical error flag raised. Rebooting.");
if (criticalErrorFlag) {
ESP_LOGE(TAG, "Critical error flag raised. Rebooting.");
esp_restart();
}
@@ -35,18 +36,15 @@ static void watchdogTask(void *pvParameters) {
extern "C" void app_main(void)
{
ESP_LOGI("BOOT", "Hello from user land bootloader worked yay!");
ESP_LOGI(TAG, "Hello from user land bootloader worked yay!");
static const esp_pm_configure_t pm_cfg = {
static const esp_pm_config_t pm_cfg = {
.max_freq_mhz = 80,
.min_freq_mhz = 10,
.light_sleep_enable = true,
.deep_sleep_enable = true
.light_sleep_enable = true
};
esp_pm_configure(&pm_cfg);
heap_caps_init();
xTaskCreate(watchdogTask, "watchdogs", 2048, NULL, configMAX_PRIORITIES-1, NULL);
xTaskCreate(wifiTask, "wifi", 4096, NULL, configMAX_PRIORITIES-4, NULL);
}