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.
Dependents: JRO_CR2 K64F_EthLink_HelloWorld frdm_test JRO_DDSv2
Revision 4:9d2a4dc03170, committed 2016-05-19
- Comitter:
- loopsva
- Date:
- Thu May 19 17:20:55 2016 +0000
- Parent:
- 3:fbd2336e1193
- Commit message:
- Changed from:
;
; uint32_t k64f_mdio_reg = ENET_EIR;
;
; To:
;
; uint32_t k64f_mdio_reg = ENET->EIR;
Changed in this revision
| k64f_EthLink.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/k64f_EthLink.cpp Fri Nov 07 22:05:00 2014 +0000
+++ b/k64f_EthLink.cpp Thu May 19 17:20:55 2016 +0000
@@ -9,7 +9,7 @@
//--------------------------------------------------------------------------------------------------------------------------------------//
// Get Ethernet link status on the K64F
-
+/*
int k64fEthLink::GetELink() {
int mdio_timer = 0;
uint32_t k64f_mdio_reg = ENET_EIR;
@@ -35,6 +35,69 @@
if(k64f_mdio_reg & MDIO_MII_LINK_BITS) return(PHY_UP);
return(PHY_DOWN);
}
+*/
+//--------------------------------------------------------------------------------------------------------------------------------------//
+// Get Ethernet link status on the K64F
+/*
+ENET_Type miiSTR = {};
+
+int k64fEthLink::GetELink() {
+ int mdio_timer = 0;
+ uint32_t k64f_mdio_reg = miiSTR.EIR;
+
+ //wait for MDIO interface to be ready
+ do {
+ k64f_mdio_reg = miiSTR.EIR;
+#ifdef RTOS_H
+ Thread::wait(1);
+#else
+ wait_ms(1);
+#endif
+ mdio_timer++;
+ } while(((k64f_mdio_reg & MDIO_MII_READY_BIT) == 0) && (mdio_timer < 300));
+ if(mdio_timer > 298) { //average is about 122mS
+ return(MDIO_TIMEOUT); //timeout error
+ }
+
+ //get Basic Status Register
+ miiSTR.MMFR = MDIO_GET_LINK_REG;
+ wait_us(35); //20 is absolute minimum!!
+ k64f_mdio_reg = miiSTR.MMFR; //get the phy result
+ if(k64f_mdio_reg & MDIO_MII_LINK_BITS) return(PHY_UP);
+ return(PHY_DOWN);
+}
+*/
+//--------------------------------------------------------------------------------------------------------------------------------------//
+// Get Ethernet link status on the K64F
+
+//see: mbed-dev/targets/cmsis/TARGET_K64F/MK64F12.h
+
+int k64fEthLink::GetELink() {
+ int mdio_timer = 0;
+ uint32_t k64f_mdio_reg = ENET->EIR;
+
+ //wait for MDIO interface to be ready
+ do {
+ k64f_mdio_reg = ENET->EIR;
+#ifdef RTOS_H
+ Thread::wait(1);
+#else
+ wait_ms(1);
+#endif
+ mdio_timer++;
+ } while(((k64f_mdio_reg & MDIO_MII_READY_BIT) == 0) && (mdio_timer < 300));
+ if(mdio_timer > 298) { //average is about 122mS
+ return(MDIO_TIMEOUT); //timeout error
+ }
+
+ //get Basic Status Register
+ ENET->MMFR = MDIO_GET_LINK_REG;
+ wait_us(35); //20 is absolute minimum!!
+ k64f_mdio_reg = ENET->MMFR; //get the phy result
+ if(k64f_mdio_reg & MDIO_MII_LINK_BITS) return(PHY_UP);
+ return(PHY_DOWN);
+}
+
#endif