WIZnet WIZ550io (w5500) support

Dependents:   HTTPClient_HelloWorld_WIZ550io NTPClient_HelloWorld_WIZ550io

Fork of WIZ820ioInterface by ban4jp -

Revision:
9:615198a7b82b
Parent:
8:8bdf6aac8cea
--- 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;
 }