diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index 329f35d34e..0fe1899f3b 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -34,6 +34,7 @@ idf_component_register(SRCS "src/coexist.c" "src/wifi_netif.c" "${idf_target}/esp_adapter.c" INCLUDE_DIRS "include" "${idf_target}/include" + PRIV_REQUIRES wpa_supplicant nvs_flash esp_netif driver ${extra_priv_requires} REQUIRES esp_event PRIV_REQUIRES esp_timer esp_pm wpa_supplicant nvs_flash esp_netif ${extra_priv_requires} LDFRAGMENTS "${ldfragments}") diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index e675105653..b8aca2ce31 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -23,6 +23,7 @@ #include "esp_wpa.h" #include "esp_netif.h" #include "tcpip_adapter_compatible/tcpip_adapter_compat.h" +#include "driver/adc.h" #include "driver/adc2_wifi_private.h" #include "esp_coexist_internal.h" @@ -56,6 +57,8 @@ uint64_t g_wifi_feature_caps = #endif 0; +static bool s_wifi_adc_xpd_flag; + static const char* TAG = "wifi_init"; static void __attribute__((constructor)) s_set_default_wifi_log_level(void) @@ -251,3 +254,19 @@ void wifi_apb80m_release(void) esp_pm_lock_release(s_wifi_modem_sleep_lock); } #endif //CONFIG_PM_ENABLE + +/* Coordinate ADC power with other modules. This overrides the function from PHY lib. */ +void set_xpd_sar(bool en) +{ + if (s_wifi_adc_xpd_flag == en) { + /* ignore repeated calls to set_xpd_sar when the state is already correct */ + return; + } + + s_wifi_adc_xpd_flag = en; + if (en) { + adc_power_acquire(); + } else { + adc_power_release(); + } +}