初级会员
- 积分
- 83
- 金钱
- 83
- 注册时间
- 2013-9-7
- 在线时间
- 24 小时
|
发表于 2020-5-9 20:11:36
|
显示全部楼层
uint16_t link_status_new = 0;
uint16_t link_status_old = 0;
void Eth_Link_ITHandler(struct netif *netif)
{
//static u8 i=0;
link_status_new = ((ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_BSR)) & (PHY_AutoNego_Complete | PHY_Linked_Status));
//printf("link_status_new is %d\r\n",link_status_new);
if(EthStatus != ETH_SUCCESS)
{
printf("EthStatus != ETH_SUCCESS \r\n");
if((ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_BSR)) & PHY_Linked_Status)
{
/* Configure Ethernet */
EthStatus = ETH_Init(Ð_InitStructure, DP83848_PHY_ADDRESS);
if(EthStatus==ETH_SUCCESS)
{
ETH_DMAITConfig(ETH_DMA_IT_NIS|ETH_DMA_IT_R,ENABLE);
printf("EthStatus == ETH_SUCCESS \r\n");
}
}
// link_status_old = ((ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_BSR)) & (PHY_AutoNego_Complete | PHY_Linked_Status));
// printf("link_status_new is %d\r\n",link_status_new);
// printf("link_status_old is %d\r\n",link_status_old);
}
else
{
if((link_status_new != 0)&&(link_status_old == 0))
{
link_status_old = link_status_new;
netif_set_link_up(netif);//set link up for re link callbalk function
printf("netif_set_link_up \r\n");
}
else if((link_status_new == 0)&&(link_status_old != 0))
{
link_status_old = link_status_new;
netif_set_link_down(netif);//set link down for re link callbalk function
printf("netif_set_link_down \r\n");
}
}
}
楼主的逻辑有一点错误才导致,不插上网线上电后再插网线导致不能正常通信,改改后就好了,还是多谢楼主了~! |
|