ソースを参照

Merge branch 'bugfix/eth_dm9051_not_responding_v4.3' into 'release/v4.3'

esp_eth: Fix dm9051 Rx interrupt processing (v4.3)

See merge request espressif/esp-idf!15284
David Čermák 4 年 前
コミット
0e956b5977
1 ファイル変更7 行追加4 行削除
  1. 7 4
      components/esp_eth/src/esp_eth_mac_dm9051.c

+ 7 - 4
components/esp_eth/src/esp_eth_mac_dm9051.c

@@ -358,8 +358,8 @@ static esp_err_t emac_dm9051_start(esp_eth_mac_t *mac)
 {
     esp_err_t ret = ESP_OK;
     emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent);
-    /* enable interrupt */
-    MAC_CHECK(dm9051_register_write(emac, DM9051_IMR, IMR_ALL) == ESP_OK, "write IMR failed", err, ESP_FAIL);
+    /* enable only Rx related interrupts as others are processed synchronously */
+    MAC_CHECK(dm9051_register_write(emac, DM9051_IMR, IMR_PAR | IMR_PRI) == ESP_OK, "write IMR failed", err, ESP_FAIL);
     /* enable rx */
     uint8_t rcr = 0;
     MAC_CHECK(dm9051_register_read(emac, DM9051_RCR, &rcr) == ESP_OK, "read RCR failed", err, ESP_FAIL);
@@ -407,8 +407,11 @@ static void emac_dm9051_task(void *arg)
     uint8_t *buffer = NULL;
     uint32_t length = 0;
     while (1) {
-        // block indefinitely until some task notifies me
-        ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
+        // check if the task receives any notification
+        if (ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(1000)) == 0 &&    // if no notification ...
+            gpio_get_level(emac->int_gpio_num) == 0) {               // ...and no interrupt asserted
+            continue;                                                // -> just continue to check again
+        }
         /* clear interrupt status */
         dm9051_register_read(emac, DM9051_ISR, &status);
         dm9051_register_write(emac, DM9051_ISR, status);