mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 18:10:57 +02:00
Merge branch 'enhancement/protect_from_odd_phy_disable_operations_by_single_modem_v5.2' into 'release/v5.2'
esp_phy: Add protection of consecutive disable operations by single modem source (v5.2) See merge request espressif/esp-idf!41294
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include "hal/temperature_sensor_ll.h"
|
||||
#endif
|
||||
|
||||
static const char* TAG = "phy_comm";
|
||||
|
||||
static volatile uint16_t s_phy_modem_flag = 0;
|
||||
|
||||
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
|
||||
@@ -114,6 +116,16 @@ void phy_track_pll_deinit(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *phy_get_modem_str(esp_phy_modem_t modem)
|
||||
{
|
||||
switch (modem) {
|
||||
case PHY_MODEM_WIFI: return "Wi-Fi";
|
||||
case PHY_MODEM_BT: return "Bluetooth";
|
||||
case PHY_MODEM_IEEE802154: return "IEEE 802.15.4";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
void phy_set_modem_flag(esp_phy_modem_t modem)
|
||||
{
|
||||
s_phy_modem_flag |= modem;
|
||||
@@ -121,6 +133,9 @@ void phy_set_modem_flag(esp_phy_modem_t modem)
|
||||
|
||||
void phy_clr_modem_flag(esp_phy_modem_t modem)
|
||||
{
|
||||
if ((s_phy_modem_flag & modem) == 0) {
|
||||
ESP_LOGW(TAG, "Clear the flag of %s before it's set", phy_get_modem_str(modem));
|
||||
}
|
||||
s_phy_modem_flag &= ~modem;
|
||||
}
|
||||
|
||||
|
@@ -352,8 +352,9 @@ void esp_phy_disable(esp_phy_modem_t modem)
|
||||
#if CONFIG_ESP_PHY_RECORD_USED_TIME
|
||||
phy_record_time(false, modem);
|
||||
#endif
|
||||
esp_phy_modem_t saved_modem = phy_get_modem_flag();
|
||||
phy_clr_modem_flag(modem);
|
||||
if (phy_get_modem_flag() == 0) {
|
||||
if (saved_modem == modem) {
|
||||
// ESP32 will track pll in the wifi/BT modem interrupt handler.
|
||||
#if !CONFIG_IDF_TARGET_ESP32 && !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
|
||||
phy_track_pll_deinit();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -134,8 +134,9 @@ void esp_phy_disable(esp_phy_modem_t modem)
|
||||
#if CONFIG_ESP_PHY_RECORD_USED_TIME
|
||||
phy_record_time(false, modem);
|
||||
#endif
|
||||
esp_phy_modem_t saved_modem = phy_get_modem_flag();
|
||||
phy_clr_modem_flag(modem);
|
||||
if (phy_get_modem_flag() == 0) {
|
||||
if (saved_modem == modem) {
|
||||
|
||||
#if !CONFIG_ESP_PHY_DISABLE_PLL_TRACK
|
||||
phy_track_pll_deinit();
|
||||
|
Reference in New Issue
Block a user