phy: fix phy pwdet and tsens power cannot be set twice issue

Closes https://github.com/espressif/esp-idf/issues/11627
This commit is contained in:
Armando 2023-06-09 20:26:37 +08:00
parent 213504238f
commit 21ce7c16a0

View File

@ -18,6 +18,8 @@
*/
static bool s_wifi_adc_xpd_flag;
static bool s_wifi_pwdet_xpd_flag;
static bool s_wifi_tsens_xpd_flag;
void include_esp_phy_override(void)
{
@ -55,6 +57,12 @@ IRAM_ATTR void phy_i2c_exit_critical(void)
void phy_set_pwdet_power(bool en)
{
if (s_wifi_pwdet_xpd_flag == en) {
/* ignore repeated calls to phy_set_pwdet_power when the state is already correct */
return;
}
s_wifi_pwdet_xpd_flag = en;
if (en) {
sar_periph_ctrl_pwdet_power_acquire();
} else {
@ -64,6 +72,12 @@ void phy_set_pwdet_power(bool en)
void phy_set_tsens_power(bool en)
{
if (s_wifi_tsens_xpd_flag == en) {
/* ignore repeated calls to phy_set_tsens_power when the state is already correct */
return;
}
s_wifi_tsens_xpd_flag = en;
if (en) {
temperature_sensor_power_acquire();
} else {