|
可能是网速自动协商失败;
cubemx中设置LWIP_NETIF_STATUS_CALLBACK enable ; LWIP_NETIF_LINK_CALLBACK enable;
ethernetif.c中low_level_init()函数中:
/* Initialize the LAN8742 ETH PHY */
LAN8742_Init(&LAN8742);
if (hal_eth_init_status == HAL_OK)
{
//PHYLinkState = LAN8742_GetLinkState(&LAN8742); //original code
if(LAN8742_StartAutoNego(&LAN8742) != LAN8742_STATUS_OK){
printf("\nLAN8742_StartAutoNego_err ");
}
PHYLinkState = LAN8742_GetLinkState(&LAN8742);
printf("\nPHYLinkState=%d ",PHYLinkState);
/* Get link state */
if(PHYLinkState <= LAN8742_STATUS_LINK_DOWN)
{
netif_set_link_down(netif);
netif_set_down(netif);
}
else
{
switch (PHYLinkState)
{
自动协商后,获取状态,如果自动协商失败,link_down set_down;手动设置网速模式duplex与网速speed,然后set_up与link_up; |
|