Hi everyone,
I'm using a custom board based on RT1064, with MCUXpresso 11.8.0 and SDK 2.12.0.
The board uses a LAN8720A ethernet tranceiver that is working fine.
I have a trouble when the system starts with then LAN cable disconnected: if I connect the cable after the init is completed, a ping packet from another device is not answered.
Here is a summary of my code:
tcpip_init( NULL, NULL );
...
netif_add( &NetIfLAN, &IPAddress, &NetMask, &DGAddress, &EthConfig, ethernetif0_init, tcpip_input );
netif_set_default( &NetIfLAN );
StartNetworkSupervisor();
void NetWorkSupervisor( void )
{
bool link, oldlink = false;
while( 1 )
{
if( PHY_GetLinkStatus( EthConfig.phyHandle, &link ) != kStatus_Success )
link = false;
if( link != oldlink )
{
if( link != false )
{
PRINTF( "LINK UP\n" );
sys_lock_tcpip_core();
//netif_set_link_up( &NetIfLAN );
netif_set_up( &NetIfLAN );
sys_unlock_tcpip_core();
}
else
{
PRINTF( "LINK DOWN\n" );
sys_lock_tcpip_core();
//netif_set_down( &NetIfLAN );
netif_set_link_down( &NetIfLAN );
sys_unlock_tcpip_core();
}
oldlink = link;
}
...
}
}
In the terminal I can see the "LINK UP" and "LINK DOWN" strings, so the connection and disconnection events are handled. I tried both with and without the netif_set_link_up() and netif_set_link_down() calls, but the behaviour is the same.
Does anyone have some suggestion?
Many thanks
Biafra