Add power manager.
This commit is contained in:
parent
9b6a91f04c
commit
c92f4ebbcc
|
|
@ -33,6 +33,9 @@
|
|||
"initializer_list": "c",
|
||||
"list": "c",
|
||||
"queue": "c",
|
||||
"stack": "c"
|
||||
"stack": "c",
|
||||
"esp_system.h": "c",
|
||||
"esp_clk_tree.h": "c",
|
||||
"esp_vfs_fat.h": "c"
|
||||
}
|
||||
}
|
||||
80
main/main.c
80
main/main.c
|
|
@ -11,10 +11,15 @@
|
|||
#include "driver/sdmmc_host.h"
|
||||
#include "es7210.h"
|
||||
#include "esp32_s3_szp.h"
|
||||
#include "esp_bt.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_netif_sntp.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_private/esp_clk.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_sntp.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "format_wav.h"
|
||||
|
|
@ -298,8 +303,49 @@ err:
|
|||
|
||||
void init_msc(sdmmc_card_t* card);
|
||||
|
||||
void config_power_manager() {
|
||||
// 自动降频至8MHz 双核都空闲时进入 Light Sleep
|
||||
esp_err_t ret;
|
||||
esp_pm_config_esp32_t pm_config = {
|
||||
.max_freq_mhz = 240, .min_freq_mhz = 8, .light_sleep_enable = true};
|
||||
ret = esp_pm_configure(&pm_config);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE("PM", "Power management configuration failed (0x%x)", ret);
|
||||
}
|
||||
uint32_t cpu_freq = esp_clk_cpu_freq();
|
||||
printf("当前CPU频率: %lu MHz\n", cpu_freq / 1000000);
|
||||
// vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
|
||||
// light_sleep_off
|
||||
// deep sleep 5
|
||||
// 240 44.8
|
||||
// 160 38.4
|
||||
// 80 32.9
|
||||
// 8 18.8
|
||||
}
|
||||
|
||||
void taskOnCore0(void* pvParam) {
|
||||
while (1) {
|
||||
uint32_t cpu_freq = esp_clk_cpu_freq();
|
||||
printf("taskOnCore0 当前CPU频率: %lu MHz\n", cpu_freq / 1000000);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
// esp_sleep_enable_timer_wakeup(1 * 1000000);
|
||||
// esp_light_sleep_start();
|
||||
}
|
||||
}
|
||||
void taskOnCore1(void* pvParam) {
|
||||
while (1) {
|
||||
uint32_t cpu_freq = esp_clk_cpu_freq();
|
||||
printf("taskOnCore1 当前CPU频率: %lu MHz\n", cpu_freq / 1000000);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
// esp_sleep_enable_timer_wakeup(1 * 1000000);
|
||||
// esp_light_sleep_start();
|
||||
}
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
esp_err_t ret;
|
||||
ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
|
|
@ -323,6 +369,38 @@ void app_main(void) {
|
|||
i2s_chan_handle_t i2s_rx_chan = es7210_i2s_init();
|
||||
es7210_codec_init();
|
||||
wifi_connect();
|
||||
|
||||
// esp_wifi_stop();
|
||||
// esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||
// esp_wifi_deinit();
|
||||
// esp_bt_controller_disable();
|
||||
// esp_bt_controller_deinit();
|
||||
// esp_bluedroid_disable();
|
||||
// esp_bluedroid_deinit();
|
||||
// esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
|
||||
|
||||
// 主动休眠
|
||||
// esp_deep_sleep_start();
|
||||
// esp_light_sleep_start();
|
||||
|
||||
// config_power_manager();
|
||||
// xTaskCreatePinnedToCore(taskOnCore0, // 任务函数
|
||||
// "Core0_Task", // 任务名称
|
||||
// 4096, // 堆栈大小
|
||||
// NULL, // 参数
|
||||
// 1, // 优先级
|
||||
// NULL, // 任务句柄
|
||||
// 0 // 绑定到核心0
|
||||
// );
|
||||
// xTaskCreatePinnedToCore(taskOnCore1, // 任务函数
|
||||
// "Core1_Task", // 任务名称
|
||||
// 4096, // 堆栈大小
|
||||
// NULL, // 参数
|
||||
// 1, // 优先级
|
||||
// NULL, // 任务句柄
|
||||
// 1 // 绑定到核心0
|
||||
// );
|
||||
|
||||
record_file_name = malloc(64);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
esp_err_t err = record_wav(i2s_rx_chan);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,27 @@ CONFIG_LV_USE_GIF=y
|
|||
CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=y
|
||||
|
||||
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BT_BLUEDROID_ENABLED=y
|
||||
CONFIG_BT_MODE_BLE=y
|
||||
|
||||
|
||||
# Component config → Power Management
|
||||
CONFIG_PM_ENABLE=y # 启用电源管理
|
||||
CONFIG_PM_DFS_INIT_AUTO=y # 自动动态频率调节
|
||||
CONFIG_PM_PROFILING=y # 功耗分析(可选)
|
||||
|
||||
# Component config → FreeRTOS
|
||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y # 启用 tickless 空闲模式
|
||||
CONFIG_FREERTOS_TICKLESS_IDLE_C1=y # CPU0 空闲时进入 Light Sleep
|
||||
CONFIG_FREERTOS_TICKLESS_IDLE_C2=y # CPU1 空闲时进入 Light Sleep
|
||||
CONFIG_FREERTOS_IDLE_TIME_BEFORE_SLEEP=2 # 空闲等待时间(单位:tick)
|
||||
|
||||
# Component config → ESP System Settings
|
||||
CONFIG_ESP_SYSTEM_PM_IDLE_SLEEP_MODE=1 # 0:无睡眠 1:Light Sleep
|
||||
|
||||
|
||||
|
||||
#
|
||||
# ESP Speech Recognition
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in New Issue