Test de RTC_IUT
Dependencies: RTC_IUT
main.cpp@2:5cc0488cf048, 2020-06-03 (annotated)
- Committer:
- gr91
- Date:
- Wed Jun 03 08:12:48 2020 +0000
- Revision:
- 2:5cc0488cf048
- Parent:
- 1:92f65ad2bb0a
V6
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gr91 | 0:8a5436c20b46 | 1 | #include "mbed.h" |
gr91 | 1:92f65ad2bb0a | 2 | #include "RTC_IUT.h" |
gr91 | 1:92f65ad2bb0a | 3 | Rtc rtc; |
gr91 | 1:92f65ad2bb0a | 4 | /// |
gr91 | 1:92f65ad2bb0a | 5 | int main() |
gr91 | 1:92f65ad2bb0a | 6 | { |
gr91 | 1:92f65ad2bb0a | 7 | //char TimeTest[] = "31/12/1999 23:59:50"; |
gr91 | 1:92f65ad2bb0a | 8 | //char TimeTest[] = "19/01/2038 03:13:50"; |
gr91 | 1:92f65ad2bb0a | 9 | char TimeTest[] = "03/06/1970 10:00:00"; |
gr91 | 1:92f65ad2bb0a | 10 | time_t epoc; |
gr91 | 1:92f65ad2bb0a | 11 | char buf[50]; |
gr91 | 1:92f65ad2bb0a | 12 | rtc.SetTimeString(TimeTest); |
gr91 | 1:92f65ad2bb0a | 13 | rtc.GetTimeString(buf); |
gr91 | 1:92f65ad2bb0a | 14 | epoc =rtc.GetTimeValue(); |
gr91 | 1:92f65ad2bb0a | 15 | printf("epoc: %8X, time: %s\r\n", epoc, buf); |
gr91 | 1:92f65ad2bb0a | 16 | while(1) { |
gr91 | 1:92f65ad2bb0a | 17 | rtc.SetYear(2020); // Set the year |
gr91 | 1:92f65ad2bb0a | 18 | rtc.GetTimeString(buf); // read date time string DD:MM:YYY hh:mm:ss |
gr91 | 1:92f65ad2bb0a | 19 | epoc =rtc.GetTimeValue(); // Read second since 01/01/1970 |
gr91 | 1:92f65ad2bb0a | 20 | printf("epoc: %8X, time: %s\r\n", epoc, buf); |
gr91 | 1:92f65ad2bb0a | 21 | wait(0.9999); |
gr91 | 0:8a5436c20b46 | 22 | } |
gr91 | 1:92f65ad2bb0a | 23 | } |