Added two functions

Fork of lwip-eth by mbed official

Files at this revision

API Documentation at this revision

Comitter:
guzbi
Date:
Fri Dec 02 07:46:12 2016 +0000
Parent:
31:da93f0f73711
Commit message:
vgtsbytv

Changed in this revision

arch/TARGET_Freescale/k64f_emac.c Show annotated file Show diff for this revision Revisions of this file
arch/TARGET_Freescale/k64f_emac_config.h Show annotated file Show diff for this revision Revisions of this file
diff -r da93f0f73711 -r 9daadcdfbeb3 arch/TARGET_Freescale/k64f_emac.c
--- 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)
diff -r da93f0f73711 -r 9daadcdfbeb3 arch/TARGET_Freescale/k64f_emac_config.h
--- 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)
 }