summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/adc.c16
-rw-r--r--firmware/export/adc.h10
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/adc-x5.c68
3 files changed, 77 insertions, 17 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index b71583ca05..e565372fac 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -332,19 +332,3 @@ void adc_init(void)
332} 332}
333 333
334#endif 334#endif
335#ifdef IAUDIO_X5
336unsigned char adc_scan(int channel)
337{
338 return 0;
339}
340
341unsigned short adc_read(int channel)
342{
343 return 0;
344}
345
346void adc_init(void)
347{
348}
349
350#endif
diff --git a/firmware/export/adc.h b/firmware/export/adc.h
index 4082e4b39b..027c7154f0 100644
--- a/firmware/export/adc.h
+++ b/firmware/export/adc.h
@@ -21,7 +21,15 @@
21 21
22#include "config.h" 22#include "config.h"
23 23
24#if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) 24#ifdef IAUDIO_X5
25#define NUM_ADC_CHANNELS 3
26
27#define ADC_BUTTONS 0
28#define ADC_REMOTE 1
29#define ADC_BATTERY 2
30#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
31
32#elif defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
25#define NUM_ADC_CHANNELS 4 33#define NUM_ADC_CHANNELS 4
26 34
27#define ADC_BUTTONS 0 35#define ADC_BUTTONS 0
diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c
new file mode 100755
index 0000000000..c67b8b5c98
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/adc-x5.c
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "cpu.h"
21#include "system.h"
22#include "kernel.h"
23#include "thread.h"
24#include "adc.h"
25#include "pcf50606.h"
26
27static unsigned char adcdata[NUM_ADC_CHANNELS];
28
29static int channelnum[] =
30{
31 5, /* ADC_BUTTONS (ADCIN2) */
32 6, /* ADC_REMOTE (ADCIN3) */
33 0, /* ADC_BATTERY (BATVOLT, resistive divider) */
34};
35
36unsigned char adc_scan(int channel)
37{
38 unsigned char data;
39
40 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1);
41 data = pcf50606_read(0x30);
42
43 adcdata[channel] = data;
44
45 return data;
46}
47
48unsigned short adc_read(int channel)
49{
50 return adcdata[channel];
51}
52
53static int adc_counter;
54
55static void adc_tick(void)
56{
57 if(++adc_counter == HZ)
58 {
59 adc_counter = 0;
60 adc_scan(ADC_BATTERY);
61 }
62}
63
64void adc_init(void)
65{
66 adc_scan(ADC_BATTERY);
67 tick_add_task(adc_tick);
68}