summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iriver/h100/adc-h100.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iriver/h100/adc-h100.c')
-rw-r--r--firmware/target/coldfire/iriver/h100/adc-h100.c26
1 files changed, 2 insertions, 24 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 @@
22#include "kernel.h" 22#include "kernel.h"
23#include "thread.h" 23#include "thread.h"
24#include "adc.h" 24#include "adc.h"
25static unsigned char adcdata[NUM_ADC_CHANNELS];
26 25
27 26
28#define CS_LO and_l(~0x80, &GPIO_OUT) 27#define CS_LO and_l(~0x80, &GPIO_OUT)
@@ -48,6 +47,7 @@ static unsigned char adcdata[NUM_ADC_CHANNELS];
48 47
49unsigned short adc_scan(int channel) 48unsigned short adc_scan(int channel)
50{ 49{
50 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
51 unsigned char data = 0; 51 unsigned char data = 0;
52 int i; 52 int i;
53 53
@@ -97,27 +97,9 @@ unsigned short adc_scan(int channel)
97 97
98 CS_HI; 98 CS_HI;
99 99
100 adcdata[channel] = data; 100 set_irq_level(level);
101
102 return data; 101 return data;
103} 102}
104unsigned short adc_read(int channel)
105{
106 return adcdata[channel];
107}
108
109static int adc_counter;
110
111static void adc_tick(void)
112{
113 if(++adc_counter == HZ)
114 {
115 adc_counter = 0;
116 adc_scan(ADC_BATTERY);
117 adc_scan(ADC_REMOTEDETECT); /* Temporary. Remove when the remote
118 detection feels stable. */
119 }
120}
121 103
122void adc_init(void) 104void adc_init(void)
123{ 105{
@@ -128,8 +110,4 @@ void adc_init(void)
128 or_l(0x00600080, &GPIO_ENABLE); 110 or_l(0x00600080, &GPIO_ENABLE);
129 or_l(0x80, &GPIO_OUT); /* CS high */ 111 or_l(0x80, &GPIO_OUT); /* CS high */
130 and_l(~0x00400000, &GPIO_OUT); /* CLK low */ 112 and_l(~0x00400000, &GPIO_OUT); /* CLK low */
131
132 adc_scan(ADC_BATTERY);
133
134 tick_add_task(adc_tick);
135} 113}