浏览代码

[bsp][stm32] fix eth bug

SummerGift 6 年之前
父节点
当前提交
11dfedecdc
共有 1 个文件被更改,包括 13 次插入15 次删除
  1. 13 15
      bsp/stm32/libraries/HAL_Drivers/drv_eth.c

+ 13 - 15
bsp/stm32/libraries/HAL_Drivers/drv_eth.c

@@ -96,16 +96,9 @@ static rt_err_t rt_stm32_eth_init(rt_device_t dev)
     HAL_ETH_DeInit(&EthHandle);
 
     /* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
-    if (HAL_ETH_Init(&EthHandle) == HAL_OK)
-    {
-        LOG_D("emac hardware init sucess");
-    }
-    else
-    {
-        LOG_E("emac hardware init faild");
-        return -RT_ERROR;
-    }
-
+    HAL_ETH_Init(&EthHandle);
+    LOG_D("eth hardware init finished");
+    
     /* Initialize Tx Descriptors list: Chain Mode */
     HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, Tx_Buff, ETH_TXBUFNB);
 
@@ -543,7 +536,7 @@ static int rt_hw_stm32_eth_init(void)
     if (Rx_Buff == RT_NULL)
     {
         LOG_E("No memory");
-        state = RT_ENOMEM;
+        state = -RT_ENOMEM;
         goto __exit;
     }
 
@@ -551,7 +544,7 @@ static int rt_hw_stm32_eth_init(void)
     if (Rx_Buff == RT_NULL)
     {
         LOG_E("No memory");
-        state = RT_ENOMEM;
+        state = -RT_ENOMEM;
         goto __exit;
     }
 
@@ -559,7 +552,7 @@ static int rt_hw_stm32_eth_init(void)
     if (DMARxDscrTab == RT_NULL)
     {
         LOG_E("No memory");
-        state = RT_ENOMEM;
+        state = -RT_ENOMEM;
         goto __exit;
     }
 
@@ -567,7 +560,7 @@ static int rt_hw_stm32_eth_init(void)
     if (DMATxDscrTab == RT_NULL)
     {
         LOG_E("No memory");
-        state = RT_ENOMEM;
+        state = -RT_ENOMEM;
         goto __exit;
     }
 
@@ -607,7 +600,8 @@ static int rt_hw_stm32_eth_init(void)
     else
     {
         LOG_E("emac device init faild: %d", state);
-        return -RT_ERROR;
+        state = -RT_ERROR;
+        goto __exit;
     }
 
     /* start phy monitor */
@@ -622,6 +616,10 @@ static int rt_hw_stm32_eth_init(void)
     {
         rt_thread_startup(tid);
     }
+    else
+    {
+        state = -RT_ERROR;
+    }
 __exit:
     if (state != RT_EOK)
     {