W5500 driver for mbed OS 5

Dependents:   http-webserver-example mbed-os-example-sockets

Fork of W5500Interface by Sergei G

Revision:
6:e2ab76b2be07
Parent:
4:80e302a610fd
Child:
8:c71c66d43703
--- a/WIZnet/W5500.cpp	Thu Jul 06 05:46:17 2017 +0000
+++ b/WIZnet/W5500.cpp	Thu Aug 09 08:10:27 2018 +0000
@@ -1,3 +1,4 @@
+// modified 08/08/2018 by Bongjun Hur
 
 #include "mbed.h"
 #include "mbed_debug.h"
@@ -71,6 +72,15 @@
     return true;
 }
 
+bool WIZnet_Chip::setLocalPort(int socket, uint16_t port)
+{
+    if (socket < 0) {
+        return false;
+    }
+    sreg<uint16_t>(socket, Sn_PORT, port);
+    return true;
+}
+
 bool WIZnet_Chip::connect(int socket, const char * host, int port, int timeout_ms)
 {
     if (socket < 0) {
@@ -131,7 +141,7 @@
 // Reset the chip & set the buffer
 void WIZnet_Chip::reset()
 {
-    reset_pin = 1;
+//    reset_pin = 1;
     reset_pin = 0;
     wait_us(500); // 500us (w5500)
     reset_pin = 1;
@@ -227,6 +237,8 @@
     Timer t;
     t.reset();
     t.start();
+    t.start();
+        
     while(1) {
         //int size = sreg<uint16_t>(socket, Sn_TX_FSR);
         int size1, size2;
@@ -235,7 +247,10 @@
         do {
             size1 = sreg<uint16_t>(socket, Sn_TX_FSR);
             size2 = sreg<uint16_t>(socket, Sn_TX_FSR);
+            DBG("The time taken was %d %d %f seconds\n", wait_time_ms, t.read_ms(), t.read());
+            
             if (wait_time_ms != (-1) && t.read_ms() > wait_time_ms) {
+                
                 return NSAPI_ERROR_WOULD_BLOCK;
             }        
         } while (size1 != size2);