代码后增加这些
/* Set the link callback function, this function is called on change of link status*/
netif_set_link_callback(&gnetif, ethernetif_update_config);
/* create a binary semaphore used for informing ethernetif of frame reception */
osSemaphoreDef(Netif_SEM);
Netif_LinkSemaphore = osSemaphoreCreate(osSemaphore(Netif_SEM) , 1 );
另外再增加回调函数
/**
* @brief This function notify user about link status changement.
* @param netif: the network interface
* @retval None
*/
void ethernetif_notify_conn_changed(struct netif *netif)
{
/* NOTE : This is function could be implemented in user file
when the callback is needed,
*/
if(netif_is_link_up(netif))
{
/* When the netif is fully configured this function must be called.*/
netif_set_up(netif);
}
else
{
/* When the netif link is down this function must be called.*/
netif_set_down(netif);
}
}