From 94034246b28f5dfde6184a1346b3a7a935137e11 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Fri, 17 Mar 2023 11:39:54 +0800 Subject: [PATCH] bugfix: close rf in deep sleep prepare to reduce base current --- components/esp_phy/src/phy_init.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 62ea775656..6011bb236a 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -19,6 +19,7 @@ #include "nvs_flash.h" #include "esp_efuse.h" #include "esp_timer.h" +#include "esp_sleep.h" #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" @@ -246,8 +247,7 @@ void esp_phy_enable(void) if (s_is_phy_calibrated == false) { esp_phy_load_cal_and_init(); s_is_phy_calibrated = true; - } - else { + } else { #if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP extern bool pm_mac_modem_rf_already_enabled(void); if (!pm_mac_modem_rf_already_enabled()) { @@ -815,6 +815,8 @@ void esp_phy_load_cal_and_init(void) esp_phy_release_init_data(init_data); #endif + ESP_ERROR_CHECK(esp_deep_sleep_register_hook(&phy_close_rf)); + free(cal_data); // PHY maintains a copy of calibration data, so we can free this }