deep sleep: close rf to optimize sleep current

This commit is contained in:
wuzhenghui 2023-03-13 20:45:48 +08:00
parent 568dd3d823
commit 64d5421d8b
5 changed files with 20 additions and 3 deletions

View File

@ -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();
}

View File

@ -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
*

View File

@ -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);

View File

@ -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

View File

@ -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 <power_management>`。在这两种模式下Wi-Fi 驱动程序发出请求时,系统将自动从睡眠中被唤醒,从而保持与 AP 的连接。