summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/rtc/rtc_rx5x348ab.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-10-23 14:22:44 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-10-23 14:22:44 +0000
commitdbff3731a54b37dfe421e445dbf30f5f0c90c0fd (patch)
treeb5017a7a01d38b4e5892bab47b341cf9edc7321d /firmware/drivers/rtc/rtc_rx5x348ab.c
parentd40db1901ef33bb9d068efd871c1c1e42d04175f (diff)
downloadrockbox-dbff3731a54b37dfe421e445dbf30f5f0c90c0fd.tar.gz
rockbox-dbff3731a54b37dfe421e445dbf30f5f0c90c0fd.zip
enable the RTC on the mrobe.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15279 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/rtc/rtc_rx5x348ab.c')
-rw-r--r--firmware/drivers/rtc/rtc_rx5x348ab.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/firmware/drivers/rtc/rtc_rx5x348ab.c b/firmware/drivers/rtc/rtc_rx5x348ab.c
index 4899d99567..429a221b1a 100644
--- a/firmware/drivers/rtc/rtc_rx5x348ab.c
+++ b/firmware/drivers/rtc/rtc_rx5x348ab.c
@@ -21,15 +21,32 @@
#include "spi.h"
#include "rtc.h"
#include <stdbool.h>
-
+/* Choose one of: */
+#define ADDR_READ 0x04
+#define ADDR_WRITE 0x00
+/* and one of: */
+#define ADDR_ONE 0x08
+#define ADDR_BURST 0x00
void rtc_init(void)
{
}
-
+
int rtc_read_datetime(unsigned char* buf)
{
- char command = 0x04; /* burst read from the start of the time/date reg */
+ char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */
spi_block_transfer(SPI_target_RX5X348AB,
&command, 1, buf, 7);
return 1;
}
+int rtc_write_datetime(unsigned char* buf)
+{
+ char command = ADDR_WRITE|ADDR_BURST; /* burst read from the start of the time/date reg */
+ char data[8];
+ int i;
+ data[0] = command;
+ for (i=1;i<8;i++)
+ data[i] = buf[i-1];
+ spi_block_transfer(SPI_target_RX5X348AB,
+ data, 8, NULL, 0);
+ return 1;
+}