diff options
Diffstat (limited to 'firmware/drivers/rtc.c')
-rw-r--r-- | firmware/drivers/rtc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc.c index b77db8b865..0e6d68eb1a 100644 --- a/firmware/drivers/rtc.c +++ b/firmware/drivers/rtc.c | |||
@@ -21,12 +21,41 @@ | |||
21 | #include "i2c.h" | 21 | #include "i2c.h" |
22 | #include "rtc.h" | 22 | #include "rtc.h" |
23 | #include "kernel.h" | 23 | #include "kernel.h" |
24 | #include "system.h" | ||
25 | #include "pcf50606.h" | ||
24 | #include <stdbool.h> | 26 | #include <stdbool.h> |
25 | 27 | ||
26 | #define RTC_ADR 0xd0 | 28 | #define RTC_ADR 0xd0 |
27 | #define RTC_DEV_WRITE (RTC_ADR | 0x00) | 29 | #define RTC_DEV_WRITE (RTC_ADR | 0x00) |
28 | #define RTC_DEV_READ (RTC_ADR | 0x01) | 30 | #define RTC_DEV_READ (RTC_ADR | 0x01) |
29 | 31 | ||
32 | #if CONFIG_RTC == RTC_PCF50606 | ||
33 | void rtc_init(void) | ||
34 | { | ||
35 | } | ||
36 | int rtc_read_datetime(unsigned char* buf) { | ||
37 | int rc; | ||
38 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
39 | |||
40 | rc = pcf50606_read_multiple(0x0a, buf, 7); | ||
41 | |||
42 | set_irq_level(oldlevel); | ||
43 | |||
44 | return rc; | ||
45 | } | ||
46 | |||
47 | int rtc_write_datetime(unsigned char* buf) { | ||
48 | int rc; | ||
49 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
50 | |||
51 | rc = pcf50606_write_multiple(0x0a, buf, 7); | ||
52 | |||
53 | set_irq_level(oldlevel); | ||
54 | |||
55 | return rc; | ||
56 | } | ||
57 | |||
58 | #else | ||
30 | void rtc_init(void) | 59 | void rtc_init(void) |
31 | { | 60 | { |
32 | unsigned char data; | 61 | unsigned char data; |
@@ -278,5 +307,6 @@ int rtc_write_datetime(unsigned char* buf) { | |||
278 | 307 | ||
279 | return rc; | 308 | return rc; |
280 | } | 309 | } |
310 | #endif /* CONFIG_RTC == RTC_PCF50606 */ | ||
281 | 311 | ||
282 | #endif /* CONFIG_RTC */ | 312 | #endif /* CONFIG_RTC */ |