mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
Power Management: refactor the configuration of each module in sleep mode
This commit is contained in:
@@ -28,6 +28,16 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
bool cpu_domain_pd_allowed(void);
|
bool cpu_domain_pd_allowed(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure the parameters of the CPU domain during the sleep process
|
||||||
|
*
|
||||||
|
* @param light_sleep_enable true for enable light sleep mode, false for disable light sleep mode
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK on success
|
||||||
|
*/
|
||||||
|
esp_err_t sleep_cpu_configure(bool light_sleep_enable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOC_PM_SUPPORT_CPU_PD && SOC_PM_CPU_RETENTION_BY_RTCCNTL
|
#if SOC_PM_SUPPORT_CPU_PD && SOC_PM_CPU_RETENTION_BY_RTCCNTL
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include "esp_err.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -50,11 +52,12 @@ bool sleep_modem_wifi_modem_state_enabled(void);
|
|||||||
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE */
|
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Whether to allow the Modem or TOP power domain to be powered off.
|
* @brief Whether the current target allows Modem or the TOP power domain to be powered off during light sleep
|
||||||
*
|
*
|
||||||
* In light sleep mode, only when the system can provide enough memory
|
* During light sleep on some targets, it is possible to power OFF the Modem or TOP
|
||||||
* for modem (WiFi, Bluetooth, IEEE802.15.4) retention, the Modem or TOP
|
* power domains in order to further lower power power consumption. However, this
|
||||||
* power domain can be powered off.
|
* can only occur on targets that support REGDMA for modem (WiFi, Bluetooth,
|
||||||
|
* IEEE802.15.4) retention.
|
||||||
*/
|
*/
|
||||||
bool modem_domain_pd_allowed(void);
|
bool modem_domain_pd_allowed(void);
|
||||||
|
|
||||||
@@ -65,6 +68,85 @@ bool modem_domain_pd_allowed(void);
|
|||||||
*/
|
*/
|
||||||
uint32_t sleep_modem_reject_triggers(void);
|
uint32_t sleep_modem_reject_triggers(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure the parameters of the modem subsytem during the sleep process
|
||||||
|
*
|
||||||
|
* In light sleep mode, the wake-up early time of the WiFi module and the TBTT
|
||||||
|
* interrupt early time (trigger enabling RF) are determined by the maximum and
|
||||||
|
* minimum frequency of system (higher system frequency means less time to wake
|
||||||
|
* up and enable RF).
|
||||||
|
* For the esp32c6 SOC, the modem state is strongly dependent on the light sleep
|
||||||
|
* mode, and the modem state will be enabled only when light sleep is enabled
|
||||||
|
* and the `CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP` is configured in menuconfig.
|
||||||
|
*
|
||||||
|
* @param max_freq_mhz the maximum frequency of system
|
||||||
|
* @param min_freq_mhz the minimum frequency of system
|
||||||
|
* @param light_sleep_enable ture or false for enable or disable light sleep mode, respectively
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK on success
|
||||||
|
*/
|
||||||
|
esp_err_t sleep_modem_configure(int max_freq_mhz, int min_freq_mhz, bool light_sleep_enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function type for peripherals to know light sleep wakeup overhead.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef void (* inform_out_light_sleep_overhead_cb_t)(uint32_t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Register informing peripherals light sleep wakeup overhead time callback
|
||||||
|
*
|
||||||
|
* This function allows you to register a callback that informs the peripherals of
|
||||||
|
* the wakeup overhead time of light sleep.
|
||||||
|
* @param cb function to inform time
|
||||||
|
* @return
|
||||||
|
* - ESP_OK on success
|
||||||
|
* - ESP_ERR_NO_MEM if no more callback slots are available
|
||||||
|
*/
|
||||||
|
esp_err_t esp_pm_register_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unregister informing peripherals light sleep wakeup overhead time callback
|
||||||
|
*
|
||||||
|
* This function allows you to unregister a callback that informs the peripherals of
|
||||||
|
* the wakeup overhead time of light sleep.
|
||||||
|
* @param cb function to inform time
|
||||||
|
* @return
|
||||||
|
* - ESP_OK on success
|
||||||
|
* - ESP_ERR_INVALID_STATE if the given callback hasn't been registered before
|
||||||
|
*/
|
||||||
|
esp_err_t esp_pm_unregister_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A callback that informs the peripherals of the wakeup overhead time of light sleep
|
||||||
|
*
|
||||||
|
* @param out_light_sleep_time wakeup overhead time of light sleep
|
||||||
|
*/
|
||||||
|
void periph_inform_out_light_sleep_overhead(uint32_t out_light_sleep_time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback function type for peripherals to know light sleep default parameters
|
||||||
|
*/
|
||||||
|
typedef void (* update_light_sleep_default_params_config_cb_t)(int, int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Register peripherals light sleep default parameters configure callback
|
||||||
|
*
|
||||||
|
* This function allows you to register a callback that configure the peripherals
|
||||||
|
* of default parameters of light sleep
|
||||||
|
* @param cb function to update default parameters
|
||||||
|
*/
|
||||||
|
void esp_pm_register_light_sleep_default_params_config_callback(update_light_sleep_default_params_config_cb_t cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unregister peripherals light sleep default parameters configure Callback
|
||||||
|
*
|
||||||
|
* This function allows you to unregister a callback that configure the peripherals
|
||||||
|
* of default parameters of light sleep
|
||||||
|
*/
|
||||||
|
void esp_pm_unregister_light_sleep_default_params_config_callback(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -20,6 +20,8 @@ entries:
|
|||||||
rtc_time (noflash_text)
|
rtc_time (noflash_text)
|
||||||
if SOC_PMU_SUPPORTED = y:
|
if SOC_PMU_SUPPORTED = y:
|
||||||
pmu_sleep (noflash)
|
pmu_sleep (noflash)
|
||||||
|
if PM_SLP_IRAM_OPT = y && IDF_TARGET_ESP32 = n:
|
||||||
|
sleep_modem:periph_inform_out_light_sleep_overhead (noflash)
|
||||||
if IDF_TARGET_ESP32 = y || IDF_TARGET_ESP32S2 = y:
|
if IDF_TARGET_ESP32 = y || IDF_TARGET_ESP32S2 = y:
|
||||||
rtc_wdt (noflash_text)
|
rtc_wdt (noflash_text)
|
||||||
if PERIPH_CTRL_FUNC_IN_IRAM = y:
|
if PERIPH_CTRL_FUNC_IN_IRAM = y:
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
|
#include "esp_check.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
@@ -642,4 +643,16 @@ bool cpu_domain_pd_allowed(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
|
||||||
|
{
|
||||||
|
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
|
||||||
|
if (light_sleep_enable) {
|
||||||
|
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
|
||||||
|
} else {
|
||||||
|
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_deinit(), TAG, "Failed to release CPU retention memory");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -30,6 +30,10 @@
|
|||||||
|
|
||||||
static __attribute__((unused)) const char *TAG = "sleep_modem";
|
static __attribute__((unused)) const char *TAG = "sleep_modem";
|
||||||
|
|
||||||
|
#if CONFIG_PM_SLP_DEFAULT_PARAMS_OPT
|
||||||
|
static void esp_pm_light_sleep_default_params_config(int min_freq_mhz, int max_freq_mhz);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_MAC_BB_PD
|
#if CONFIG_MAC_BB_PD
|
||||||
#define MAC_BB_POWER_DOWN_CB_NO (2)
|
#define MAC_BB_POWER_DOWN_CB_NO (2)
|
||||||
#define MAC_BB_POWER_UP_CB_NO (2)
|
#define MAC_BB_POWER_UP_CB_NO (2)
|
||||||
@@ -257,7 +261,6 @@ bool IRAM_ATTR modem_domain_pd_allowed(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t IRAM_ATTR sleep_modem_reject_triggers(void)
|
uint32_t IRAM_ATTR sleep_modem_reject_triggers(void)
|
||||||
{
|
{
|
||||||
uint32_t reject_triggers = 0;
|
uint32_t reject_triggers = 0;
|
||||||
@@ -266,3 +269,87 @@ uint32_t IRAM_ATTR sleep_modem_reject_triggers(void)
|
|||||||
#endif
|
#endif
|
||||||
return reject_triggers;
|
return reject_triggers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t sleep_modem_configure(int max_freq_mhz, int min_freq_mhz, bool light_sleep_enable)
|
||||||
|
{
|
||||||
|
#if CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
|
||||||
|
extern int esp_wifi_internal_mac_sleep_configure(bool, bool);
|
||||||
|
if (light_sleep_enable) {
|
||||||
|
if (sleep_modem_wifi_modem_state_init() == ESP_OK) {
|
||||||
|
esp_wifi_internal_mac_sleep_configure(light_sleep_enable, true); /* require WiFi to enable automatically receives the beacon */
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
esp_wifi_internal_mac_sleep_configure(light_sleep_enable, false); /* require WiFi to disable automatically receives the beacon */
|
||||||
|
sleep_modem_wifi_modem_state_deinit();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if CONFIG_PM_SLP_DEFAULT_PARAMS_OPT
|
||||||
|
if (light_sleep_enable) {
|
||||||
|
esp_pm_light_sleep_default_params_config(min_freq_mhz, max_freq_mhz);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO 1
|
||||||
|
|
||||||
|
/* Inform peripherals of light sleep wakeup overhead time */
|
||||||
|
static inform_out_light_sleep_overhead_cb_t s_periph_inform_out_light_sleep_overhead_cb[PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO];
|
||||||
|
|
||||||
|
esp_err_t esp_pm_register_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO; i++) {
|
||||||
|
if (s_periph_inform_out_light_sleep_overhead_cb[i] == cb) {
|
||||||
|
return ESP_OK;
|
||||||
|
} else if (s_periph_inform_out_light_sleep_overhead_cb[i] == NULL) {
|
||||||
|
s_periph_inform_out_light_sleep_overhead_cb[i] = cb;
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ESP_ERR_NO_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_pm_unregister_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO; i++) {
|
||||||
|
if (s_periph_inform_out_light_sleep_overhead_cb[i] == cb) {
|
||||||
|
s_periph_inform_out_light_sleep_overhead_cb[i] = NULL;
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void periph_inform_out_light_sleep_overhead(uint32_t out_light_sleep_time)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO; i++) {
|
||||||
|
if (s_periph_inform_out_light_sleep_overhead_cb[i]) {
|
||||||
|
s_periph_inform_out_light_sleep_overhead_cb[i](out_light_sleep_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static update_light_sleep_default_params_config_cb_t s_light_sleep_default_params_config_cb = NULL;
|
||||||
|
|
||||||
|
void esp_pm_register_light_sleep_default_params_config_callback(update_light_sleep_default_params_config_cb_t cb)
|
||||||
|
{
|
||||||
|
if (s_light_sleep_default_params_config_cb == NULL) {
|
||||||
|
s_light_sleep_default_params_config_cb = cb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void esp_pm_unregister_light_sleep_default_params_config_callback(void)
|
||||||
|
{
|
||||||
|
if (s_light_sleep_default_params_config_cb) {
|
||||||
|
s_light_sleep_default_params_config_cb = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if CONFIG_PM_SLP_DEFAULT_PARAMS_OPT
|
||||||
|
static void esp_pm_light_sleep_default_params_config(int min_freq_mhz, int max_freq_mhz)
|
||||||
|
{
|
||||||
|
if (s_light_sleep_default_params_config_cb) {
|
||||||
|
(*s_light_sleep_default_params_config_cb)(min_freq_mhz, max_freq_mhz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@@ -139,8 +139,6 @@
|
|||||||
#define DEEP_SLEEP_WAKEUP_DELAY 0
|
#define DEEP_SLEEP_WAKEUP_DELAY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void periph_inform_out_light_sleep_overhead(uint32_t out_light_sleep_time);
|
|
||||||
|
|
||||||
// Minimal amount of time we can sleep for
|
// Minimal amount of time we can sleep for
|
||||||
#define LIGHT_SLEEP_MIN_TIME_US 200
|
#define LIGHT_SLEEP_MIN_TIME_US 200
|
||||||
|
|
||||||
|
@@ -1,16 +1,8 @@
|
|||||||
// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2016-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -149,58 +141,6 @@ esp_err_t esp_pm_register_skip_light_sleep_callback(skip_light_sleep_cb_t cb);
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_pm_unregister_skip_light_sleep_callback(skip_light_sleep_cb_t cb);
|
esp_err_t esp_pm_unregister_skip_light_sleep_callback(skip_light_sleep_cb_t cb);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Callback function type for peripherals to know light sleep wakeup overhead.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
typedef void (* inform_out_light_sleep_overhead_cb_t)(uint32_t);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register informing peripherals light sleep wakeup overhead time callback
|
|
||||||
*
|
|
||||||
* This function allows you to register a callback that informs the peripherals of
|
|
||||||
* the wakeup overhead time of light sleep.
|
|
||||||
* @param cb function to inform time
|
|
||||||
* @return
|
|
||||||
* - ESP_OK on success
|
|
||||||
* - ESP_ERR_NO_MEM if no more callback slots are available
|
|
||||||
*/
|
|
||||||
esp_err_t esp_pm_register_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unregister informing peripherals light sleep wakeup overhead time callback
|
|
||||||
*
|
|
||||||
* This function allows you to unregister a callback that informs the peripherals of
|
|
||||||
* the wakeup overhead time of light sleep.
|
|
||||||
* @param cb function to inform time
|
|
||||||
* @return
|
|
||||||
* - ESP_OK on success
|
|
||||||
* - ESP_ERR_INVALID_STATE if the given callback hasn't been registered before
|
|
||||||
*/
|
|
||||||
esp_err_t esp_pm_unregister_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Callback function type for peripherals to know light sleep default parameters
|
|
||||||
*/
|
|
||||||
typedef void (* update_light_sleep_default_params_config_cb_t)(int, int);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register peripherals light sleep default parameters configure callback
|
|
||||||
*
|
|
||||||
* This function allows you to register a callback that configure the peripherals
|
|
||||||
* of default parameters of light sleep
|
|
||||||
* @param cb function to update default parameters
|
|
||||||
*/
|
|
||||||
void esp_pm_register_light_sleep_default_params_config_callback(update_light_sleep_default_params_config_cb_t cb);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unregister peripherals light sleep default parameters configure Callback
|
|
||||||
*
|
|
||||||
* This function allows you to unregister a callback that configure the peripherals
|
|
||||||
* of default parameters of light sleep
|
|
||||||
*/
|
|
||||||
void esp_pm_unregister_light_sleep_default_params_config_callback(void);
|
|
||||||
|
|
||||||
#ifdef CONFIG_PM_PROFILING
|
#ifdef CONFIG_PM_PROFILING
|
||||||
#define WITH_PROFILING
|
#define WITH_PROFILING
|
||||||
#endif
|
#endif
|
||||||
|
@@ -4,8 +4,6 @@ entries:
|
|||||||
if PM_RTOS_IDLE_OPT = y:
|
if PM_RTOS_IDLE_OPT = y:
|
||||||
pm_impl:esp_pm_impl_idle_hook (noflash)
|
pm_impl:esp_pm_impl_idle_hook (noflash)
|
||||||
pm_impl:esp_pm_impl_waiti (noflash)
|
pm_impl:esp_pm_impl_waiti (noflash)
|
||||||
if PM_SLP_IRAM_OPT = y && IDF_TARGET_ESP32 = n:
|
|
||||||
pm_impl:periph_inform_out_light_sleep_overhead (noflash)
|
|
||||||
|
|
||||||
[mapping:esp_hw_support_pm]
|
[mapping:esp_hw_support_pm]
|
||||||
archive: libesp_hw_support.a
|
archive: libesp_hw_support.a
|
||||||
|
@@ -35,7 +35,9 @@
|
|||||||
#include "esp_private/pm_trace.h"
|
#include "esp_private/pm_trace.h"
|
||||||
#include "esp_private/esp_timer_private.h"
|
#include "esp_private/esp_timer_private.h"
|
||||||
#include "esp_private/esp_clk.h"
|
#include "esp_private/esp_clk.h"
|
||||||
|
#include "esp_private/sleep_cpu.h"
|
||||||
|
#include "esp_private/sleep_gpio.h"
|
||||||
|
#include "esp_private/sleep_modem.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
@@ -178,9 +180,6 @@ static const char* TAG = "pm";
|
|||||||
static void do_switch(pm_mode_t new_mode);
|
static void do_switch(pm_mode_t new_mode);
|
||||||
static void leave_idle(void);
|
static void leave_idle(void);
|
||||||
static void on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_per_us);
|
static void on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_per_us);
|
||||||
#if CONFIG_PM_SLP_DEFAULT_PARAMS_OPT
|
|
||||||
static void esp_pm_light_sleep_default_params_config(int min_freq_mhz, int max_freq_mhz);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pm_mode_t esp_pm_impl_get_mode(esp_pm_lock_type_t type, int arg)
|
pm_mode_t esp_pm_impl_get_mode(esp_pm_lock_type_t type, int arg)
|
||||||
{
|
{
|
||||||
@@ -197,6 +196,22 @@ pm_mode_t esp_pm_impl_get_mode(esp_pm_lock_type_t type, int arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_pm_sleep_configure(const void *vconfig)
|
||||||
|
{
|
||||||
|
esp_err_t err = ESP_OK;
|
||||||
|
const esp_pm_config_t* config = (const esp_pm_config_t*) vconfig;
|
||||||
|
|
||||||
|
#if SOC_PM_SUPPORT_CPU_PD
|
||||||
|
err = sleep_cpu_configure(config->light_sleep_enable);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
err = sleep_modem_configure(config->max_freq_mhz, config->min_freq_mhz, config->light_sleep_enable);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t esp_pm_configure(const void* vconfig)
|
esp_err_t esp_pm_configure(const void* vconfig)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_PM_ENABLE
|
#ifndef CONFIG_PM_ENABLE
|
||||||
@@ -282,26 +297,7 @@ esp_err_t esp_pm_configure(const void* vconfig)
|
|||||||
s_config_changed = true;
|
s_config_changed = true;
|
||||||
portEXIT_CRITICAL(&s_switch_lock);
|
portEXIT_CRITICAL(&s_switch_lock);
|
||||||
|
|
||||||
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_SUPPORT_CPU_PD
|
esp_pm_sleep_configure(config);
|
||||||
if (config->light_sleep_enable) {
|
|
||||||
if (esp_sleep_cpu_retention_init() != ESP_OK) {
|
|
||||||
ESP_LOGW(TAG, "Failed to enable CPU power down during light sleep.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
esp_sleep_cpu_retention_deinit();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_ESP_WIFI_AUTO_BEACON_ENABLE
|
|
||||||
extern int esp_wifi_internal_mac_sleep_configure(bool, bool);
|
|
||||||
esp_wifi_internal_mac_sleep_configure(config->light_sleep_enable, true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_PM_SLP_DEFAULT_PARAMS_OPT
|
|
||||||
if (config->light_sleep_enable) {
|
|
||||||
esp_pm_light_sleep_default_params_config(min_freq_mhz, max_freq_mhz);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -821,66 +817,3 @@ void esp_pm_impl_waiti(void)
|
|||||||
esp_cpu_wait_for_intr();
|
esp_cpu_wait_for_intr();
|
||||||
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO 1
|
|
||||||
|
|
||||||
/* Inform peripherals of light sleep wakeup overhead time */
|
|
||||||
static inform_out_light_sleep_overhead_cb_t s_periph_inform_out_light_sleep_overhead_cb[PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO];
|
|
||||||
|
|
||||||
esp_err_t esp_pm_register_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO; i++) {
|
|
||||||
if (s_periph_inform_out_light_sleep_overhead_cb[i] == cb) {
|
|
||||||
return ESP_OK;
|
|
||||||
} else if (s_periph_inform_out_light_sleep_overhead_cb[i] == NULL) {
|
|
||||||
s_periph_inform_out_light_sleep_overhead_cb[i] = cb;
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ESP_ERR_NO_MEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t esp_pm_unregister_inform_out_light_sleep_overhead_callback(inform_out_light_sleep_overhead_cb_t cb)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO; i++) {
|
|
||||||
if (s_periph_inform_out_light_sleep_overhead_cb[i] == cb) {
|
|
||||||
s_periph_inform_out_light_sleep_overhead_cb[i] = NULL;
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ESP_ERR_INVALID_STATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void periph_inform_out_light_sleep_overhead(uint32_t out_light_sleep_time)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < PERIPH_INFORM_OUT_LIGHT_SLEEP_OVERHEAD_NO; i++) {
|
|
||||||
if (s_periph_inform_out_light_sleep_overhead_cb[i]) {
|
|
||||||
s_periph_inform_out_light_sleep_overhead_cb[i](out_light_sleep_time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static update_light_sleep_default_params_config_cb_t s_light_sleep_default_params_config_cb = NULL;
|
|
||||||
|
|
||||||
void esp_pm_register_light_sleep_default_params_config_callback(update_light_sleep_default_params_config_cb_t cb)
|
|
||||||
{
|
|
||||||
if (s_light_sleep_default_params_config_cb == NULL) {
|
|
||||||
s_light_sleep_default_params_config_cb = cb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void esp_pm_unregister_light_sleep_default_params_config_callback(void)
|
|
||||||
{
|
|
||||||
if (s_light_sleep_default_params_config_cb) {
|
|
||||||
s_light_sleep_default_params_config_cb = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CONFIG_PM_SLP_DEFAULT_PARAMS_OPT
|
|
||||||
static void esp_pm_light_sleep_default_params_config(int min_freq_mhz, int max_freq_mhz)
|
|
||||||
{
|
|
||||||
if (s_light_sleep_default_params_config_cb) {
|
|
||||||
(*s_light_sleep_default_params_config_cb)(min_freq_mhz, max_freq_mhz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
@@ -630,6 +630,17 @@ void esp_wifi_set_keep_alive_time(uint32_t keep_alive_time);
|
|||||||
*/
|
*/
|
||||||
void esp_wifi_beacon_monitor_configure(bool enable, int timeout, int threshold, int delta_intr_early, int delta_timeout);
|
void esp_wifi_beacon_monitor_configure(bool enable, int timeout, int threshold, int delta_intr_early, int delta_timeout);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Require WiFi to enable or disable Advanced DTIM sleep function
|
||||||
|
*
|
||||||
|
* @param light_sleep_enable: true for light sleep mode is enabled, false for light sleep mode is disabled.
|
||||||
|
* @param modem_state_enable: true for require WiFi to enable Advanced DTIM sleep function,
|
||||||
|
* false for require WiFi to disable Advanced DTIM sleep function.
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: succeed
|
||||||
|
*/
|
||||||
|
void esp_wifi_internal_mac_sleep_configure(bool light_sleep_enable, bool modem_state_enable);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -143,7 +143,7 @@ typedef struct {
|
|||||||
uint8_t (* _coex_schm_curr_period_get)(void);
|
uint8_t (* _coex_schm_curr_period_get)(void);
|
||||||
void * (* _coex_schm_curr_phase_get)(void);
|
void * (* _coex_schm_curr_phase_get)(void);
|
||||||
int (* _coex_register_start_cb)(int (* cb)(void));
|
int (* _coex_register_start_cb)(int (* cb)(void));
|
||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
#if CONFIG_IDF_TARGET_ESP32C6
|
||||||
void (* _regdma_link_set_write_wait_content)(void *, uint32_t, uint32_t);
|
void (* _regdma_link_set_write_wait_content)(void *, uint32_t, uint32_t);
|
||||||
void * (* _sleep_retention_find_link_by_id)(int);
|
void * (* _sleep_retention_find_link_by_id)(int);
|
||||||
int (* _sleep_retention_entries_create)(const void *, int, int, int);
|
int (* _sleep_retention_entries_create)(const void *, int, int, int);
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_private/wifi.h"
|
#include "esp_private/wifi.h"
|
||||||
#include "esp_private/adc_share_hw_ctrl.h"
|
#include "esp_private/adc_share_hw_ctrl.h"
|
||||||
|
#include "esp_private/sleep_modem.h"
|
||||||
#include "esp_pm.h"
|
#include "esp_pm.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "esp_private/pm_impl.h"
|
#include "esp_private/pm_impl.h"
|
||||||
|
@@ -439,7 +439,6 @@ components/esp_netif/test/test_esp_netif.c
|
|||||||
components/esp_netif/test_apps/component_ut_test.py
|
components/esp_netif/test_apps/component_ut_test.py
|
||||||
components/esp_netif/test_apps/main/esp_netif_test.c
|
components/esp_netif/test_apps/main/esp_netif_test.c
|
||||||
components/esp_phy/test/test_phy_rtc.c
|
components/esp_phy/test/test_phy_rtc.c
|
||||||
components/esp_pm/include/esp_private/pm_impl.h
|
|
||||||
components/esp_pm/include/esp_private/pm_trace.h
|
components/esp_pm/include/esp_private/pm_trace.h
|
||||||
components/esp_pm/pm_locks.c
|
components/esp_pm/pm_locks.c
|
||||||
components/esp_pm/test/test_pm.c
|
components/esp_pm/test/test_pm.c
|
||||||
|
Reference in New Issue
Block a user