summaryrefslogtreecommitdiff
path: root/firmware/drivers/rtc/rtc_rx5x348ab.c
diff options
context:
space:
mode:
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 @@
21#include "spi.h" 21#include "spi.h"
22#include "rtc.h" 22#include "rtc.h"
23#include <stdbool.h> 23#include <stdbool.h>
24 24/* Choose one of: */
25#define ADDR_READ 0x04
26#define ADDR_WRITE 0x00
27/* and one of: */
28#define ADDR_ONE 0x08
29#define ADDR_BURST 0x00
25void rtc_init(void) 30void rtc_init(void)
26{ 31{
27} 32}
28 33
29int rtc_read_datetime(unsigned char* buf) 34int rtc_read_datetime(unsigned char* buf)
30{ 35{
31 char command = 0x04; /* burst read from the start of the time/date reg */ 36 char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */
32 spi_block_transfer(SPI_target_RX5X348AB, 37 spi_block_transfer(SPI_target_RX5X348AB,
33 &command, 1, buf, 7); 38 &command, 1, buf, 7);
34 return 1; 39 return 1;
35} 40}
41int rtc_write_datetime(unsigned char* buf)
42{
43 char command = ADDR_WRITE|ADDR_BURST; /* burst read from the start of the time/date reg */
44 char data[8];
45 int i;
46 data[0] = command;
47 for (i=1;i<8;i++)
48 data[i] = buf[i-1];
49 spi_block_transfer(SPI_target_RX5X348AB,
50 data, 8, NULL, 0);
51 return 1;
52}