uint8_t addr[6];
uint8_t *rx_buf[CONFIG_ETH_DMA_RX_BUFFER_NUM];
uint8_t *tx_buf[CONFIG_ETH_DMA_TX_BUFFER_NUM];
+ bool isr_need_yield;
} emac_esp32_t;
static esp_err_t emac_esp32_set_mediator(esp_eth_mac_t *mac, esp_eth_mediator_t *eth)
return ESP_OK;
}
+void emac_esp32_isr_handler(void *args)
+{
+ emac_hal_context_t *hal = (emac_hal_context_t *)args;
+ emac_esp32_t *emac = __containerof(hal, emac_esp32_t, hal);
+ emac_hal_isr(args);
+ if (emac->isr_need_yield) {
+ emac->isr_need_yield = false;
+ portYIELD_FROM_ISR();
+ }
+}
+
esp_eth_mac_t *esp_eth_mac_new_esp32(const eth_mac_config_t *config)
{
esp_eth_mac_t *ret = NULL;
emac->parent.transmit = emac_esp32_transmit;
emac->parent.receive = emac_esp32_receive;
/* Interrupt configuration */
- MAC_CHECK(esp_intr_alloc(ETS_ETH_MAC_INTR_SOURCE, ESP_INTR_FLAG_IRAM, emac_hal_isr,
+ MAC_CHECK(esp_intr_alloc(ETS_ETH_MAC_INTR_SOURCE, ESP_INTR_FLAG_IRAM, emac_esp32_isr_handler,
&emac->hal, &(emac->intr_hdl)) == ESP_OK,
"alloc emac interrupt failed", err_intr, NULL);
/* create counting semaphore */
BaseType_t high_task_wakeup;
/* send message to rx thread */
xSemaphoreGiveFromISR(emac->rx_counting_sem, &high_task_wakeup);
- if (high_task_wakeup != pdFALSE) {
- portYIELD_FROM_ISR();
+ if (high_task_wakeup == pdTRUE) {
+ emac->isr_need_yield = true;
}
}
BaseType_t high_task_wakeup;
/* send message to rx thread */
xSemaphoreGiveFromISR(emac->rx_counting_sem, &high_task_wakeup);
- if (high_task_wakeup != pdFALSE) {
- portYIELD_FROM_ISR();
+ if (high_task_wakeup == pdTRUE) {
+ emac->isr_need_yield = true;
}
}