diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 15 | ||||
-rw-r--r-- | firmware/drivers/rtc/rtc_e8564.c | 64 | ||||
-rw-r--r-- | firmware/drivers/rtc/rtc_m41st84w.c (renamed from firmware/drivers/rtc.c) | 95 | ||||
-rw-r--r-- | firmware/drivers/rtc/rtc_pcf50605.c | 45 | ||||
-rw-r--r-- | firmware/drivers/rtc/rtc_pcf50606.c | 51 |
5 files changed, 169 insertions, 101 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 6bc9df231b..beb51bef42 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -127,14 +127,17 @@ eeprom_settings.c | |||
127 | #endif /* HAVE_EEPROM */ | 127 | #endif /* HAVE_EEPROM */ |
128 | 128 | ||
129 | /* RTC */ | 129 | /* RTC */ |
130 | #if (CONFIG_RTC == RTC_M41ST84W) \ | ||
131 | || (CONFIG_RTC == RTC_PCF50606) \ | ||
132 | || (CONFIG_RTC == RTC_PCF50605) \ | ||
133 | || (CONFIG_RTC == RTC_E8564) | ||
134 | #ifndef SIMULATOR | 130 | #ifndef SIMULATOR |
135 | drivers/rtc.c | 131 | #if (CONFIG_RTC == RTC_M41ST84W) |
132 | drivers/rtc/rtc_m41st84w.c | ||
133 | #elif (CONFIG_RTC == RTC_PCF50606) | ||
134 | drivers/rtc/rtc_pcf50606.c | ||
135 | #elif (CONFIG_RTC == RTC_PCF50605) | ||
136 | drivers/rtc/rtc_pcf50605.c | ||
137 | #elif (CONFIG_RTC == RTC_E8564) | ||
138 | drivers/rtc/rtc_e8564.c | ||
139 | #endif /* (CONFIG_RTC == RTC_) */ | ||
136 | #endif /* SIMULATOR */ | 140 | #endif /* SIMULATOR */ |
137 | #endif /* (CONFIG_RTC == RTC_*) | ||
138 | 141 | ||
139 | /* Tuner */ | 142 | /* Tuner */ |
140 | #ifdef CONFIG_TUNER | 143 | #ifdef CONFIG_TUNER |
diff --git a/firmware/drivers/rtc/rtc_e8564.c b/firmware/drivers/rtc/rtc_e8564.c new file mode 100644 index 0000000000..233168c303 --- /dev/null +++ b/firmware/drivers/rtc/rtc_e8564.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "i2c.h" | ||
21 | #include "rtc.h" | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "i2c-pp5020.h" | ||
25 | #include <stdbool.h> | ||
26 | |||
27 | void rtc_init(void) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | int rtc_read_datetime(unsigned char* buf) | ||
32 | { | ||
33 | unsigned char tmp; | ||
34 | int read; | ||
35 | |||
36 | /*RTC_E8564's slave address is 0x51*/ | ||
37 | read = i2c_readbytes(0x51,0x02,7,buf); | ||
38 | |||
39 | /* swap wday and mday to be compatible with | ||
40 | * get_time() from firmware/common/timefuncs.c */ | ||
41 | tmp=buf[3]; | ||
42 | buf[3]=buf[4]; | ||
43 | buf[4]=tmp; | ||
44 | |||
45 | return read; | ||
46 | } | ||
47 | |||
48 | int rtc_write_datetime(unsigned char* buf) | ||
49 | { | ||
50 | int i; | ||
51 | unsigned char tmp; | ||
52 | |||
53 | /* swap wday and mday to be compatible with | ||
54 | * set_time() in firmware/common/timefuncs.c */ | ||
55 | tmp=buf[3]; | ||
56 | buf[3]=buf[4]; | ||
57 | buf[4]=tmp; | ||
58 | |||
59 | for (i=0;i<7;i++){ | ||
60 | pp_i2c_send(0x51, 0x02+i,buf[i]); | ||
61 | } | ||
62 | return 1; | ||
63 | } | ||
64 | |||
diff --git a/firmware/drivers/rtc.c b/firmware/drivers/rtc/rtc_m41st84w.c index 4f30539904..1d76867e13 100644 --- a/firmware/drivers/rtc.c +++ b/firmware/drivers/rtc/rtc_m41st84w.c | |||
@@ -17,108 +17,16 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | #ifdef CONFIG_RTC | ||
21 | #include "i2c.h" | 20 | #include "i2c.h" |
22 | #include "rtc.h" | 21 | #include "rtc.h" |
23 | #include "kernel.h" | 22 | #include "kernel.h" |
24 | #include "system.h" | 23 | #include "system.h" |
25 | #include "pcf50606.h" | ||
26 | #include "pcf50605.h" | ||
27 | #if CONFIG_RTC == RTC_E8564 | ||
28 | #include "i2c-pp5020.h" | ||
29 | #endif /*CONFIG_RTC == RTC_E8564*/ | ||
30 | #include <stdbool.h> | 24 | #include <stdbool.h> |
31 | 25 | ||
32 | #define RTC_ADR 0xd0 | 26 | #define RTC_ADR 0xd0 |
33 | #define RTC_DEV_WRITE (RTC_ADR | 0x00) | 27 | #define RTC_DEV_WRITE (RTC_ADR | 0x00) |
34 | #define RTC_DEV_READ (RTC_ADR | 0x01) | 28 | #define RTC_DEV_READ (RTC_ADR | 0x01) |
35 | 29 | ||
36 | #if CONFIG_RTC == RTC_E8564 | ||
37 | void rtc_init(void) | ||
38 | { | ||
39 | } | ||
40 | |||
41 | int rtc_read_datetime(unsigned char* buf) | ||
42 | { | ||
43 | unsigned char tmp; | ||
44 | int read; | ||
45 | |||
46 | /*RTC_E8564's slave address is 0x51*/ | ||
47 | read = i2c_readbytes(0x51,0x02,7,buf); | ||
48 | |||
49 | /* swap wday and mday to be compatible with | ||
50 | * get_time() from firmware/common/timefuncs.c */ | ||
51 | tmp=buf[3]; | ||
52 | buf[3]=buf[4]; | ||
53 | buf[4]=tmp; | ||
54 | |||
55 | return read; | ||
56 | } | ||
57 | |||
58 | int rtc_write_datetime(unsigned char* buf) | ||
59 | { | ||
60 | int i; | ||
61 | unsigned char tmp; | ||
62 | |||
63 | /* swap wday and mday to be compatible with | ||
64 | * set_time() in firmware/common/timefuncs.c */ | ||
65 | tmp=buf[3]; | ||
66 | buf[3]=buf[4]; | ||
67 | buf[4]=tmp; | ||
68 | |||
69 | for (i=0;i<7;i++){ | ||
70 | pp_i2c_send(0x51, 0x02+i,buf[i]); | ||
71 | } | ||
72 | return 1; | ||
73 | } | ||
74 | |||
75 | #elif CONFIG_RTC == RTC_PCF50605 | ||
76 | void rtc_init(void) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | int rtc_read_datetime(unsigned char* buf) | ||
81 | { | ||
82 | return pcf50605_read_multiple(0x0a, buf, 7); | ||
83 | } | ||
84 | |||
85 | int rtc_write_datetime(unsigned char* buf) | ||
86 | { | ||
87 | int i; | ||
88 | |||
89 | for (i=0;i<7;i++) { | ||
90 | pcf50605_write(0x0a+i, buf[i]); | ||
91 | } | ||
92 | |||
93 | return 1; | ||
94 | } | ||
95 | #elif CONFIG_RTC == RTC_PCF50606 | ||
96 | void rtc_init(void) | ||
97 | { | ||
98 | } | ||
99 | |||
100 | int rtc_read_datetime(unsigned char* buf) { | ||
101 | int rc; | ||
102 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
103 | |||
104 | rc = pcf50606_read_multiple(0x0a, buf, 7); | ||
105 | |||
106 | set_irq_level(oldlevel); | ||
107 | return rc; | ||
108 | } | ||
109 | |||
110 | int rtc_write_datetime(unsigned char* buf) { | ||
111 | int rc; | ||
112 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
113 | |||
114 | rc = pcf50606_write_multiple(0x0a, buf, 7); | ||
115 | |||
116 | set_irq_level(oldlevel); | ||
117 | |||
118 | return rc; | ||
119 | } | ||
120 | |||
121 | #else | ||
122 | void rtc_init(void) | 30 | void rtc_init(void) |
123 | { | 31 | { |
124 | unsigned char data; | 32 | unsigned char data; |
@@ -370,6 +278,3 @@ int rtc_write_datetime(unsigned char* buf) { | |||
370 | 278 | ||
371 | return rc; | 279 | return rc; |
372 | } | 280 | } |
373 | #endif /* CONFIG_RTC == RTC_PCF50606 */ | ||
374 | |||
375 | #endif /* CONFIG_RTC */ | ||
diff --git a/firmware/drivers/rtc/rtc_pcf50605.c b/firmware/drivers/rtc/rtc_pcf50605.c new file mode 100644 index 0000000000..1bc40146ff --- /dev/null +++ b/firmware/drivers/rtc/rtc_pcf50605.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "i2c.h" | ||
21 | #include "rtc.h" | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "pcf50605.h" | ||
25 | #include <stdbool.h> | ||
26 | |||
27 | void rtc_init(void) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | int rtc_read_datetime(unsigned char* buf) | ||
32 | { | ||
33 | return pcf50605_read_multiple(0x0a, buf, 7); | ||
34 | } | ||
35 | |||
36 | int rtc_write_datetime(unsigned char* buf) | ||
37 | { | ||
38 | int i; | ||
39 | |||
40 | for (i=0;i<7;i++) { | ||
41 | pcf50605_write(0x0a+i, buf[i]); | ||
42 | } | ||
43 | |||
44 | return 1; | ||
45 | } | ||
diff --git a/firmware/drivers/rtc/rtc_pcf50606.c b/firmware/drivers/rtc/rtc_pcf50606.c new file mode 100644 index 0000000000..25b0c704c0 --- /dev/null +++ b/firmware/drivers/rtc/rtc_pcf50606.c | |||
@@ -0,0 +1,51 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing, Uwe Freese, Laurent Baum | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "i2c.h" | ||
21 | #include "rtc.h" | ||
22 | #include "kernel.h" | ||
23 | #include "system.h" | ||
24 | #include "pcf50606.h" | ||
25 | #include <stdbool.h> | ||
26 | |||
27 | void rtc_init(void) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | int rtc_read_datetime(unsigned char* buf) { | ||
32 | int rc; | ||
33 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
34 | |||
35 | rc = pcf50606_read_multiple(0x0a, buf, 7); | ||
36 | |||
37 | set_irq_level(oldlevel); | ||
38 | return rc; | ||
39 | } | ||
40 | |||
41 | int rtc_write_datetime(unsigned char* buf) { | ||
42 | int rc; | ||
43 | int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
44 | |||
45 | rc = pcf50606_write_multiple(0x0a, buf, 7); | ||
46 | |||
47 | set_irq_level(oldlevel); | ||
48 | |||
49 | return rc; | ||
50 | } | ||
51 | |||