Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WIZnet_Library mbed
Fork of HTTPServer_echoback_WIZ550io by
Diff: main.cpp
- Revision:
- 16:ea8f49af2d86
- Parent:
- 15:eae1575da9ca
- Child:
- 17:c42419afb2f8
--- a/main.cpp Fri Mar 08 02:24:33 2013 +0000
+++ b/main.cpp Mon Jul 21 05:13:27 2014 +0000
@@ -1,18 +1,18 @@
#include "mbed.h"
-#include "EthernetInterface.h"
+//#include "EthernetInterface.h"
+#include "EthernetInterfaceW5500.h"
#include <stdio.h>
#include <string.h>
#define PORT 80
-EthernetInterface eth;
+//EthernetInterface eth;
-TCPSocketServer svr;
+//TCPSocketServer svr;
bool serverIsListened = false;
-TCPSocketConnection client;
+//TCPSocketConnection client;
bool clientIsConnected = false;
-
DigitalOut led1(LED1); //server listning status
DigitalOut led2(LED2); //socket connecting status
@@ -29,12 +29,58 @@
int main (void)
{
+#if defined(TARGET_LPC1114)
+ SPI spi(dp2, dp1, dp6); // mosi, miso, sclk
+ EthernetInterfaceW5500 eth(&spi, dp25, dp26); // spi, cs, reset
+
+#elif defined(TARGET_LPC1768)
+ SPI spi(p11, p12, p13); // mosi, miso, sclk
+ EthernetInterfaceW5500 eth(&spi, p14, p15); // spi, cs, reset
+
+#elif defined(TARGET_LPC11U68)
+ SPI spi(P0_9, P0_8, P1_29); // mosi, miso, sclk
+//WIZnetInterface eth(&spi, P0_2, P1_25); // spi, cs, reset
+//SPI spi(p5, p6, p7); // mosi, miso, sclk
+ EthernetInterfaceW5500 eth(&spi, P0_2, P1_28);//, nRESET(p9); // reset pin is dummy, don't affect any pin of WIZ550io
+ spi.format(8,0); // 8bit, mode 0
+ spi.frequency(7000000); // 7MHz
+ wait(1); // 1 second for stable state
+
+#endif
+
+TCPSocketServer svr;
+TCPSocketConnection client;
+
ledTick.attach(&ledTickfunc,0.5);
+/*
//setup ethernet interface
eth.init(); //Use DHCP
eth.connect();
printf("IP Address is %s\n\r", eth.getIPAddress());
+*/
+
+#ifdef _DHCP // didn't test yet in DHCP
+
+ eth.init(); //Use DHCP
+ eth.connect();
+ //printf("IP Address is %s\n\r", eth.getIPAddress());
+ printf("Initialized, MAC: %s\n", eth.getMACAddress());
+ printf("Connected, IP: %s, MASK: %s, GW: %s\n",
+ eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+
+#else
+ // as your env. change to real IP address and so on.
+ int ret = eth.init("222.98.173.212", "255.255.255.192", "222.98.173.254");
+ if (!ret) {
+ printf("Initialized, MAC: %s\n", eth.getMACAddress());
+ printf("Connected, IP: %s, MASK: %s, GW: %s\n",
+ eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
+ } else {
+ printf("Error eth.init() - ret = %d\n", ret);
+ return -1;
+ }
+#endif
//setup tcp socket
if(svr.bind(PORT)< 0) {
