From 3cfda14ed41d8af61fe02a690da5ad6bedbdc3ba Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Mon, 8 Nov 2021 20:52:03 +0800 Subject: [PATCH] fix the wifi scan fail issue caused by the power off the wifi power domain --- components/esp_wifi/include/phy.h | 8 ++++++++ components/esp_wifi/src/wifi_init.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/include/phy.h b/components/esp_wifi/include/phy.h index 40c3a1d499..84cbbf5b4d 100644 --- a/components/esp_wifi/include/phy.h +++ b/components/esp_wifi/include/phy.h @@ -76,6 +76,14 @@ 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_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 5cf74e723d..910fdd0164 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -26,6 +26,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!" @@ -136,7 +137,9 @@ esp_err_t esp_wifi_deinit(void) 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(); #if CONFIG_MAC_BB_PD esp_mac_bb_pd_mem_deinit();