diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/adc.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index c79c22ce0f..c9ae2daca8 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "thread.h" | 23 | #include "thread.h" |
24 | #include "adc.h" | 24 | #include "adc.h" |
25 | #include "pcf50606.h" | ||
25 | 26 | ||
26 | #if CONFIG_CPU == SH7034 | 27 | #if CONFIG_CPU == SH7034 |
27 | /************************************************************************** | 28 | /************************************************************************** |
@@ -107,9 +108,29 @@ void adc_init(void) | |||
107 | sleep(2); /* Ensure valid readings when adc_init returns */ | 108 | sleep(2); /* Ensure valid readings when adc_init returns */ |
108 | } | 109 | } |
109 | #elif CONFIG_CPU == MCF5249 | 110 | #elif CONFIG_CPU == MCF5249 |
110 | |||
111 | static unsigned char adcdata[NUM_ADC_CHANNELS]; | 111 | static unsigned char adcdata[NUM_ADC_CHANNELS]; |
112 | 112 | ||
113 | #ifdef IRIVER_H300_SERIES | ||
114 | static int channelnum[] = | ||
115 | { | ||
116 | 5, /* ADC_BUTTONS */ | ||
117 | 6, /* ADC_REMOTE */ | ||
118 | 0, /* ADC_BATTERY */ | ||
119 | }; | ||
120 | |||
121 | unsigned char adc_scan(int channel) | ||
122 | { | ||
123 | unsigned char data; | ||
124 | |||
125 | pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); | ||
126 | data = pcf50606_read(0x30); | ||
127 | |||
128 | adcdata[channel] = data; | ||
129 | |||
130 | return data; | ||
131 | } | ||
132 | #else | ||
133 | |||
113 | #define CS_LO and_l(~0x80, &GPIO_OUT) | 134 | #define CS_LO and_l(~0x80, &GPIO_OUT) |
114 | #define CS_HI or_l(0x80, &GPIO_OUT) | 135 | #define CS_HI or_l(0x80, &GPIO_OUT) |
115 | #define CLK_LO and_l(~0x00400000, &GPIO_OUT) | 136 | #define CLK_LO and_l(~0x00400000, &GPIO_OUT) |
@@ -176,6 +197,7 @@ unsigned char adc_scan(int channel) | |||
176 | 197 | ||
177 | return data; | 198 | return data; |
178 | } | 199 | } |
200 | #endif | ||
179 | 201 | ||
180 | unsigned short adc_read(int channel) | 202 | unsigned short adc_read(int channel) |
181 | { | 203 | { |
@@ -195,6 +217,8 @@ static void adc_tick(void) | |||
195 | 217 | ||
196 | void adc_init(void) | 218 | void adc_init(void) |
197 | { | 219 | { |
220 | #ifdef IRIVER_H300_SERIES | ||
221 | #else | ||
198 | or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS | 222 | or_l(0x80600080, &GPIO_FUNCTION); /* GPIO7: CS |
199 | GPIO21: Data In (to the ADC) | 223 | GPIO21: Data In (to the ADC) |
200 | GPIO22: CLK | 224 | GPIO22: CLK |
@@ -202,6 +226,7 @@ void adc_init(void) | |||
202 | or_l(0x00600080, &GPIO_ENABLE); | 226 | or_l(0x00600080, &GPIO_ENABLE); |
203 | or_l(0x80, &GPIO_OUT); /* CS high */ | 227 | or_l(0x80, &GPIO_OUT); /* CS high */ |
204 | and_l(~0x00400000, &GPIO_OUT); /* CLK low */ | 228 | and_l(~0x00400000, &GPIO_OUT); /* CLK low */ |
229 | #endif | ||
205 | 230 | ||
206 | adc_scan(ADC_BATTERY); | 231 | adc_scan(ADC_BATTERY); |
207 | 232 | ||