summaryrefslogtreecommitdiff
path: root/firmware/drivers/rtc/rtc_m41st84w.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-01-25 19:32:15 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-01-26 23:07:49 -0500
commit58b849c451ac1281c14bfc535ab7f411a0b736e0 (patch)
tree035026a62581900f72fa0d90bd694a8a92372c00 /firmware/drivers/rtc/rtc_m41st84w.c
parent783c77531c35e62dd754c510c4f2beefe6df4a9d (diff)
downloadrockbox-58b849c451ac1281c14bfc535ab7f411a0b736e0.tar.gz
rockbox-58b849c451ac1281c14bfc535ab7f411a0b736e0.zip
Move intrinsic RTC implmentation differences to driver files
Some drivers set tm_wday just fine and do not need it coerced to be correct. Others set tm_yday, so don't overwrite what the driver sets; just zero it inside if it can't fill the field. Move calls to set_day_of_week() to the sorts of drivers that presumably required the hammer (FS#11814) in get_time() where the weekday isn't locked to the date. Change-Id: Idd0ded6bfc9d9f48fcc1a6074068164c42fcf24a
Diffstat (limited to 'firmware/drivers/rtc/rtc_m41st84w.c')
-rw-r--r--firmware/drivers/rtc/rtc_m41st84w.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/firmware/drivers/rtc/rtc_m41st84w.c b/firmware/drivers/rtc/rtc_m41st84w.c
index 4cfa155bfb..621e650f68 100644
--- a/firmware/drivers/rtc/rtc_m41st84w.c
+++ b/firmware/drivers/rtc/rtc_m41st84w.c
@@ -23,7 +23,7 @@
23#include "rtc.h" 23#include "rtc.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "system.h" 25#include "system.h"
26#include <stdbool.h> 26#include "timefuncs.h"
27 27
28#define RTC_ADR 0xd0 28#define RTC_ADR 0xd0
29#define RTC_DEV_WRITE (RTC_ADR | 0x00) 29#define RTC_DEV_WRITE (RTC_ADR | 0x00)
@@ -257,14 +257,12 @@ int rtc_read_datetime(struct tm *tm)
257 tm->tm_sec = BCD2DEC(buf[0] & 0x7f); 257 tm->tm_sec = BCD2DEC(buf[0] & 0x7f);
258 tm->tm_min = BCD2DEC(buf[1] & 0x7f); 258 tm->tm_min = BCD2DEC(buf[1] & 0x7f);
259 tm->tm_hour = BCD2DEC(buf[2] & 0x3f); 259 tm->tm_hour = BCD2DEC(buf[2] & 0x3f);
260 tm->tm_wday = BCD2DEC(buf[3] & 0x7);
261 tm->tm_mday = BCD2DEC(buf[4] & 0x3f); 260 tm->tm_mday = BCD2DEC(buf[4] & 0x3f);
262 tm->tm_mon = BCD2DEC(buf[5] & 0x1f) - 1; 261 tm->tm_mon = BCD2DEC(buf[5] & 0x1f) - 1;
263 tm->tm_year = BCD2DEC(buf[6]) + 100; 262 tm->tm_year = BCD2DEC(buf[6]) + 100;
263 tm->tm_yday = 0; /* Not implemented for now */
264 264
265 /* Adjust weekday */ 265 set_day_of_week(tm);
266 if (tm->tm_wday == 7)
267 tm->tm_wday = 0;
268 266
269 return rc; 267 return rc;
270} 268}