diff options
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/timefuncs.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index 275fc6c782..5cf1a35a77 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c | |||
@@ -47,12 +47,13 @@ struct tm *get_time(void) | |||
47 | { | 47 | { |
48 | #ifndef SIMULATOR | 48 | #ifndef SIMULATOR |
49 | #ifdef CONFIG_RTC | 49 | #ifdef CONFIG_RTC |
50 | static long last_tick = 0; | 50 | static long timeout = 0; |
51 | 51 | ||
52 | /* Don't read the RTC more than 4 times per second */ | 52 | /* Don't read the RTC more than once per second */ |
53 | if (last_tick + HZ < current_tick) { | 53 | if (current_tick > timeout) { |
54 | char rtcbuf[7]; | 54 | char rtcbuf[7]; |
55 | last_tick = HZ * (current_tick / HZ); | 55 | /* Once per second, 1/10th of a second off */ |
56 | timeout = HZ * (current_tick / HZ + 1) + HZ / 5; | ||
56 | rtc_read_datetime(rtcbuf); | 57 | rtc_read_datetime(rtcbuf); |
57 | 58 | ||
58 | tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f); | 59 | tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f); |