W5200(WIZ820io) network interface
Diff: WIZ820ioNetIf.cpp
- Revision:
- 1:803123933c5a
- Parent:
- 0:61831b843b44
- Child:
- 2:a8df39b4f3aa
diff -r 61831b843b44 -r 803123933c5a WIZ820ioNetIf.cpp --- a/WIZ820ioNetIf.cpp Sat Apr 14 17:21:11 2012 +0000 +++ b/WIZ820ioNetIf.cpp Tue Apr 17 12:13:15 2012 +0000 @@ -1,7 +1,25 @@ -// WIZ820ioNetIf.cpp 2012/4/13 +// WIZ820ioNetIf.cpp 2012/4/17 #include "WIZ820ioNetIf.h" #include "w5100.h" +extern SPI* pSPI; // w5100.cpp +extern DigitalOut* pCS; // w5100.cpp + +DigitalOut* pRESET = NULL; + +void hardware_reset() { + if (!pRESET) { + pRESET = new DigitalOut(p15); + } + if (pRESET) { + pRESET->write(1); + pRESET->write(0); + wait_us(2); + pRESET->write(1); + wait_ms(150); + } +} + bool wait_linkup(int timeout = 5000) { Timer link_t; link_t.start(); @@ -14,8 +32,18 @@ return false; } +void WIZ820ioNetIf::spi(PinName mosi,PinName miso, PinName sclk) { + pSPI = new SPI(mosi,miso,sclk); +} +void WIZ820ioNetIf::cs(PinName _cs) { + pCS = new DigitalOut(_cs); +} +void WIZ820ioNetIf::reset(PinName _reset) { + pRESET = new DigitalOut(_reset); +} + int WIZ820ioNetIf::setup(int timeout_ms) { - W5100.hardware_reset(); + hardware_reset(); W5100.init(); wait_linkup(); return w5200NetIf::setup(timeout_ms);