summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/timefuncs.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index 28fe8deb97..a924ed496a 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -46,13 +46,13 @@ bool valid_time(const struct tm *tm)
46struct tm *get_time(void) 46struct tm *get_time(void)
47{ 47{
48#ifndef SIMULATOR 48#ifndef SIMULATOR
49#ifdef CONFIG_RTC
50 static long last_tick = 0; 49 static long last_tick = 0;
51 50
52 /* Don't read the RTC more than 4 times per second */ 51 /* Don't read the RTC more than 4 times per second */
53 if (last_tick + HZ/4 < current_tick) { 52 if (last_tick + HZ < current_tick) {
53#ifdef CONFIG_RTC
54 char rtcbuf[7]; 54 char rtcbuf[7];
55 last_tick = current_tick; 55 last_tick = HZ * (current_tick / HZ);
56 rtc_read_datetime(rtcbuf); 56 rtc_read_datetime(rtcbuf);
57 57
58 tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f); 58 tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f);
@@ -65,18 +65,18 @@ struct tm *get_time(void)
65 65
66 tm.tm_yday = 0; /* Not implemented for now */ 66 tm.tm_yday = 0; /* Not implemented for now */
67 tm.tm_isdst = -1; /* Not implemented for now */ 67 tm.tm_isdst = -1; /* Not implemented for now */
68 }
69#else 68#else
70 tm.tm_sec = 0; 69 tm.tm_sec = 0;
71 tm.tm_min = 0; 70 tm.tm_min = 0;
72 tm.tm_hour = 0; 71 tm.tm_hour = 0;
73 tm.tm_mday = 1; 72 tm.tm_mday = 1;
74 tm.tm_mon = 0; 73 tm.tm_mon = 0;
75 tm.tm_year = 70; 74 tm.tm_year = 70;
76 tm.tm_wday = 1; 75 tm.tm_wday = 1;
77 tm.tm_yday = 0; /* Not implemented for now */ 76 tm.tm_yday = 0; /* Not implemented for now */
78 tm.tm_isdst = -1; /* Not implemented for now */ 77 tm.tm_isdst = -1; /* Not implemented for now */
79#endif 78#endif
79 }
80 return &tm; 80 return &tm;
81#else 81#else
82 time_t now = time(NULL); 82 time_t now = time(NULL);