From 489701eb2d424790f85fee1d84b2665769274405 Mon Sep 17 00:00:00 2001 From: shangke Date: Fri, 6 Jan 2017 13:49:42 +0800 Subject: [PATCH] ethernet : fix sometimes ethernet init fail bug --- components/ethernet/emac_main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/ethernet/emac_main.c b/components/ethernet/emac_main.c index 20d428cf7b..06e641453b 100644 --- a/components/ethernet/emac_main.c +++ b/components/ethernet/emac_main.c @@ -628,6 +628,7 @@ static void emac_start(void *param) cmd->err = EMAC_CMD_OK; emac_enable_clk(true); + emac_reset(); emac_macaddr_init(); emac_check_mac_addr(); @@ -839,7 +840,9 @@ esp_err_t IRAM_ATTR emac_post(emac_sig_t sig, emac_par_t par) } } } else { + portENTER_CRITICAL(&g_emac_mux); emac_sig_cnt[sig]++; + portEXIT_CRITICAL(&g_emac_mux); emac_event_t evt; evt.sig = sig; evt.par = par; @@ -898,10 +901,8 @@ esp_err_t esp_eth_init(eth_config_t *config) emac_xqueue = xQueueCreate(EMAC_EVT_QNUM, sizeof(emac_event_t)); xTaskCreate(emac_task, "emacT", 2048, NULL, EMAC_TASK_PRIORITY, &emac_task_hdl); - esp_intr_alloc(ETS_ETH_MAC_INTR_SOURCE, 0, emac_process_intr, NULL, NULL); - - emac_reset(); emac_enable_clk(false); + esp_intr_alloc(ETS_ETH_MAC_INTR_SOURCE, 0, emac_process_intr, NULL, NULL); emac_config.emac_status = EMAC_RUNTIME_INIT;