Kaynağa Gözat

Merge branch 'bugfix/phy_critical_v3.3' into 'release/v3.3'

fix bug that phy_enter_critical cannot effect on dual-core

See merge request espressif/esp-idf!6866
Jiang Jiang Jian 6 yıl önce
ebeveyn
işleme
bf80d8211e
1 değiştirilmiş dosya ile 15 ekleme ve 2 silme
  1. 15 2
      components/esp32/phy_init.c

+ 15 - 2
components/esp32/phy_init.c

@@ -68,14 +68,27 @@ static _lock_t s_modem_sleep_lock;
 /* time stamp updated when the PHY/RF is turned on */
 static int64_t s_phy_rf_en_ts = 0;
 
+static DRAM_ATTR portMUX_TYPE s_phy_int_mux = portMUX_INITIALIZER_UNLOCKED;
+
 uint32_t IRAM_ATTR phy_enter_critical(void)
 {
-    return portENTER_CRITICAL_NESTED();
+    if (xPortInIsrContext()) {
+        portENTER_CRITICAL_ISR(&s_phy_int_mux);
+    } else {
+        portENTER_CRITICAL(&s_phy_int_mux);
+    }
+    // Interrupt level will be stored in current tcb, so always return zero.
+    return 0;
 }
 
 void IRAM_ATTR phy_exit_critical(uint32_t level)
 {
-    portEXIT_CRITICAL_NESTED(level);
+    // Param level don't need any more, ignore it.
+    if (xPortInIsrContext()) {
+        portEXIT_CRITICAL_ISR(&s_phy_int_mux);
+    } else {
+        portEXIT_CRITICAL(&s_phy_int_mux);
+    }
 }
 
 int64_t esp_phy_rf_get_on_ts(void)