summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/rtc.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c
index 66b37fccb7..2882c975b7 100644
--- a/firmware/drivers/rtc.c
+++ b/firmware/drivers/rtc.c
@@ -25,6 +25,14 @@
25#define RTC_DEV_WRITE (RTC_ADR | 0x00) 25#define RTC_DEV_WRITE (RTC_ADR | 0x00)
26#define RTC_DEV_READ (RTC_ADR | 0x01) 26#define RTC_DEV_READ (RTC_ADR | 0x01)
27 27
28void rtc_init(void)
29{
30 unsigned char data;
31 data = (unsigned int)rtc_read(0x0c);
32 data &= 0xbf;
33 rtc_write(0x0c,data);
34}
35
28int rtc_write(unsigned char address, unsigned char value) 36int rtc_write(unsigned char address, unsigned char value)
29{ 37{
30 int ret = 0; 38 int ret = 0;
@@ -55,7 +63,7 @@ int rtc_read(unsigned char address)
55 63
56 buf[0] = address; 64 buf[0] = address;
57 65
58 /* send run command */ 66 /* send read command */
59 if (i2c_write(RTC_DEV_READ,buf,1) >= 0) 67 if (i2c_write(RTC_DEV_READ,buf,1) >= 0)
60 { 68 {
61 i2c_start(); 69 i2c_start();
@@ -66,6 +74,8 @@ int rtc_read(unsigned char address)
66 } 74 }
67 } 75 }
68 76
77 i2c_stop();
78
69 i2c_end(); 79 i2c_end();
70 return value; 80 return value;
71} 81}