Demo code for Seeed Ethernet Shield V2.0
Dependencies: WIZ820ioInterface mbed
Fork of Seeed_Ethernet_Shield_V2_HelloWorld by
Revision 0:84c1d086f776, committed 2014-02-18
- Comitter:
- lawliet
- Date:
- Tue Feb 18 06:28:27 2014 +0000
- Commit message:
- Initial Version
Changed in this revision
diff -r 000000000000 -r 84c1d086f776 WIZ820ioInterface.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WIZ820ioInterface.lib Tue Feb 18 06:28:27 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/va009039/code/WIZ820ioInterface/#fb15c35d1e28
diff -r 000000000000 -r 84c1d086f776 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Feb 18 06:28:27 2014 +0000 @@ -0,0 +1,77 @@ +/* + main.cpp + 2013 Copyright (c) Seeed Technology Inc. All right reserved. + + Author:lawliet zou(lawliet.zou@gmail.com) + 2014-02-18 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "WIZ820ioInterface.h" +#include "mbed.h" + +#if defined(TARGET_LPC11U24) //SEEEDUINO_ARCH + #define PIN_MOSI P1_22 + #define PIN_MISO P1_21 + #define PIN_SCLK P1_20 + #define PIN_CS P0_2 +#elif defined(TARGET_LPC1768) //SEEEDUINO_ARCH_PRO + #define PIN_MOSI P0_18 + #define PIN_MISO P0_17 + #define PIN_SCLK P0_15 + #define PIN_CS P0_6 +#else //please redefine the following pins + #define PIN_MOSI + #define PIN_MISO + #define PIN_SCLK + #define PIN_CS +#endif + +WIZ820ioInterface eth(PIN_MOSI,PIN_MISO,PIN_SCLK,PIN_CS,NC);//mosi,miso,sclk,cs,reset; + +int main(void) +{ + // use DHCP + eth.init(); + + // attempt DHCP + eth.connect(); + + // successful DHCP + printf("IP Address is %s\n", eth.getIPAddress()); + + TCPSocketConnection sock; + sock.connect("mbed.org", 80); + + char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n"; + sock.send_all(http_cmd, sizeof(http_cmd)-1); + + char buffer[300]; + int ret; + while (true) { + ret = sock.receive(buffer, sizeof(buffer)-1); + if (ret <= 0) + break; + buffer[ret] = '\0'; + printf("Received %d chars from server:\n%s\n", ret, buffer); + } + + sock.close(); + + eth.disconnect(); + + return 0; +}
diff -r 000000000000 -r 84c1d086f776 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Feb 18 06:28:27 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f \ No newline at end of file