vhgr

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of sisk_project by Szymon Guza

Committer:
grzemich
Date:
Fri Dec 09 07:14:15 2016 +0000
Revision:
1:65cfd74a3ae5
Parent:
0:7a4b0e7660ad
Child:
2:b656e974fad2
gfhvce

Who changed what in which revision?

UserRevisionLine numberNew contents of line
guzbi 0:7a4b0e7660ad 1 #include "mbed.h"
guzbi 0:7a4b0e7660ad 2 #include "EthernetInterface.h"
grzemich 1:65cfd74a3ae5 3 #include "fsl_phy.h"
grzemich 1:65cfd74a3ae5 4
grzemich 1:65cfd74a3ae5 5 bool connection_status;
grzemich 1:65cfd74a3ae5 6 phy_speed_t speed;
grzemich 1:65cfd74a3ae5 7 phy_duplex_t duplex;
grzemich 1:65cfd74a3ae5 8 int phyAddr = 0;
guzbi 0:7a4b0e7660ad 9
guzbi 0:7a4b0e7660ad 10 int main() {
guzbi 0:7a4b0e7660ad 11
guzbi 0:7a4b0e7660ad 12 EthernetInterface eth;
guzbi 0:7a4b0e7660ad 13 eth.init(); //Use DHCP
guzbi 0:7a4b0e7660ad 14 eth.connect();
guzbi 0:7a4b0e7660ad 15
guzbi 0:7a4b0e7660ad 16 while(1) {
grzemich 1:65cfd74a3ae5 17 PHY_GetLinkStatus(ENET, phyAddr, &connection_status);
grzemich 1:65cfd74a3ae5 18 PHY_GetSpeedDuplex(ENET, phyAddr, &speed, &duplex);
grzemich 1:65cfd74a3ae5 19 if(connection_status){
guzbi 0:7a4b0e7660ad 20 printf("Cable is connected\n");
grzemich 1:65cfd74a3ae5 21 if(duplex)
guzbi 0:7a4b0e7660ad 22 printf("Full duplex\n");
guzbi 0:7a4b0e7660ad 23 else
guzbi 0:7a4b0e7660ad 24 printf("Half duplex\n");
grzemich 1:65cfd74a3ae5 25 if(speed)
guzbi 0:7a4b0e7660ad 26 printf("100 Mbit per second\n");
guzbi 0:7a4b0e7660ad 27 else
guzbi 0:7a4b0e7660ad 28 printf("10 Mbit per second\n");
guzbi 0:7a4b0e7660ad 29 }
guzbi 0:7a4b0e7660ad 30 else
guzbi 0:7a4b0e7660ad 31 printf("Cable is disconnected\n");
guzbi 0:7a4b0e7660ad 32
guzbi 0:7a4b0e7660ad 33 wait(5);
guzbi 0:7a4b0e7660ad 34 }
guzbi 0:7a4b0e7660ad 35 }