diff --git a/components/esp_pm/include/esp32/pm.h b/components/esp_pm/include/esp32/pm.h index 4933345f09..d5d6022fb3 100644 --- a/components/esp_pm/include/esp32/pm.h +++ b/components/esp_pm/include/esp32/pm.h @@ -6,25 +6,8 @@ #pragma once -#include -#include -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" -/** - * @brief Power management config for ESP32 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32c2/pm.h b/components/esp_pm/include/esp32c2/pm.h index 78ad319646..4488ff895a 100644 --- a/components/esp_pm/include/esp32c2/pm.h +++ b/components/esp_pm/include/esp32c2/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32c2_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32-C2 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32c2_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32c3/pm.h b/components/esp_pm/include/esp32c3/pm.h index e2d125d89a..aeb83322cc 100644 --- a/components/esp_pm/include/esp32c3/pm.h +++ b/components/esp_pm/include/esp32c3/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32c3_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32C3 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32c3_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32c6/pm.h b/components/esp_pm/include/esp32c6/pm.h index 6255cccad1..b6b0487861 100644 --- a/components/esp_pm/include/esp32c6/pm.h +++ b/components/esp_pm/include/esp32c6/pm.h @@ -1,32 +1,13 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32c6_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32C6 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32c6_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32h2/pm.h b/components/esp_pm/include/esp32h2/pm.h deleted file mode 100644 index 45c89d71c6..0000000000 --- a/components/esp_pm/include/esp32h2/pm.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - - -#pragma once -#include -#include -#include "esp_err.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Power management config for ESP32H2 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32h2_t; - -#ifdef __cplusplus -} -#endif diff --git a/components/esp_pm/include/esp32h4/pm.h b/components/esp_pm/include/esp32h4/pm.h index 9a1c9c9c42..1078f77812 100644 --- a/components/esp_pm/include/esp32h4/pm.h +++ b/components/esp_pm/include/esp32h4/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32h4_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32H4 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32h4_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32s2/pm.h b/components/esp_pm/include/esp32s2/pm.h index 8036326ff9..8c6bc5bb84 100644 --- a/components/esp_pm/include/esp32s2/pm.h +++ b/components/esp_pm/include/esp32s2/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32s2_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32s2_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp32s3/pm.h b/components/esp_pm/include/esp32s3/pm.h index 51ec7aafb2..b51c7df326 100644 --- a/components/esp_pm/include/esp32s3/pm.h +++ b/components/esp_pm/include/esp32s3/pm.h @@ -6,27 +6,8 @@ #pragma once -#include -#include -#include "esp_err.h" -#ifdef __cplusplus -extern "C" { -#endif +#warning "esp_pm_config_esp32s3_t is deprecated, please include esp_pm.h and use esp_pm_config_t instead" - -/** - * @brief Power management config for ESP32 - * - * Pass a pointer to this structure as an argument to esp_pm_configure function. - */ -typedef struct { - int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ - int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ - bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ -} esp_pm_config_esp32s3_t; - - -#ifdef __cplusplus -} -#endif +/* backward compatibility */ +#include "esp_pm.h" diff --git a/components/esp_pm/include/esp_pm.h b/components/esp_pm/include/esp_pm.h index 4b8a3b05ca..f64bdd93cf 100644 --- a/components/esp_pm/include/esp_pm.h +++ b/components/esp_pm/include/esp_pm.h @@ -9,26 +9,34 @@ #include #include "esp_err.h" #include "sdkconfig.h" -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/pm.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/pm.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/pm.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/pm.h" -#endif #ifdef __cplusplus extern "C" { #endif +/** + * @brief Power management config + * + * Pass a pointer to this structure as an argument to esp_pm_configure function. + */ +typedef struct { + int max_freq_mhz; /*!< Maximum CPU frequency, in MHz */ + int min_freq_mhz; /*!< Minimum CPU frequency to use when no locks are taken, in MHz */ + bool light_sleep_enable; /*!< Enter light sleep when no locks are taken */ +} esp_pm_config_t; + +/** + * backward compatibility + * newer chips no longer require this typedef + */ +typedef esp_pm_config_t esp_pm_config_esp32_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32s2_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32s3_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32c3_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32h4_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32c2_t __attribute__((deprecated("please use esp_pm_config_t instead"))); +typedef esp_pm_config_t esp_pm_config_esp32c6_t __attribute__((deprecated("please use esp_pm_config_t instead"))); + /** * @brief Power management constraints */ diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index a14bcc3d2f..b56346ba81 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -22,6 +22,7 @@ #include "hal/uart_ll.h" #include "hal/uart_types.h" #include "driver/uart.h" +#include "driver/gpio.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -39,31 +40,6 @@ #include "sdkconfig.h" -// [refactor-todo] opportunity for further refactor -#if CONFIG_IDF_TARGET_ESP32 -#include "esp32/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/pm.h" -#elif CONFIG_IDF_TARGET_ESP32C3 -#include "esp32c3/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32H4 -#include "esp32h4/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32C2 -#include "esp32c2/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32C6 -#include "esp32c6/pm.h" -#include "driver/gpio.h" -#elif CONFIG_IDF_TARGET_ESP32H2 -#include "esp32h2/pm.h" -#include "driver/gpio.h" -#endif #define MHZ (1000000) @@ -227,23 +203,7 @@ esp_err_t esp_pm_configure(const void* vconfig) return ESP_ERR_NOT_SUPPORTED; #endif -#if CONFIG_IDF_TARGET_ESP32 - const esp_pm_config_esp32_t* config = (const esp_pm_config_esp32_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S2 - const esp_pm_config_esp32s2_t* config = (const esp_pm_config_esp32s2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S3 - const esp_pm_config_esp32s3_t* config = (const esp_pm_config_esp32s3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C3 - const esp_pm_config_esp32c3_t* config = (const esp_pm_config_esp32c3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H4 - const esp_pm_config_esp32h4_t* config = (const esp_pm_config_esp32h4_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C2 - const esp_pm_config_esp32c2_t* config = (const esp_pm_config_esp32c2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C6 - const esp_pm_config_esp32c6_t* config = (const esp_pm_config_esp32c6_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H2 - const esp_pm_config_esp32h2_t* config = (const esp_pm_config_esp32h2_t*) vconfig; -#endif + const esp_pm_config_t* config = (const esp_pm_config_t*) vconfig; #ifndef CONFIG_FREERTOS_USE_TICKLESS_IDLE if (config->light_sleep_enable) { @@ -347,23 +307,7 @@ esp_err_t esp_pm_get_configuration(void* vconfig) return ESP_ERR_INVALID_ARG; } -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t* config = (esp_pm_config_esp32_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t* config = (esp_pm_config_esp32s2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t* config = (esp_pm_config_esp32s3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t* config = (esp_pm_config_esp32c3_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t* config = (esp_pm_config_esp32h4_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t* config = (esp_pm_config_esp32c2_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t* config = (esp_pm_config_esp32c6_t*) vconfig; -#elif CONFIG_IDF_TARGET_ESP32H2 - esp_pm_config_esp32h2_t* config = (esp_pm_config_esp32h2_t*) vconfig; -#endif + esp_pm_config_t* config = (esp_pm_config_t*) vconfig; portENTER_CRITICAL(&s_switch_lock); config->light_sleep_enable = s_light_sleep_en; @@ -792,23 +736,7 @@ void esp_pm_impl_init(void) #ifdef CONFIG_PM_DFS_INIT_AUTO int xtal_freq_mhz = esp_clk_xtal_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t cfg = { -#elif CONFIG_IDF_TARGET_ESP32H2 - esp_pm_config_esp32h2_t cfg = { -#endif + esp_pm_config_t cfg = { .max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ, .min_freq_mhz = xtal_freq_mhz, }; diff --git a/components/esp_pm/test_apps/esp_pm/main/test_pm.c b/components/esp_pm/test_apps/esp_pm/main/test_pm.c index 09e90edce7..af98d2c54a 100644 --- a/components/esp_pm/test_apps/esp_pm/main/test_pm.c +++ b/components/esp_pm/test_apps/esp_pm/main/test_pm.c @@ -48,21 +48,8 @@ TEST_CASE("Can dump power management lock stats", "[pm]") static void switch_freq(int mhz) { int xtal_freq_mhz = esp_clk_xtal_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + + esp_pm_config_t pm_config = { .max_freq_mhz = mhz, .min_freq_mhz = MIN(mhz, xtal_freq_mhz), }; @@ -105,21 +92,7 @@ static void light_sleep_enable(void) int cur_freq_mhz = esp_clk_cpu_freq() / MHZ; int xtal_freq = esp_clk_xtal_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + esp_pm_config_t pm_config = { .max_freq_mhz = cur_freq_mhz, .min_freq_mhz = xtal_freq, .light_sleep_enable = true @@ -131,21 +104,7 @@ static void light_sleep_disable(void) { int cur_freq_mhz = esp_clk_cpu_freq() / MHZ; -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32H4 - esp_pm_config_esp32h4_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + esp_pm_config_t pm_config = { .max_freq_mhz = cur_freq_mhz, .min_freq_mhz = cur_freq_mhz, }; diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index d48a77d466..05a845a494 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -159,7 +159,6 @@ INPUT = \ $(PROJECT_PATH)/components/esp_netif/include/esp_netif_sntp.h \ $(PROJECT_PATH)/components/esp_partition/include/esp_partition.h \ $(PROJECT_PATH)/components/esp_phy/include/esp_phy_init.h \ - $(PROJECT_PATH)/components/esp_pm/include/$(IDF_TARGET)/pm.h \ $(PROJECT_PATH)/components/esp_pm/include/esp_pm.h \ $(PROJECT_PATH)/components/esp_ringbuf/include/freertos/ringbuf.h \ $(PROJECT_PATH)/components/esp_rom/include/esp_rom_sys.h \ diff --git a/docs/en/api-reference/system/power_management.rst b/docs/en/api-reference/system/power_management.rst index 0c830d50f0..b43e721b07 100644 --- a/docs/en/api-reference/system/power_management.rst +++ b/docs/en/api-reference/system/power_management.rst @@ -25,7 +25,7 @@ Power management can be enabled at compile time, using the option :ref:`CONFIG_P Enabling power management features comes at the cost of increased interrupt latency. Extra latency depends on a number of factors, such as the CPU frequency, single/dual core mode, whether or not frequency switch needs to be done. Minimum extra latency is 0.2 us (when the CPU frequency is 240 MHz and frequency scaling is not enabled). Maximum extra latency is 40 us (when frequency scaling is enabled, and a switch from 40 MHz to 80 MHz is performed on interrupt entry). -Dynamic frequency scaling (DFS) and automatic light sleep can be enabled in an application by calling the function :cpp:func:`esp_pm_configure`. Its argument is a structure defining the frequency scaling settings, :cpp:class:`esp_pm_config_{IDF_TARGET_PATH_NAME}_t`. In this structure, three fields need to be initialized: +Dynamic frequency scaling (DFS) and automatic light sleep can be enabled in an application by calling the function :cpp:func:`esp_pm_configure`. Its argument is a structure defining the frequency scaling settings, :cpp:class:`esp_pm_config_t`. In this structure, three fields need to be initialized: - ``max_freq_mhz``: Maximum CPU frequency in MHz, i.e., the frequency used when the ``ESP_PM_CPU_FREQ_MAX`` lock is acquired. This field will usually be set to the default CPU frequency. - ``min_freq_mhz``: Minimum CPU frequency in MHz, i.e., the frequency used when only the ``ESP_PM_APB_FREQ_MAX`` lock is acquired. This field can be set to the XTAL frequency value, or the XTAL frequency divided by an integer. Note that 10 MHz is the lowest frequency at which the default REF_TICK clock of 1 MHz can be generated. @@ -137,5 +137,4 @@ API Reference ------------- .. include-build-file:: inc/esp_pm.inc -.. include-build-file:: inc/pm.inc diff --git a/docs/zh_CN/api-reference/system/power_management.rst b/docs/zh_CN/api-reference/system/power_management.rst index e199d07c24..106fa9efbb 100644 --- a/docs/zh_CN/api-reference/system/power_management.rst +++ b/docs/zh_CN/api-reference/system/power_management.rst @@ -25,7 +25,7 @@ ESP-IDF 中集成的电源管理算法可以根据应用程序组件的需求, 启用电源管理功能将会增加中断延迟。额外延迟与多个因素有关,例如:CPU 频率、单/双核模式、是否需要进行频率切换等。CPU 频率为 240 MHz 且未启用频率调节时,最小额外延迟为 0.2 us;如果启用频率调节,且在中断入口将频率由 40 MHz 调节至 80 MHz,则最大额外延迟为 40 us。 -通过调用 :cpp:func:`esp_pm_configure` 函数可以在应用程序中启用动态调频 (DFS) 功能和自动 Light-sleep 模式。此函数的参数 :cpp:class:`esp_pm_config_{IDF_TARGET_PATH_NAME}_t` 定义了频率调节的相关设置。在此参数结构中,需要初始化以下三个字段: +通过调用 :cpp:func:`esp_pm_configure` 函数可以在应用程序中启用动态调频 (DFS) 功能和自动 Light-sleep 模式。此函数的参数 :cpp:class:`esp_pm_config_t` 定义了频率调节的相关设置。在此参数结构中,需要初始化以下三个字段: - ``max_freq_mhz``:最大 CPU 频率 (MHz),即获取 ``ESP_PM_CPU_FREQ_MAX`` 锁后所使用的频率。该字段通常设置为 :ref:`CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ`。 - ``min_freq_mhz``:最小 CPU 频率 (MHz),即仅获取 ``ESP_PM_APB_FREQ_MAX`` 锁后所使用的频率。该字段可设置为晶振 (XTAL) 频率值,或者 XTAL 频率值除以整数。注意,10 MHz 是生成 1 MHz 的 REF_TICK 默认时钟所需的最小频率。 @@ -137,5 +137,4 @@ API 参考 ------------- .. include-build-file:: inc/esp_pm.inc -.. include-build-file:: inc/pm.inc diff --git a/examples/wifi/itwt/main/itwt.c b/examples/wifi/itwt/main/itwt.c index 8ce6db7e26..23a60a3128 100644 --- a/examples/wifi/itwt/main/itwt.c +++ b/examples/wifi/itwt/main/itwt.c @@ -254,7 +254,7 @@ void app_main(void) // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. - esp_pm_config_esp32c6_t pm_config = { + esp_pm_config_t pm_config = { .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, #if CONFIG_FREERTOS_USE_TICKLESS_IDLE diff --git a/examples/wifi/power_save/main/power_save.c b/examples/wifi/power_save/main/power_save.c index bd39b47d76..780a902ead 100644 --- a/examples/wifi/power_save/main/power_save.c +++ b/examples/wifi/power_save/main/power_save.c @@ -95,19 +95,7 @@ void app_main(void) // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled. -#if CONFIG_IDF_TARGET_ESP32 - esp_pm_config_esp32_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S2 - esp_pm_config_esp32s2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C3 - esp_pm_config_esp32c3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32S3 - esp_pm_config_esp32s3_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C2 - esp_pm_config_esp32c2_t pm_config = { -#elif CONFIG_IDF_TARGET_ESP32C6 - esp_pm_config_esp32c6_t pm_config = { -#endif + esp_pm_config_t pm_config = { .max_freq_mhz = CONFIG_EXAMPLE_MAX_CPU_FREQ_MHZ, .min_freq_mhz = CONFIG_EXAMPLE_MIN_CPU_FREQ_MHZ, #if CONFIG_FREERTOS_USE_TICKLESS_IDLE