From 003247e066f667bd829739eed138940c45a0569f Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Thu, 18 Nov 2004 23:23:47 +0000 Subject: [PATCH] Added iRiver ADC tick task git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5431 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/adc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index 4b11c7dbab..46890badd4 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c @@ -179,6 +179,17 @@ unsigned short adc_read(int channel) return adcdata[channel]; } +static int adc_counter; + +static void adc_tick(void) +{ + if(++adc_counter == HZ) + { + adc_counter = 0; + adcdata[ADC_BATTERY] = adc_scan(ADC_BATTERY); + } +} + void adc_init(void) { GPIO_FUNCTION |= 0x80600080; /* GPIO7: CS @@ -188,6 +199,10 @@ void adc_init(void) GPIO_ENABLE |= 0x00600080; GPIO_OUT |= 0x80; /* CS high */ GPIO_OUT &= ~0x00400000; /* CLK low */ + + tick_add_task(adc_tick); + + adcdata[3] = adc_scan(3); } #endif