Fix power management API and variable naming for ESP32-C3 compatibility
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
#include <iostream>
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
@@ -8,6 +7,8 @@
|
|||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "wifi.hpp"
|
#include "wifi.hpp"
|
||||||
|
|
||||||
|
static const char* TAG = "MAIN";
|
||||||
|
|
||||||
volatile bool criticalErrorFlag = false;
|
volatile bool criticalErrorFlag = false;
|
||||||
|
|
||||||
static void watchdogTask(void *pvParameters) {
|
static void watchdogTask(void *pvParameters) {
|
||||||
@@ -16,14 +17,14 @@ static void watchdogTask(void *pvParameters) {
|
|||||||
.idle_core_mask = 0,
|
.idle_core_mask = 0,
|
||||||
.trigger_panic = true,
|
.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));
|
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
|
||||||
|
|
||||||
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(8000);
|
const TickType_t keepAlivePeriod = pdMS_TO_TICKS(8000);
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (critical_error_flag) {
|
if (criticalErrorFlag) {
|
||||||
ESP_LOGE("Critical error flag raised. Rebooting.");
|
ESP_LOGE(TAG, "Critical error flag raised. Rebooting.");
|
||||||
esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,18 +36,15 @@ static void watchdogTask(void *pvParameters) {
|
|||||||
|
|
||||||
extern "C" void app_main(void)
|
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,
|
.max_freq_mhz = 80,
|
||||||
.min_freq_mhz = 10,
|
.min_freq_mhz = 10,
|
||||||
.light_sleep_enable = true,
|
.light_sleep_enable = true
|
||||||
.deep_sleep_enable = true
|
|
||||||
};
|
};
|
||||||
esp_pm_configure(&pm_cfg);
|
esp_pm_configure(&pm_cfg);
|
||||||
|
|
||||||
heap_caps_init();
|
|
||||||
|
|
||||||
xTaskCreate(watchdogTask, "watchdogs", 2048, NULL, configMAX_PRIORITIES-1, NULL);
|
xTaskCreate(watchdogTask, "watchdogs", 2048, NULL, configMAX_PRIORITIES-1, NULL);
|
||||||
xTaskCreate(wifiTask, "wifi", 4096, NULL, configMAX_PRIORITIES-4, NULL);
|
xTaskCreate(wifiTask, "wifi", 4096, NULL, configMAX_PRIORITIES-4, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user