vhgr

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of sisk_project by Szymon Guza

main.cpp

Committer:
grzemich
Date:
2016-12-09
Revision:
1:65cfd74a3ae5
Parent:
0:7a4b0e7660ad
Child:
2:b656e974fad2

File content as of revision 1:65cfd74a3ae5:

#include "mbed.h"
#include "EthernetInterface.h"
#include "fsl_phy.h"

bool connection_status;
phy_speed_t speed;
phy_duplex_t duplex;
int phyAddr = 0;

int main() {

    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    
    while(1) {
        PHY_GetLinkStatus(ENET, phyAddr, &connection_status);
        PHY_GetSpeedDuplex(ENET, phyAddr, &speed, &duplex);   
        if(connection_status){
            printf("Cable is connected\n");
            if(duplex)
                printf("Full duplex\n");
            else
                printf("Half duplex\n");
            if(speed)
                printf("100 Mbit per second\n");
            else
                printf("10 Mbit per second\n");
            }
        else
            printf("Cable is disconnected\n");
        
        wait(5);
        }
}