wifi: add set_xpd_sar override

Wi-Fi enables and disables ADC when exiting and entering sleep mode.
Coordinate ADC power state with other modules, using adc_power_acquire
and adc_power_release.
This commit is contained in:
Ivan Grokhotkov 2020-01-02 10:44:45 +01:00 committed by Cao Sen Miao
parent a4f81d0bd3
commit 80e7252c13
2 changed files with 20 additions and 0 deletions

View File

@ -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}")

View File

@ -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();
}
}