summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 66b37fc..2882c97 100644
--- a/firmware/drivers/rtc.c
+++ b/firmware/drivers/rtc.c
@@ -25,6 +25,14 @@
#define RTC_DEV_WRITE (RTC_ADR | 0x00)
#define RTC_DEV_READ (RTC_ADR | 0x01)
+void rtc_init(void)
+{
+ unsigned char data;
+ data = (unsigned int)rtc_read(0x0c);
+ data &= 0xbf;
+ rtc_write(0x0c,data);
+}
+
int rtc_write(unsigned char address, unsigned char value)
{
int ret = 0;
@@ -55,7 +63,7 @@ int rtc_read(unsigned char address)
buf[0] = address;
- /* send run command */
+ /* send read command */
if (i2c_write(RTC_DEV_READ,buf,1) >= 0)
{
i2c_start();
@@ -66,6 +74,8 @@ int rtc_read(unsigned char address)
}
}
+ i2c_stop();
+
i2c_end();
return value;
}