diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 1edf7950f4..c2ff063ced 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -37,6 +37,7 @@ #include "esp32c3/rom/rom_layout.h" #include "esp_timer.h" #include "esp_sleep.h" +#include "phy.h" #if CONFIG_BT_ENABLED @@ -1237,6 +1238,11 @@ esp_err_t esp_bt_controller_deinit(void) esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); #endif + /* Fix the issue caused by the power off the bt power domain. + * This issue is only on ESP32C3. + */ + phy_init_flag(); + esp_bt_power_domain_off(); free(osi_funcs_p); diff --git a/components/bt/controller/esp32s3/bt.c b/components/bt/controller/esp32s3/bt.c index 5da5ce0eaf..64e10ad4a7 100644 --- a/components/bt/controller/esp32s3/bt.c +++ b/components/bt/controller/esp32s3/bt.c @@ -1144,8 +1144,6 @@ error: esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); #endif - esp_bt_power_domain_off(); - if (osi_funcs_p != NULL) { free(osi_funcs_p); osi_funcs_p = NULL; @@ -1206,6 +1204,9 @@ esp_err_t esp_bt_controller_deinit(void) esp_unregister_mac_bb_pd_callback(btdm_mac_bb_power_down_cb); esp_unregister_mac_bb_pu_callback(btdm_mac_bb_power_up_cb); #endif + + esp_bt_power_domain_off(); + free(osi_funcs_p); osi_funcs_p = NULL; diff --git a/components/esp_phy/include/phy.h b/components/esp_phy/include/phy.h index 1d0690f356..e6aa21db50 100644 --- a/components/esp_phy/include/phy.h +++ b/components/esp_phy/include/phy.h @@ -68,6 +68,13 @@ void phy_close_rf(void); void phy_xpd_tsens(void); #endif +#if CONFIG_IDF_TARGET_ESP32C3 +/** + * @brief Update internal state of PHY when wifi deinit powers off the wifi power domain. + */ +void phy_init_flag(void); +#endif + /** * @brief Store and load PHY digital registers. * diff --git a/components/esp_phy/lib b/components/esp_phy/lib index 7586abbf59..fe7dc9599b 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit 7586abbf591ab63d609d7afeb377559deabec808 +Subproject commit fe7dc9599bd318518eccc165d9e751114e28e7d2 diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 40273d86bf..3a66d30ea3 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -19,6 +19,7 @@ #include "driver/adc2_wifi_private.h" #include "esp_coexist_internal.h" #include "esp_phy_init.h" +#include "phy.h" #if (CONFIG_ESP32_WIFI_RX_BA_WIN > CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM) #error "WiFi configuration check: WARNING, WIFI_RX_BA_WIN should not be larger than WIFI_DYNAMIC_RX_BUFFER_NUM!" @@ -124,6 +125,9 @@ esp_err_t esp_wifi_deinit(void) #if CONFIG_MAC_BB_PD esp_unregister_mac_bb_pd_callback(pm_mac_sleep); esp_unregister_mac_bb_pu_callback(pm_mac_wakeup); +#endif +#if CONFIG_IDF_TARGET_ESP32C3 + phy_init_flag(); #endif esp_wifi_power_domain_off(); return err;