Merge branch 'bugfix/close_rf_in_deep_sleep_backport_v4.3' into 'release/v4.3'

deep sleep: further optimize sleep current if RF is enabled (backport v4.3)

See merge request espressif/esp-idf!22736
This commit is contained in:
Jiang Jiang Jian
2023-03-30 17:36:59 +08:00
8 changed files with 19 additions and 6 deletions

View File

@ -180,7 +180,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg)
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG,
RTC_CNTL_CKGEN_I2C_PU | RTC_CNTL_PLL_I2C_PU |
RTC_CNTL_RFRX_PBUS_PU | RTC_CNTL_TXRF_I2C_PU);
CLEAR_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_BB_I2C_FORCE_PU);
} else {
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_DG_WRAP_PD_EN);
}

View File

@ -112,7 +112,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg)
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG,
RTC_CNTL_CKGEN_I2C_PU | RTC_CNTL_PLL_I2C_PU |
RTC_CNTL_RFRX_PBUS_PU | RTC_CNTL_TXRF_I2C_PU);
CLEAR_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_BB_I2C_FORCE_PU);
} else {
SET_PERI_REG_MASK(RTC_CNTL_BIAS_CONF_REG, RTC_CNTL_DG_VDD_DRV_B_SLP_EN);
REG_SET_FIELD(RTC_CNTL_BIAS_CONF_REG, RTC_CNTL_DG_VDD_DRV_B_SLP, RTC_CNTL_DG_VDD_DRV_B_SLP_DEFAULT);

View File

@ -111,7 +111,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg)
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG,
RTC_CNTL_CKGEN_I2C_PU | RTC_CNTL_PLL_I2C_PU |
RTC_CNTL_RFRX_PBUS_PU | RTC_CNTL_TXRF_I2C_PU);
CLEAR_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_BB_I2C_FORCE_PU);
} else {
SET_PERI_REG_MASK(RTC_CNTL_REG, RTC_CNTL_REGULATOR_FORCE_PU);
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_DG_WRAP_PD_EN);

View File

@ -117,7 +117,6 @@ void rtc_sleep_init(rtc_sleep_config_t cfg)
CLEAR_PERI_REG_MASK(RTC_CNTL_ANA_CONF_REG,
RTC_CNTL_CKGEN_I2C_PU | RTC_CNTL_PLL_I2C_PU |
RTC_CNTL_RFRX_PBUS_PU | RTC_CNTL_TXRF_I2C_PU);
CLEAR_PERI_REG_MASK(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_BB_I2C_FORCE_PU);
} else {
SET_PERI_REG_MASK(RTC_CNTL_REG, RTC_CNTL_REGULATOR_FORCE_PU);
CLEAR_PERI_REG_MASK(RTC_CNTL_DIG_PWC_REG, RTC_CNTL_DG_WRAP_PD_EN);

View File

@ -640,7 +640,13 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags)
rtc_sleep_low_init(s_config.rtc_clk_cal_period);
// Set state machine time for light sleep
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 {
rtc_sleep_low_init(s_config.rtc_clk_cal_period);
}

View File

@ -153,6 +153,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

@ -233,6 +233,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, application can enter sleep mode using :cpp:
WiFi/BT and sleep modes
-----------------------
In deep sleep and light sleep modes, wireless peripherals are powered down. Before entering deep sleep or light sleep modes, applications must disable WiFi and BT using appropriate calls (:cpp:func:`esp_bluedroid_disable`, :cpp:func:`esp_bt_controller_disable`, :cpp:func:`esp_wifi_stop`). WiFi and BT connections will not be maintained in deep sleep or light sleep, even if these functions are not called.
In deep sleep and light sleep modes, wireless peripherals are powered down. Before entering light sleep modes, applications must disable WiFi and BT using appropriate calls (:cpp:func:`esp_bluedroid_disable`, :cpp:func:`esp_bt_controller_disable`, :cpp:func:`esp_wifi_stop`). WiFi and BT connections will not be maintained in deep sleep or light sleep, even if these functions are not called.
.. only:: not SOC_BT_SUPPORTED