mirror of https://github.com/ARMmbed/mbed-os.git
EMAC: check link status callback is set
Nanostack doesn't set the link status callback. Make sure the two example drivers don't crash if it isn't set.pull/6847/head
parent
ef68eb8b4d
commit
5472a9703f
|
|
@ -488,7 +488,7 @@ void K64F_EMAC::phy_task()
|
||||||
PHY_GetLinkSpeedDuplex(ENET, phyAddr, &crt_state.speed, &crt_state.duplex);
|
PHY_GetLinkSpeedDuplex(ENET, phyAddr, &crt_state.speed, &crt_state.duplex);
|
||||||
|
|
||||||
// Compare with previous state
|
// Compare with previous state
|
||||||
if (crt_state.connected != prev_state.connected) {
|
if (crt_state.connected != prev_state.connected && emac_link_state_cb) {
|
||||||
emac_link_state_cb(crt_state.connected);
|
emac_link_state_cb(crt_state.connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -347,12 +347,15 @@ void STM32_EMAC::thread_function(void* pvParameters)
|
||||||
void STM32_EMAC::phy_task()
|
void STM32_EMAC::phy_task()
|
||||||
{
|
{
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
|
|
||||||
if (HAL_ETH_ReadPHYRegister(&EthHandle, PHY_BSR, &status) == HAL_OK) {
|
if (HAL_ETH_ReadPHYRegister(&EthHandle, PHY_BSR, &status) == HAL_OK) {
|
||||||
|
if (emac_link_state_cb) {
|
||||||
if ((status & PHY_LINKED_STATUS) && !(phy_status & PHY_LINKED_STATUS)) {
|
if ((status & PHY_LINKED_STATUS) && !(phy_status & PHY_LINKED_STATUS)) {
|
||||||
emac_link_state_cb(true);
|
emac_link_state_cb(true);
|
||||||
} else if (!(status & PHY_LINKED_STATUS) && (phy_status & PHY_LINKED_STATUS)) {
|
} else if (!(status & PHY_LINKED_STATUS) && (phy_status & PHY_LINKED_STATUS)) {
|
||||||
emac_link_state_cb(false);
|
emac_link_state_cb(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
phy_status = status;
|
phy_status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue