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.
Dependencies: EthernetInterface k64f_EthLink mbed-rtos mbed
Fork of K64F_EthLink_HelloWorld by
main.cpp
- Committer:
- loopsva
- Date:
- 2016-05-19
- Revision:
- 2:20bc1a7828e4
- Parent:
- 0:66507f292910
File content as of revision 2:20bc1a7828e4:
#include "mbed.h" #include "EthernetInterface.h" #include "k64f_EthLink.h" EthernetInterface eth; k64fEthLink link; Serial pc(USBTX, USBRX); //--------------------------------------------------------------------------------------------------------------------------------------// // Check for a valid Ethernet Link, print ONLY on status change and keep count of link "downs" bool EthPhyUpT = false; int EthUpDownCnt = 0; int TestEthLink() { int EthLinkStat = link.GetELink(); if((!(EthLinkStat)) && (EthPhyUpT == false)) { pc.printf("Eth Link UP\r\n"); EthPhyUpT = true; } else if(((EthLinkStat)) && (EthPhyUpT == true)){ EthUpDownCnt++; pc.printf("Eth Link DOWN, count: %d\r\n", EthUpDownCnt); EthPhyUpT = false; } if(EthLinkStat == MDIO_TIMEOUT) return(MDIO_TIMEOUT); if(EthPhyUpT == true) return(PHY_UP); return(PHY_DOWN); } //--------------------------------------------------------------------------------------------------------------------------------------// int main() { pc.baud(230400); pc.printf("\r\n\r\nBasic Ethernet Link Up / Down test for K64F\r\n"); int EthInitStatus = eth.init(); /* Finish up initialization here!!! */ while(1) { Thread::wait(500); int i = TestEthLink(); if(i == MDIO_TIMEOUT) pc.printf("MDIO Timeout!!!\r\n"); } }