diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index e8357997b7..c68f3aea86 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -447,7 +447,13 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags) } #endif - if (!deep_sleep) { + if (deep_sleep) { + extern bool esp_phy_is_initialized(void); + if (esp_phy_is_initialized()){ + extern void phy_close_rf(void); + phy_close_rf(); + } + } else { misc_modules_sleep_prepare(); } diff --git a/components/esp_phy/include/esp_phy_init.h b/components/esp_phy/include/esp_phy_init.h index bcf3e289d3..1422b43245 100644 --- a/components/esp_phy/include/esp_phy_init.h +++ b/components/esp_phy/include/esp_phy_init.h @@ -150,6 +150,12 @@ esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_da */ esp_err_t esp_phy_erase_cal_data_in_nvs(void); +/** + * @brief Get phy initialize status + * @return return true if phy is already initialized. + */ +bool esp_phy_is_initialized(void); + /** * @brief Enable PHY and RF module * diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 664e89b6a6..08e67003d2 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -224,6 +224,11 @@ static inline void phy_digital_regs_load(void) } } +bool esp_phy_is_initialized(void) +{ + return s_is_phy_calibrated; +} + void esp_phy_enable(void) { _lock_acquire(&s_phy_access_lock); diff --git a/docs/en/api-reference/system/sleep_modes.rst b/docs/en/api-reference/system/sleep_modes.rst index 792038c1ee..8374cc442f 100644 --- a/docs/en/api-reference/system/sleep_modes.rst +++ b/docs/en/api-reference/system/sleep_modes.rst @@ -31,7 +31,7 @@ Once wakeup sources are configured, the application can enter sleep mode using : Wi-Fi/Bluetooth and Sleep Modes --------------------------------- - In Deep-sleep and Light-sleep modes, the wireless peripherals are powered down. Before entering Deep-sleep or Light-sleep modes, the application must disable Wi-Fi and Bluetooth using the appropriate calls (i.e., :cpp:func:`esp_bluedroid_disable`, :cpp:func:`esp_bt_controller_disable`, :cpp:func:`esp_wifi_stop`). Wi-Fi and Bluetooth connections will not be maintained in Deep-sleep or Light-sleep mode, even if these functions are not called. + In Deep-sleep and Light-sleep modes, the wireless peripherals are powered down. Before entering Light-sleep modes, the application must disable Wi-Fi and Bluetooth using the appropriate calls (i.e., :cpp:func:`esp_bluedroid_disable`, :cpp:func:`esp_bt_controller_disable`, :cpp:func:`esp_wifi_stop`). In both Deep-sleep and Light-sleep modes, Wi-Fi and Bluetooth connection cannot be maintained. .. only:: not SOC_BT_SUPPORTED diff --git a/docs/zh_CN/api-reference/system/sleep_modes.rst b/docs/zh_CN/api-reference/system/sleep_modes.rst index 15f65ff100..e1245c2a6f 100644 --- a/docs/zh_CN/api-reference/system/sleep_modes.rst +++ b/docs/zh_CN/api-reference/system/sleep_modes.rst @@ -38,7 +38,7 @@ Light-sleep 和 Deep-sleep 模式有多种唤醒源。这些唤醒源也可以 睡眠模式下的 Wi-Fi 功能 -------------------------- - 在 Light-sleep 和 Deep-sleep 模式下,无线外设会被断电。因此,在进入这两种睡眠模式前,应用程序必须调用恰当的函数 (:cpp:func:`esp_wifi_stop`) 来禁用 Wi-Fi。在 Light-sleep 或 Deep-sleep 模式下,即使不调用此函数也无法连接 Wi-Fi。 + 在 Light-sleep 和 Deep-sleep 模式下,无线外设会被断电。因此,在进入 Light-sleep 模式前,应用程序必须调用恰当的函数 (:cpp:func:`esp_wifi_stop`) 来禁用 Wi-Fi。在 Light-sleep 和 Deep-sleep 模式下均无法保持 Wi-Fi 的连接。 如需保持 Wi-Fi 连接,请启用 Wi-Fi Modem-sleep 模式和自动 Light-sleep 模式(请参阅 :doc:`电源管理 API `)。在这两种模式下,Wi-Fi 驱动程序发出请求时,系统将自动从睡眠中被唤醒,从而保持与 AP 的连接。