[bsp][stm32] fix eth bug

This commit is contained in:
SummerGift 2018-12-26 18:15:17 +08:00
parent 840eff05ca
commit 11dfedecdc
1 changed files with 13 additions and 15 deletions

View File

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