summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2005-12-11 00:47:40 +0000
committerDave Chapman <dave@dchapman.com>2005-12-11 00:47:40 +0000
commit790b365595ce0e3407777b9ff37494ec7fe7db0f (patch)
tree0af5f8bcbe9c4b5edbdb55f137f02fc0989480d0 /firmware/drivers
parent6ddfac0806a15a8771725ec4fdc39247f36949ff (diff)
Reworking of Archos RTC code to create a (slightly) more abstract RTC api
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8216 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/rtc.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c
index 30bbb6dfcb..b77db8b865 100644
--- a/firmware/drivers/rtc.c
+++ b/firmware/drivers/rtc.c
@@ -249,4 +249,34 @@ int rtc_read_multiple(unsigned char address, unsigned char *buf, int numbytes)
i2c_end();
return ret;
}
-#endif
+
+int rtc_read_datetime(unsigned char* buf) {
+ int rc;
+
+ rc = rtc_read_multiple(1, buf, 7);
+
+ /* Adjust weekday */
+ if(buf[3] == 7)
+ buf[3]=0;
+
+ return rc;
+}
+
+int rtc_write_datetime(unsigned char* buf) {
+ int i;
+ int rc = 0;
+
+ /* Adjust weekday */
+ if(buf[3] == 0)
+ buf[3] = 7;
+
+ for (i = 0; i < 7 ; i++)
+ {
+ rc |= rtc_write(i+1, buf[i]);
+ }
+ rc |= rtc_write(8, 0x80); /* Out=1, calibration = 0 */
+
+ return rc;
+}
+
+#endif /* CONFIG_RTC */