diff options
Diffstat (limited to 'firmware/drivers/pcf50605.c')
-rw-r--r-- | firmware/drivers/pcf50605.c | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/firmware/drivers/pcf50605.c b/firmware/drivers/pcf50605.c index 122ba6ee38..7d2036e807 100644 --- a/firmware/drivers/pcf50605.c +++ b/firmware/drivers/pcf50605.c | |||
@@ -98,22 +98,12 @@ int pcf50605_write_multiple(int address, const unsigned char* buf, int count) | |||
98 | return 0; | 98 | return 0; |
99 | } | 99 | } |
100 | 100 | ||
101 | static int pcf50605_a2d_read(int adc_input) | 101 | unsigned short pcf50605_a2d_read(int adc_input) |
102 | { | 102 | { |
103 | int hi, lo; | 103 | unsigned short hi; |
104 | unsigned char lo; | ||
104 | 105 | ||
105 | /* Enable ACD module */ | ||
106 | ipod_i2c_send(0x8, 0x33, 0x80); /* ACDC1, ACDAPE = 1 */ | ||
107 | |||
108 | /* select ADCIN1 - subtractor, and start sampling process */ | ||
109 | ipod_i2c_send(0x8, 0x2f, (adc_input<<1) | 0x1); /* ADCC2, ADCMUX = adc_input, ADCSTART = 1 */ | 106 | ipod_i2c_send(0x8, 0x2f, (adc_input<<1) | 0x1); /* ADCC2, ADCMUX = adc_input, ADCSTART = 1 */ |
110 | |||
111 | /* ADCC2, wait for ADCSTART = 0 (wait for sampling to start) */ | ||
112 | while ((i2c_readbyte(0x8, 0x2f) & 1)) /* do nothing */; | ||
113 | |||
114 | /* ADCS2, wait ADCRDY = 0 (wait for sampling to end) */ | ||
115 | while (!(i2c_readbyte(0x8, 0x31) & 0x80)) /* do nothing */; | ||
116 | |||
117 | hi = i2c_readbyte(0x8, 0x30); /* ADCS1 */ | 107 | hi = i2c_readbyte(0x8, 0x30); /* ADCS1 */ |
118 | lo = (i2c_readbyte(0x8, 0x31) & 0x3); /* ADCS2 */ | 108 | lo = (i2c_readbyte(0x8, 0x31) & 0x3); /* ADCS2 */ |
119 | 109 | ||
@@ -129,33 +119,3 @@ void pcf50605_standby_mode(void) | |||
129 | pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK); | 119 | pcf50605_write(OOCC1, GOSTDBY | CHGWAK | EXTONWAK); |
130 | } | 120 | } |
131 | 121 | ||
132 | int pcf50605_battery_read(void) | ||
133 | { | ||
134 | return pcf50605_a2d_read(0x3); /* ADCIN1, subtractor */ | ||
135 | } | ||
136 | |||
137 | void rtc_init(void) | ||
138 | { | ||
139 | /* Nothing to do. */ | ||
140 | } | ||
141 | |||
142 | int rtc_read_datetime(unsigned char* buf) | ||
143 | { | ||
144 | int rc; | ||
145 | |||
146 | rc = pcf50605_read_multiple(0x0a, buf, 7); | ||
147 | |||
148 | return rc; | ||
149 | } | ||
150 | |||
151 | |||
152 | int rtc_write_datetime(unsigned char* buf) | ||
153 | { | ||
154 | int i; | ||
155 | |||
156 | for (i=0;i<7;i++) { | ||
157 | ipod_i2c_send(0x8, 0x0a+i, buf[i]); | ||
158 | } | ||
159 | |||
160 | return 1; | ||
161 | } | ||