modify

Dependencies:   Adafruit_GFX Adafruit_ST7735 GMMP_mbed NTPClient SDFileSystem WIZnet_Library mbed

Fork of ThingPlug_Ethernet_Example_temp_V2 by irina kim

Files at this revision

API Documentation at this revision

Comitter:
lesmin
Date:
Wed Aug 12 12:53:28 2015 +0000
Parent:
6:f3e13103ea9d
Child:
8:88a323a90d37
Commit message:
W5500 re-initialize code added

Changed in this revision

GMMP_mbed.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GMMP_mbed.lib	Wed Aug 12 09:14:06 2015 +0000
+++ b/GMMP_mbed.lib	Wed Aug 12 12:53:28 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/SKTelecom_ThingPlug/code/GMMP_mbed/#e210cb961300
+https://developer.mbed.org/teams/SKTelecom_ThingPlug/code/GMMP_mbed/#909c1838c601
--- a/main.cpp	Wed Aug 12 09:14:06 2015 +0000
+++ b/main.cpp	Wed Aug 12 12:53:28 2015 +0000
@@ -349,25 +349,44 @@
     printf("input MAC Address is %02x:%02x:%02x:%02x:%02x:%02x\r\n",
     	g_mac[0], g_mac[1], g_mac[2], g_mac[3], g_mac[4], g_mac[5]);
 	
-	int ret2 = ethernet.init(g_mac);
+	int ret = ethernet.init(g_mac);
     //printf("SPI Initialized \r\n");
     //wait(1); // 1 second for stable state
     
     printf("W5500 Networking Started \r\n");
     //wait(1); // 1 second for stable state
 
-    if (!ret2) {
+    if (!ret) {
         printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress());
-        ret2 = ethernet.connect();
-        if (!ret2) {
+        ret = ethernet.connect();
+        if (!ret) {
             printf("IP: %s, MASK: %s, GW: %s\r\n",
                       ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
         } else {
-            printf("Error ethernet.connect() - ret = %d\r\n", ret2);
+            printf("Error ethernet.connect() - ret = %d\r\n", ret);
             //exit(0);
+
+            // ## 20150812 Eric added, Ethernet interface re-initialize code
+            ///////////////////////////////////////////////////////////////////////////
+            do{             
+                //printf("Ethernet Interface Re-initialize\r\n");               
+                #if defined(TARGET_LPC1768) 
+                SPI spi(p5, p6, p7); // mosi, miso, sclk        
+                #elif defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
+                SPI spi(PA_7, PA_6, PA_5);
+                #endif
+                //wait(0.5);
+                
+                ethernet.init(g_mac);
+                ret = ethernet.connect();
+                printf("Re-initialized, MAC: %s\r\n", ethernet.getMACAddress());            
+                printf("IP: %s, MASK: %s, GW: %s\r\n",
+                          ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway());
+            } while(ret);
+            ///////////////////////////////////////////////////////////////////////////
         }
     } else {
-        printf("Error ethernet.init() - ret = %d\r\n", ret2);
+        printf("Error ethernet.init() - ret = %d\r\n", ret);
         //exit(0);
     }
 
@@ -384,7 +403,7 @@
   infoln("SetCallFunction");
   SetCallFunction(Recv);
   
-  int ret = GO_Reg(NULL, pszGWMFID);
+  ret = GO_Reg(NULL, pszGWMFID);
 
   if (ret != GMMP_SUCCESS) {
     errorln("RegReq Error!!");