WIZnet WIZ820io (W5200) support
Dependencies: NTPClient WIZ820ioInterface mbed
Fork of NTPClient_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 //#include "EthernetInterface.h" 00003 #include "WIZ820ioInterface.h" 00004 #include "NTPClient.h" 00005 00006 //EthernetInterface eth; 00007 #if defined(TARGET_LPC1114) 00008 SPI spi(dp2, dp1, dp6); // mosi, miso, sclk 00009 WIZ820ioInterface eth(&spi, dp25, dp26); // spi, cs, reset 00010 00011 #elif defined(TARGET_LPC1768) 00012 SPI spi(p11, p12, p13); // mosi, miso, sclk 00013 WIZ820ioInterface eth(&spi, p14, p15); // spi, cs, reset 00014 00015 #endif 00016 00017 NTPClient ntp; 00018 00019 int main() 00020 { 00021 int ret = eth.init(); //Use DHCP 00022 if (!ret) 00023 { 00024 printf("Initialized, MAC: %s\n", eth.getMACAddress()); 00025 } 00026 else 00027 { 00028 printf("Error eth.init() - ret = %d\n", ret); 00029 return -1; 00030 } 00031 00032 ret = eth.connect(); 00033 if (!ret) 00034 { 00035 printf("Connected, IP: %s, MASK: %s, GW: %s\n", 00036 eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway()); 00037 } 00038 else 00039 { 00040 printf("Error eth.connect() - ret = %d\n", ret); 00041 return -1; 00042 } 00043 00044 00045 printf("Trying to update time...\r\n"); 00046 if (ntp.setTime("0.pool.ntp.org") == 0) 00047 { 00048 printf("Set time successfully\r\n"); 00049 time_t ctTime; 00050 ctTime = time(NULL); 00051 printf("Time is set to (UTC): %s\r\n", ctime(&ctTime)); 00052 } 00053 else 00054 { 00055 printf("Error\r\n"); 00056 } 00057 00058 eth.disconnect(); 00059 00060 while(1) { 00061 } 00062 }
Generated on Fri Jul 22 2022 15:26:59 by 1.7.2