no upgrade or change at this. move to new Library for WIZ550io, W5500 -> http://mbed.org/teams/EthernetInterfaceW5500-makers/code/W5500Interface/

Dependents:   LPC11U68_NTPClient_HelloWorld_WIZ550io

Fork of WIZ550ioInterface by ban4jp -

please get the new Library for WIZ550io, W5500 (WIZnet) http://mbed.org/teams/EthernetInterfaceW5500-makers/code/W5500Interface/

Import libraryW5500Interface

This is the Interface library for WIZnet W5500 chip which forked of EthernetInterfaceW5500, WIZnetInterface and WIZ550ioInterface. This library has simple name as "W5500Interface". and can be used for Wiz550io users also.

Files at this revision

API Documentation at this revision

Comitter:
ban4jp
Date:
Mon Dec 23 13:51:35 2013 +0000
Parent:
8:8bdf6aac8cea
Child:
10:4da8370d14da
Commit message:
Use on-board MAC Address.; Fixed compatibility.

Changed in this revision

Socket/Socket.h Show annotated file Show diff for this revision Revisions of this file
Socket/UDPSocket.cpp Show annotated file Show diff for this revision Revisions of this file
WIZ820io/WIZ820io.cpp Show annotated file Show diff for this revision Revisions of this file
WIZ820io/WIZ820io.h Show annotated file Show diff for this revision Revisions of this file
--- a/Socket/Socket.h	Sun Dec 15 12:29:47 2013 +0000
+++ b/Socket/Socket.h	Mon Dec 23 13:51:35 2013 +0000
@@ -20,6 +20,11 @@
 
 #include "WIZ820io.h"
 
+#define htons(x) __REV16(x)
+#define ntohs(x) __REV16(x)
+#define htonl(x) __REV(x)
+#define ntohl(x) __REV(x)
+
 /** Socket file descriptor and select wrapper
   */
 class Socket {
--- a/Socket/UDPSocket.cpp	Sun Dec 15 12:29:47 2013 +0000
+++ b/Socket/UDPSocket.cpp	Mon Dec 23 13:51:35 2013 +0000
@@ -18,6 +18,8 @@
 
 #include "UDPSocket.h"
 
+static int udp_local_port;
+
 UDPSocket::UDPSocket()
 {
 }
@@ -41,7 +43,12 @@
         }
     }
     // set local port
-    eth->sreg<uint16_t>(_sock_fd, Sn_PORT, port);
+    if (port != 0) {
+        eth->sreg<uint16_t>(_sock_fd, Sn_PORT, port);
+    } else {
+        udp_local_port++;
+        eth->sreg<uint16_t>(_sock_fd, Sn_PORT, udp_local_port);
+    }
     // set udp protocol
     eth->setProtocol(_sock_fd, UDP);
     eth->scmd(_sock_fd, OPEN);
--- a/WIZ820io/WIZ820io.cpp	Sun Dec 15 12:29:47 2013 +0000
+++ b/WIZ820io/WIZ820io.cpp	Mon Dec 23 13:51:35 2013 +0000
@@ -139,14 +139,22 @@
     reset_pin = 1;
     //wait_ms(150); // 150ms
     wait_ms(300); // 300ms (w5500)
-    reg_wr<uint8_t>(MR, 1<<7);
-#ifdef TARGET_LPC1114
-    uint8_t mac[6] = {0x00,0x02,0xf7,0xf0,0x00,0x00};
-#else
-    uint8_t mac[6];
-    mbed_mac_address((char*)mac);
-#endif
-    reg_wr_mac(SHAR, mac);
+    
+    //reg_wr<uint8_t>(MR, 1<<7);
+    
+//#ifdef TARGET_LPC1114
+//    uint8_t mac[6] = {0x00,0x02,0xf7,0xf0,0x00,0x00};
+//#else
+//    uint8_t mac[6];
+//    mbed_mac_address((char*)mac);
+//#endif
+//    reg_wr_mac(SHAR, mac);
+    
+    // set RX and TX buffer size
+    for (int socket = 0; socket < MAX_SOCK_NUM; socket++) {
+        sreg<uint8_t>(socket, Sn_RXBUF_SIZE, 2);
+        sreg<uint8_t>(socket, Sn_TXBUF_SIZE, 2);
+    }
 }
 
 bool WIZ820io::close(int socket)
@@ -162,6 +170,7 @@
         scmd(socket, DISCON);
     }
     scmd(socket, CLOSE);
+    sreg<uint8_t>(socket, Sn_IR, 0xff);
     return true;
 }
 
@@ -215,6 +224,15 @@
     spi_write(ptr, cntl_byte, (uint8_t*)str, len);
     sreg<uint16_t>(socket, Sn_TX_WR, ptr + len);
     scmd(socket, SEND);
+    
+    while ((sreg<uint8_t>(socket, Sn_IR) & INT_SEND_OK) != INT_SEND_OK) {
+        if (sreg<uint8_t>(socket, Sn_SR) == CLOSED) {
+            close(socket);
+            return 0;
+        }
+    }
+    sreg<uint8_t>(socket, Sn_IR, INT_SEND_OK);
+
     return len;
 }
 
--- a/WIZ820io/WIZ820io.h	Sun Dec 15 12:29:47 2013 +0000
+++ b/WIZ820io/WIZ820io.h	Mon Dec 23 13:51:35 2013 +0000
@@ -45,6 +45,14 @@
     
 };
 
+enum Interrupt {
+    INT_CON     = 0x01,
+    INT_DISCON  = 0x02,
+    INT_RECV    = 0x04,
+    INT_TIMEOUT = 0x08,
+    INT_SEND_OK = 0x10,
+};
+
 enum Status {
     SOCK_CLOSED      = 0x00,
     SOCK_INIT        = 0x13,
@@ -64,16 +72,19 @@
 #define SIPR      0x000f
 #define PHYSTATUS 0x0035
 // socket
-#define Sn_MR     0x0000
-#define Sn_CR     0x0001
-#define Sn_SR     0x0003
-#define Sn_PORT   0x0004
-#define Sn_DIPR   0x000c
-#define Sn_DPORT  0x0010
-#define Sn_TX_FSR 0x0020
-#define Sn_TX_WR  0x0024
-#define Sn_RX_RSR 0x0026
-#define Sn_RX_RD  0x0028
+#define Sn_MR         0x0000
+#define Sn_CR         0x0001
+#define Sn_IR         0x0002
+#define Sn_SR         0x0003
+#define Sn_PORT       0x0004
+#define Sn_DIPR       0x000c
+#define Sn_DPORT      0x0010
+#define Sn_RXBUF_SIZE 0x001e
+#define Sn_TXBUF_SIZE 0x001f
+#define Sn_TX_FSR     0x0020
+#define Sn_TX_WR      0x0024
+#define Sn_RX_RSR     0x0026
+#define Sn_RX_RD      0x0028
 
 class WIZ820io {
 public: