Wiznet W5500 lightweight SNTPClient example, tested on Maxim MAX32630FTHR board

Dependencies:   mbed W5500-Interface max32630fthr W5500-SNTPClient

Committer:
star297
Date:
Thu May 02 20:57:14 2019 +0000
Revision:
0:31500befb6ca
First commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
star297 0:31500befb6ca 1
star297 0:31500befb6ca 2 // Wiznet WIZ550io bytsize SNTPClient Example
star297 0:31500befb6ca 3 // Tested using MAX32630FTHR board
star297 0:31500befb6ca 4
star297 0:31500befb6ca 5 #include "mbed.h"
star297 0:31500befb6ca 6 #include "EthernetInterface.h"
star297 0:31500befb6ca 7 #include "SNTPClient.h"
star297 0:31500befb6ca 8
star297 0:31500befb6ca 9 #include "max32630fthr.h"
star297 0:31500befb6ca 10 //Init board and set GPIO to 3.3V logic
star297 0:31500befb6ca 11 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
star297 0:31500befb6ca 12
star297 0:31500befb6ca 13 EthernetInterface eth(P5_1, P5_2, P5_0, P3_0, P3_1); // MOSI, MISO, SCK, CS, RESET
star297 0:31500befb6ca 14 SNTPClient sntp;
star297 0:31500befb6ca 15
star297 0:31500befb6ca 16 int main() {
star297 0:31500befb6ca 17
star297 0:31500befb6ca 18 printf("Initialise! \n\n");
star297 0:31500befb6ca 19 eth.init(); //Use DHCP
star297 0:31500befb6ca 20 printf("Connecting.. \n");
star297 0:31500befb6ca 21 eth.connect();
star297 0:31500befb6ca 22 printf("IP Address is: %s\n\n", eth.getIPAddress());
star297 0:31500befb6ca 23 printf("Get NTP... \n\n");
star297 0:31500befb6ca 24
star297 0:31500befb6ca 25 // example NTPpool = "1.nl.pool.ntp.org"
star297 0:31500befb6ca 26 // get seconds UTC + 1hour, enable DST and set MCU RTC
star297 0:31500befb6ca 27 printf("Seconds since 1970 = %d\n\n", sntp.getNTP("1.nl.pool.ntp.org",1,1,1));
star297 0:31500befb6ca 28 time_t ctTime;
star297 0:31500befb6ca 29 ctTime = time(NULL);
star297 0:31500befb6ca 30 printf("RTC is set to: %s\n", ctime(&ctTime));
star297 0:31500befb6ca 31 }
star297 0:31500befb6ca 32