moccos mizuki / EthernetXpresso

Dependents:   XNetServicesMin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EthernetXpresso.cpp Source File

EthernetXpresso.cpp

00001 #include "EthernetXpresso.h"
00002 #include "LPC1768/ARM/cmsis.h"
00003 #include <string.h>
00004 #include <mbed.h>
00005 
00006 // === public functions ===
00007 EthernetXpresso::EthernetXpresso() {
00008     ResetEmac_();
00009     //emac_.SetAddress(0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
00010 }
00011 
00012 EthernetXpresso::~EthernetXpresso() {
00013 }
00014 
00015 void
00016 EthernetXpresso::set_link(Mode mode) {
00017 }
00018 
00019 // === private functions ===
00020 bool
00021 EthernetXpresso::ResetEmac_() {
00022     if (!emac_.Reset()) return false;  // auto-neg
00023     int i;
00024     for (i = 0; i < 0x1000; i++) {  // 10 sec
00025         if (emac_.Link()) break;
00026         wait_ms(10);
00027     }
00028     emac_.StartTx();
00029     emac_.StartRx();
00030     return true;
00031 }