Ethernet link status for the K64F

Dependents:   JRO_CR2 K64F_EthLink_HelloWorld frdm_test JRO_DDSv2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers k64f_EthLink.h Source File

k64f_EthLink.h

00001 #ifndef K64FLINK_H
00002 #define K64FLINK_H
00003 
00004 #include "mbed.h"
00005 
00006 /** Software routine used to get Ethernet Link status from the KSZ8081 
00007  *  Ethernet PHY on the FRDM-K64F via the K64F MDIO interface. 
00008  * 
00009  * @code
00010  * //See K64F_EthLink_HelloWorld example
00011  * @endcode
00012 */
00013 
00014 #define MDIO_MII_READY_BIT      0x00800000  //Bit in ENET_EIR reister that allows access to ENET_MMFR register
00015 #define MDIO_MII_LINK_BITS      0x0004      //Ethernet Link Up / Down bit in Phy's Basic Status Register
00016 #define MDIO_GET_LINK_REG       0x60060000  //command for ENET_MMFR register to read Phy's Basic Status
00017 //                                |-------  ST = 01 start of frame                  31,30
00018 //                                |-------  OP = 10 read                            29,28
00019 //                                 ||-----  PA = 00000 phy address                  27,26,25,24,23
00020 //                                  ||----  RA = 00001 phy register Basic Status    22,21,20,19,18
00021 //                                   |----  TA = 10 turn around                     17,16
00022 //                                    ||||  DATA
00023 
00024 
00025     /** k64f_phy_status Ethernet link result enumator
00026      *
00027      * @param k64f_phy_status enumator
00028      *
00029      */
00030 enum k64f_phy_status {PHY_UP = 0, PHY_DOWN = 1, MDIO_TIMEOUT = 2};
00031 
00032     /** Create k64fEthLink controller class
00033      *
00034      * @param k64fEthLink class
00035      *
00036      */
00037 class k64fEthLink {
00038 
00039 public:
00040     /** Create a k64fEthLink object
00041      *
00042      * @param -none-
00043      */
00044     k64fEthLink();
00045     /** Return Ethernet Link Status
00046      *
00047      * @param -none-
00048      *
00049      * @return the link status code from enum k64f_phy_status
00050      */
00051     int GetELink();
00052 
00053 };
00054 
00055 #endif