summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/rtc.c34
-rw-r--r--firmware/drivers/rtc.h1
2 files changed, 34 insertions, 1 deletions
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c
index c8e19aab53..d052247986 100644
--- a/firmware/drivers/rtc.c
+++ b/firmware/drivers/rtc.c
@@ -65,7 +65,6 @@ int rtc_write(unsigned char address, unsigned char value)
65 return ret; 65 return ret;
66} 66}
67 67
68
69int rtc_read(unsigned char address) 68int rtc_read(unsigned char address)
70{ 69{
71 int value = -1; 70 int value = -1;
@@ -92,4 +91,37 @@ int rtc_read(unsigned char address)
92 return value; 91 return value;
93} 92}
94 93
94int rtc_read_multiple(unsigned char address, unsigned char *buf, int numbytes)
95{
96 int ret = 0;
97 unsigned char obuf[1];
98 int i;
99
100 i2c_begin();
101
102 obuf[0] = address;
103
104 /* send read command */
105 if (i2c_write(RTC_DEV_READ, obuf, 1) >= 0)
106 {
107 i2c_start();
108 i2c_outb(RTC_DEV_READ);
109 if (i2c_getack())
110 {
111 for(i = 0;i < numbytes-1;i++)
112 buf[i] = i2c_inb(0);
113
114 buf[i] = i2c_inb(1);
115 }
116 else
117 {
118 ret = -1;
119 }
120 }
121
122 i2c_stop();
123
124 i2c_end();
125 return ret;
126}
95#endif 127#endif
diff --git a/firmware/drivers/rtc.h b/firmware/drivers/rtc.h
index 695683ea87..7b101ee62e 100644
--- a/firmware/drivers/rtc.h
+++ b/firmware/drivers/rtc.h
@@ -22,6 +22,7 @@
22#ifdef HAVE_RTC 22#ifdef HAVE_RTC
23void rtc_init(void); 23void rtc_init(void);
24int rtc_read(unsigned char address); 24int rtc_read(unsigned char address);
25int rtc_read_multiple(unsigned char address, unsigned char *buf, int numbytes);
25int rtc_write(unsigned char address, unsigned char value); 26int rtc_write(unsigned char address, unsigned char value);
26#endif 27#endif
27 28