Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of lwip-eth by
Revision 34:9daadcdfbeb3, committed 2016-12-02
- Comitter:
- guzbi
- Date:
- Fri Dec 02 07:46:12 2016 +0000
- Parent:
- 31:da93f0f73711
- Commit message:
- vgtsbytv
Changed in this revision
--- a/arch/TARGET_Freescale/k64f_emac.c Tue May 03 00:16:23 2016 +0100 +++ b/arch/TARGET_Freescale/k64f_emac.c Fri Dec 02 07:46:12 2016 +0000 @@ -503,6 +503,30 @@ return (int)connection_status; } +int phy_get_duplex() { + bool connection_status; + PHY_STATE crt_state = {STATE_UNKNOWN, (phy_speed_t)STATE_UNKNOWN, (phy_duplex_t)STATE_UNKNOWN}; + uint32_t phyAddr = 0; + + PHY_GetLinkStatus(ENET, phyAddr, &connection_status); + crt_state.connected = connection_status ? 1 : 0; + PHY_GetLinkSpeedDuplex(ENET, phyAddr, &crt_state.speed, &crt_state.duplex); + + return (int)crt_state.duplex; +} + +int phy_get_speed() { + bool connection_status; + PHY_STATE crt_state = {STATE_UNKNOWN, (phy_speed_t)STATE_UNKNOWN, (phy_duplex_t)STATE_UNKNOWN}; + uint32_t phyAddr = 0; + + PHY_GetLinkStatus(ENET, phyAddr, &connection_status); + crt_state.connected = connection_status ? 1 : 0; + PHY_GetLinkSpeedDuplex(ENET, phyAddr, &crt_state.speed, &crt_state.duplex); + + return (int)crt_state.speed; +} + static void k64f_phy_task(void *data) { struct netif *netif = (struct netif*)data; bool connection_status; @@ -510,6 +534,7 @@ PHY_STATE prev_state; uint32_t phyAddr = 0; uint32_t rcr = 0; + prev_state = crt_state; while (true) { @@ -518,7 +543,8 @@ crt_state.connected = connection_status ? 1 : 0; // Get the actual PHY link speed PHY_GetLinkSpeedDuplex(ENET, phyAddr, &crt_state.speed, &crt_state.duplex); - + //printf("Speed: %d\n", crt_state.speed); + //printf("Duplex: %d\n", crt_state.duplex); // Compare with previous state if (crt_state.connected != prev_state.connected) { if (crt_state.connected)
--- a/arch/TARGET_Freescale/k64f_emac_config.h Tue May 03 00:16:23 2016 +0100 +++ b/arch/TARGET_Freescale/k64f_emac_config.h Fri Dec 02 07:46:12 2016 +0000 @@ -42,6 +42,8 @@ #endif int phy_link_status(void); +int phy_get_duplex(void); +int phy_get_speed(void); #if defined(__cplusplus) }