summaryrefslogtreecommitdiff
path: root/firmware/drivers/adc.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/adc.c')
-rw-r--r--firmware/drivers/adc.c57
1 files changed, 0 insertions, 57 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index d00f89958a..9e6ed19e4b 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -23,7 +23,6 @@
23#include "thread.h" 23#include "thread.h"
24#include "string.h" 24#include "string.h"
25#include "adc.h" 25#include "adc.h"
26#include "pcf50605.h"
27#include "pcf50606.h" 26#include "pcf50606.h"
28 27
29#if CONFIG_CPU == SH7034 28#if CONFIG_CPU == SH7034
@@ -285,62 +284,6 @@ void adc_init(void)
285 sleep(2); /* Ensure valid readings when adc_init returns */ 284 sleep(2); /* Ensure valid readings when adc_init returns */
286} 285}
287 286
288#elif defined(IPOD_ARCH)
289
290struct adc_struct {
291 long timeout;
292 void (*conversion)(unsigned short *data);
293 short channelnum;
294 unsigned short data;
295};
296
297static struct adc_struct adcdata[NUM_ADC_CHANNELS] IDATA_ATTR;
298
299static unsigned short _adc_read(struct adc_struct *adc)
300{
301 if (adc->timeout < current_tick) {
302 unsigned char data[2];
303 unsigned short value;
304 /* 5x per 2 seconds */
305 adc->timeout = current_tick + (HZ * 2 / 5);
306
307 /* ADCC1, 10 bit, start */
308 pcf50605_write(0x2f, (adc->channelnum << 1) | 0x1);
309 pcf50605_read_multiple(0x30, data, 2); /* ADCS1, ADCS2 */
310 value = data[0];
311 value <<= 2;
312 value |= data[1] & 0x3;
313
314 if (adc->conversion) {
315 adc->conversion(&value);
316 }
317 adc->data = value;
318 return value;
319 } else {
320 return adc->data;
321 }
322}
323
324/* Force an ADC scan _now_ */
325unsigned short adc_scan(int channel) {
326 struct adc_struct *adc = &adcdata[channel];
327 adc->timeout = 0;
328 return _adc_read(adc);
329}
330
331/* Retrieve the ADC value, only does a scan periodically */
332unsigned short adc_read(int channel) {
333 return _adc_read(&adcdata[channel]);
334}
335
336void adc_init(void)
337{
338 struct adc_struct *adc_battery = &adcdata[ADC_BATTERY];
339 adc_battery->channelnum = 0x2; /* ADCVIN1, resistive divider */
340 adc_battery->timeout = 0;
341 _adc_read(adc_battery);
342}
343
344#elif CONFIG_CPU == PNX0101 287#elif CONFIG_CPU == PNX0101
345 288
346static unsigned short adcdata[NUM_ADC_CHANNELS]; 289static unsigned short adcdata[NUM_ADC_CHANNELS];