Bläddra i källkod

NTP is now working. Time is being fetched properly.

I've worked around 1.5h on it.

@Janco: ntp_datetime is op type: tm* (pointer to tm-struct).
This means in will not fit in void function(tm* x) if you declare it as
a pointer again.
function(*x)... Then it becomes a pointer to a pointer.
Jordy Sipkema 9 år sedan
förälder
incheckning
d83e9c8471
2 ändrade filer med 18 tillägg och 4 borttagningar
  1. 17 3
      ntp.c
  2. 1 1
      ntp.h

+ 17 - 3
ntp.c

@@ -43,7 +43,21 @@ void GetTime(){
         }
     }
     puts("Opgehaald.\n");
+
     ntp_datetime = localtime(&ntp_time);
-    printf("NTP tijd is: %02d:%02d:%02d\n", ntp_datetime->tm_hour, ntp_datetime->tm_min, ntp_datetime->tm_sec);
-    //return ntp_datetime;
-}
+
+    printf("NTP time is: %02d:%02d:%02d\n", ntp_datetime->tm_hour, ntp_datetime->tm_min, ntp_datetime->tm_sec);
+    printf("NTP date is: %02d.%02d.%02d\n\n", ntp_datetime->tm_mday, (ntp_datetime->tm_mon + 1), (ntp_datetime->tm_year + 1900));
+
+    NutRtcSetTime(ntp_datetime);
+
+
+    // This isn't working...
+    tm *test;
+
+    X12RtcGetClock(test);
+
+    printf("RTC time is: %02d:%02d:%02d\n", test->tm_hour, test->tm_min, test->tm_sec);
+    printf("RTC date is: %02d.%02d.%02d\n\n", test->tm_mday, (test->tm_mon + 1), (test->tm_year + 1900));
+}
+

+ 1 - 1
ntp.h

@@ -7,4 +7,4 @@
 
 extern void NtpInit(void);
 extern void GetTime(void);
-#endif /* _Network_H */
+#endif /* _Network_H */