From 2e2f92c9066734040525347c8cb6d87f91e55c2c Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 30 Jul 2007 19:13:59 +0000 Subject: [PATCH] H1x0, H300: Get rid of the adc tick, and use the same concept as the iAudio ADC driver. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14079 a1c6a512-1295-4272-9138-f99709370657 --- .../target/coldfire/iriver/h100/adc-h100.c | 26 ++-------------- .../target/coldfire/iriver/h100/adc-target.h | 5 ++++ .../target/coldfire/iriver/h300/adc-h300.c | 30 ------------------- .../target/coldfire/iriver/h300/adc-target.h | 7 +++++ 4 files changed, 14 insertions(+), 54 deletions(-) diff --git a/firmware/target/coldfire/iriver/h100/adc-h100.c b/firmware/target/coldfire/iriver/h100/adc-h100.c index 777ab2ff73..b69204aa02 100644 --- a/firmware/target/coldfire/iriver/h100/adc-h100.c +++ b/firmware/target/coldfire/iriver/h100/adc-h100.c @@ -22,7 +22,6 @@ #include "kernel.h" #include "thread.h" #include "adc.h" -static unsigned char adcdata[NUM_ADC_CHANNELS]; #define CS_LO and_l(~0x80, &GPIO_OUT) @@ -48,6 +47,7 @@ static unsigned char adcdata[NUM_ADC_CHANNELS]; unsigned short adc_scan(int channel) { + int level = set_irq_level(HIGHEST_IRQ_LEVEL); unsigned char data = 0; int i; @@ -97,27 +97,9 @@ unsigned short adc_scan(int channel) CS_HI; - adcdata[channel] = data; - + set_irq_level(level); return data; } -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; - adc_scan(ADC_BATTERY); - adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote - detection feels stable. */ - } -} void adc_init(void) { @@ -128,8 +110,4 @@ void adc_init(void) or_l(0x00600080, &GPIO_ENABLE); or_l(0x80, &GPIO_OUT); /* CS high */ and_l(~0x00400000, &GPIO_OUT); /* CLK low */ - - adc_scan(ADC_BATTERY); - - tick_add_task(adc_tick); } diff --git a/firmware/target/coldfire/iriver/h100/adc-target.h b/firmware/target/coldfire/iriver/h100/adc-target.h index 54e7bc936a..f5161edd68 100644 --- a/firmware/target/coldfire/iriver/h100/adc-target.h +++ b/firmware/target/coldfire/iriver/h100/adc-target.h @@ -38,4 +38,9 @@ /* Force a scan now */ unsigned short adc_scan(int channel); +static inline unsigned short adc_read(int channel) +{ + return adc_scan(channel); +} + #endif /* _ADC_TARGET_H_ */ diff --git a/firmware/target/coldfire/iriver/h300/adc-h300.c b/firmware/target/coldfire/iriver/h300/adc-h300.c index 140eafe0ab..77d7b4689f 100644 --- a/firmware/target/coldfire/iriver/h300/adc-h300.c +++ b/firmware/target/coldfire/iriver/h300/adc-h300.c @@ -24,8 +24,6 @@ #include "adc.h" #include "pcf50606.h" -static unsigned char adcdata[NUM_ADC_CHANNELS]; - static int adcc2_parms[] = { [ADC_BUTTONS] = 0x80 | (5 << 1) | 1, /* ADCIN2 */ @@ -42,34 +40,6 @@ unsigned short adc_scan(int channel) pcf50606_write(0x2f, adcc2_parms[channel]); data = pcf50606_read(0x30); - adcdata[channel] = data; - set_irq_level(level); return data; } - - -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; - adc_scan(ADC_BATTERY); - adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote - detection feels stable. */ - } -} - -void adc_init(void) -{ - adc_scan(ADC_BATTERY); - - tick_add_task(adc_tick); -} diff --git a/firmware/target/coldfire/iriver/h300/adc-target.h b/firmware/target/coldfire/iriver/h300/adc-target.h index 04200904a2..211a527253 100644 --- a/firmware/target/coldfire/iriver/h300/adc-target.h +++ b/firmware/target/coldfire/iriver/h300/adc-target.h @@ -38,4 +38,11 @@ /* Force a scan now */ unsigned short adc_scan(int channel); +static inline unsigned short adc_read(int channel) +{ + return adc_scan(channel); +} +static inline void adc_init(void) +{} + #endif /* _ADC_TARGET_H_ */