From 78ba8d406d99ca8b1021e530a86d913b7fc26262 Mon Sep 17 00:00:00 2001 From: xueyunfei Date: Wed, 20 Jul 2022 15:12:23 +0800 Subject: [PATCH] bugfix for phy init failed when wifi deinit --- components/esp_wifi/src/phy_init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/esp_wifi/src/phy_init.c b/components/esp_wifi/src/phy_init.c index cbacc34c73..8985a10940 100644 --- a/components/esp_wifi/src/phy_init.c +++ b/components/esp_wifi/src/phy_init.c @@ -66,6 +66,8 @@ static DRAM_ATTR struct { /* Indicate PHY is calibrated or not */ static bool s_is_phy_calibrated = false; +static bool s_is_phy_reg_stored = false; + /* Reference count of enabling PHY */ static uint8_t s_phy_access_ref = 0; @@ -220,12 +222,13 @@ static inline void phy_digital_regs_store(void) { if (s_phy_digital_regs_mem != NULL) { phy_dig_reg_backup(true, s_phy_digital_regs_mem); + s_is_phy_reg_stored = true; } } static inline void phy_digital_regs_load(void) { - if (s_phy_digital_regs_mem != NULL) { + if (s_is_phy_reg_stored && s_phy_digital_regs_mem != NULL) { phy_dig_reg_backup(false, s_phy_digital_regs_mem); } } @@ -328,7 +331,7 @@ void esp_phy_pd_mem_deinit(void) s_phy_backup_mem_ref--; if (s_phy_backup_mem_ref == 0) { - s_is_phy_calibrated = false; + s_is_phy_reg_stored = false; free(s_phy_digital_regs_mem); s_phy_digital_regs_mem = NULL; }