summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-06 22:53:59 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-06 22:53:59 +0000
commit40d0d752aa94e162b28a89f1730d989bd9e45aee (patch)
tree3a9f40e494f5205dfd31ad516c5071726cf87177 /firmware
parent48a336851e349e6130178f3409b54dcb0dbba4e4 (diff)
downloadrockbox-40d0d752aa94e162b28a89f1730d989bd9e45aee.zip
rockbox-40d0d752aa94e162b28a89f1730d989bd9e45aee.tar.gz
rockbox-40d0d752aa94e162b28a89f1730d989bd9e45aee.tar.bz2
rockbox-40d0d752aa94e162b28a89f1730d989bd9e45aee.tar.xz
Make seconds flow evenly and further throttle RTC reads solution partially thanks to amiconn
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8938 a1c6a512-1295-4272-9138-f99709370657
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 28fe8de..a924ed4 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -46,13 +46,13 @@ bool valid_time(const struct tm *tm)
struct tm *get_time(void)
{
#ifndef SIMULATOR
-#ifdef CONFIG_RTC
static long last_tick = 0;
/* Don't read the RTC more than 4 times per second */
- if (last_tick + HZ/4 < current_tick) {
+ if (last_tick + HZ < current_tick) {
+#ifdef CONFIG_RTC
char rtcbuf[7];
- last_tick = current_tick;
+ last_tick = HZ * (current_tick / HZ);
rtc_read_datetime(rtcbuf);
tm.tm_sec = ((rtcbuf[0] & 0x70) >> 4) * 10 + (rtcbuf[0] & 0x0f);
@@ -65,18 +65,18 @@ struct tm *get_time(void)
tm.tm_yday = 0; /* Not implemented for now */
tm.tm_isdst = -1; /* Not implemented for now */
- }
#else
- tm.tm_sec = 0;
- tm.tm_min = 0;
- tm.tm_hour = 0;
- tm.tm_mday = 1;
- tm.tm_mon = 0;
- tm.tm_year = 70;
- tm.tm_wday = 1;
- tm.tm_yday = 0; /* Not implemented for now */
- tm.tm_isdst = -1; /* Not implemented for now */
+ tm.tm_sec = 0;
+ tm.tm_min = 0;
+ tm.tm_hour = 0;
+ tm.tm_mday = 1;
+ tm.tm_mon = 0;
+ tm.tm_year = 70;
+ tm.tm_wday = 1;
+ tm.tm_yday = 0; /* Not implemented for now */
+ tm.tm_isdst = -1; /* Not implemented for now */
#endif
+ }
return &tm;
#else
time_t now = time(NULL);