diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-01-27 03:19:57 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-01-27 03:19:57 +0000 |
commit | 04992ef050a2bef8387f84efc6988211c34e19b7 (patch) | |
tree | b9f5682b66fde3548ae059c4a6b0785024997274 | |
parent | a4e7bc383ed296b532a648a02db62a06c99c9ad8 (diff) | |
download | rockbox-04992ef050a2bef8387f84efc6988211c34e19b7.tar.gz rockbox-04992ef050a2bef8387f84efc6988211c34e19b7.zip |
Move the PP5020 ADC defines to the c-file instead of repeating them across the header files. Also, the Tatung TPJ1022 should use the common PP5020 ADC driver.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19864 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/target/arm/adc-pp5020.c | 6 | ||||
-rw-r--r-- | firmware/target/arm/iriver/h10/adc-target.h | 6 | ||||
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/adc-target.h | 6 | ||||
-rw-r--r-- | firmware/target/arm/philips/hdd1630/adc-target.h | 6 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/adc-target.h | 9 | ||||
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/adc-tpj1022.c | 103 |
7 files changed, 7 insertions, 131 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 4df4fae9a2..46c46c2ce2 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -857,7 +857,7 @@ target/arm/ata-as-arm.S | |||
857 | target/arm/ata-pp5020.c | 857 | target/arm/ata-pp5020.c |
858 | target/arm/wmcodec-pp.c | 858 | target/arm/wmcodec-pp.c |
859 | target/arm/i2s-pp.c | 859 | target/arm/i2s-pp.c |
860 | target/arm/tatung/tpj1022/adc-tpj1022.c | 860 | target/arm/adc-pp5020.c |
861 | target/arm/tatung/tpj1022/backlight-tpj1022.c | 861 | target/arm/tatung/tpj1022/backlight-tpj1022.c |
862 | target/arm/tatung/tpj1022/button-tpj1022.c | 862 | target/arm/tatung/tpj1022/button-tpj1022.c |
863 | target/arm/tatung/tpj1022/lcd-tpj1022.c | 863 | target/arm/tatung/tpj1022/lcd-tpj1022.c |
diff --git a/firmware/target/arm/adc-pp5020.c b/firmware/target/arm/adc-pp5020.c index 33950014dc..e270a41235 100644 --- a/firmware/target/arm/adc-pp5020.c +++ b/firmware/target/arm/adc-pp5020.c | |||
@@ -25,6 +25,12 @@ | |||
25 | #include "thread.h" | 25 | #include "thread.h" |
26 | #include "adc.h" | 26 | #include "adc.h" |
27 | 27 | ||
28 | #define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
29 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
30 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
31 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
32 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
33 | |||
28 | static unsigned short adcdata[NUM_ADC_CHANNELS]; | 34 | static unsigned short adcdata[NUM_ADC_CHANNELS]; |
29 | 35 | ||
30 | /* Scan ADC so that adcdata[channel] gets updated. */ | 36 | /* Scan ADC so that adcdata[channel] gets updated. */ |
diff --git a/firmware/target/arm/iriver/h10/adc-target.h b/firmware/target/arm/iriver/h10/adc-target.h index 4eeebb2fd8..ba3e98de47 100644 --- a/firmware/target/arm/iriver/h10/adc-target.h +++ b/firmware/target/arm/iriver/h10/adc-target.h | |||
@@ -21,12 +21,6 @@ | |||
21 | #ifndef _ADC_TARGET_H_ | 21 | #ifndef _ADC_TARGET_H_ |
22 | #define _ADC_TARGET_H_ | 22 | #define _ADC_TARGET_H_ |
23 | 23 | ||
24 | #define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
25 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
26 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
27 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
28 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
29 | |||
30 | #define NUM_ADC_CHANNELS 4 | 24 | #define NUM_ADC_CHANNELS 4 |
31 | 25 | ||
32 | #define ADC_BATTERY 0 | 26 | #define ADC_BATTERY 0 |
diff --git a/firmware/target/arm/olympus/mrobe-100/adc-target.h b/firmware/target/arm/olympus/mrobe-100/adc-target.h index cebd07c94a..ee9e294c6b 100644 --- a/firmware/target/arm/olympus/mrobe-100/adc-target.h +++ b/firmware/target/arm/olympus/mrobe-100/adc-target.h | |||
@@ -21,12 +21,6 @@ | |||
21 | #ifndef _ADC_TARGET_H_ | 21 | #ifndef _ADC_TARGET_H_ |
22 | #define _ADC_TARGET_H_ | 22 | #define _ADC_TARGET_H_ |
23 | 23 | ||
24 | #define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
25 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
26 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
27 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
28 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
29 | |||
30 | #define NUM_ADC_CHANNELS 4 | 24 | #define NUM_ADC_CHANNELS 4 |
31 | 25 | ||
32 | #define ADC_BATTERY 0 | 26 | #define ADC_BATTERY 0 |
diff --git a/firmware/target/arm/philips/hdd1630/adc-target.h b/firmware/target/arm/philips/hdd1630/adc-target.h index cebd07c94a..ee9e294c6b 100644 --- a/firmware/target/arm/philips/hdd1630/adc-target.h +++ b/firmware/target/arm/philips/hdd1630/adc-target.h | |||
@@ -21,12 +21,6 @@ | |||
21 | #ifndef _ADC_TARGET_H_ | 21 | #ifndef _ADC_TARGET_H_ |
22 | #define _ADC_TARGET_H_ | 22 | #define _ADC_TARGET_H_ |
23 | 23 | ||
24 | #define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
25 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
26 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
27 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
28 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
29 | |||
30 | #define NUM_ADC_CHANNELS 4 | 24 | #define NUM_ADC_CHANNELS 4 |
31 | 25 | ||
32 | #define ADC_BATTERY 0 | 26 | #define ADC_BATTERY 0 |
diff --git a/firmware/target/arm/tatung/tpj1022/adc-target.h b/firmware/target/arm/tatung/tpj1022/adc-target.h index 56b70b95c5..026bb58089 100644 --- a/firmware/target/arm/tatung/tpj1022/adc-target.h +++ b/firmware/target/arm/tatung/tpj1022/adc-target.h | |||
@@ -21,15 +21,6 @@ | |||
21 | #ifndef _ADC_TARGET_H_ | 21 | #ifndef _ADC_TARGET_H_ |
22 | #define _ADC_TARGET_H_ | 22 | #define _ADC_TARGET_H_ |
23 | 23 | ||
24 | #define ADC_ENABLE_ADDR (*(volatile unsigned long*)(0x70000010)) | ||
25 | #define ADC_ENABLE 0x1100 | ||
26 | |||
27 | #define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) | ||
28 | #define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) | ||
29 | #define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) | ||
30 | #define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) | ||
31 | #define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) | ||
32 | |||
33 | #define NUM_ADC_CHANNELS 4 | 24 | #define NUM_ADC_CHANNELS 4 |
34 | 25 | ||
35 | #define ADC_BATTERY 0 | 26 | #define ADC_BATTERY 0 |
diff --git a/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c b/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c deleted file mode 100644 index 843ab68fb6..0000000000 --- a/firmware/target/arm/tatung/tpj1022/adc-tpj1022.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | #include "system.h" | ||
24 | #include "kernel.h" | ||
25 | #include "thread.h" | ||
26 | #include "adc.h" | ||
27 | |||
28 | static unsigned short adcdata[NUM_ADC_CHANNELS]; | ||
29 | |||
30 | /* Scan ADC so that adcdata[channel] gets updated */ | ||
31 | unsigned short adc_scan(int channel) | ||
32 | { | ||
33 | unsigned int adc_data_1; | ||
34 | unsigned int adc_data_2; | ||
35 | |||
36 | /* Initialise */ | ||
37 | ADC_ADDR=0x130; | ||
38 | ADC_STATUS=0; /* 4 bytes, 1 per channel. Each byte is 0 if the channel is | ||
39 | off, 0x40 if the channel is on */ | ||
40 | |||
41 | /* Enable Channel */ | ||
42 | ADC_ADDR |= (0x1000000<<channel); | ||
43 | |||
44 | /* Start? */ | ||
45 | ADC_ADDR |= 0x20000000; | ||
46 | ADC_ADDR |= 0x80000000; | ||
47 | |||
48 | /* ADC_DATA_1 and ADC_DATA_2 are both four bytes, one byte per channel. | ||
49 | For each channel, ADC_DATA_1 stores the 8-bit msb, ADC_DATA_2 stores the | ||
50 | 2-bit lsb (in bits 0 and 1). Each channel is 10 bits total. */ | ||
51 | adc_data_1 = ((ADC_DATA_1 >> (8*channel)) & 0xff); | ||
52 | adc_data_2 = ((ADC_DATA_2 >> (8*channel+6)) & 0x3); | ||
53 | |||
54 | adcdata[channel] = (adc_data_1<<2 | adc_data_2); | ||
55 | |||
56 | return adcdata[channel]; | ||
57 | } | ||
58 | |||
59 | /* Read 10-bit channel data */ | ||
60 | unsigned short adc_read(int channel) | ||
61 | { | ||
62 | return adcdata[channel]; | ||
63 | } | ||
64 | |||
65 | static int adc_counter; | ||
66 | |||
67 | static void adc_tick(void) | ||
68 | { | ||
69 | if(++adc_counter == HZ) | ||
70 | { | ||
71 | adc_counter = 0; | ||
72 | adc_scan(ADC_BATTERY); | ||
73 | adc_scan(ADC_UNKNOWN_1); | ||
74 | adc_scan(ADC_UNKNOWN_2); | ||
75 | adc_scan(ADC_SCROLLPAD); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | void adc_init(void) | ||
80 | { | ||
81 | /* Enable ADC */ | ||
82 | ADC_ENABLE_ADDR |= ADC_ENABLE; | ||
83 | |||
84 | /* Initialise */ | ||
85 | ADC_INIT=0; | ||
86 | ADC_ADDR=0x130; | ||
87 | ADC_STATUS=0; | ||
88 | |||
89 | /* Enable Channels 1-4 */ | ||
90 | ADC_ADDR |= 0x1000000; | ||
91 | ADC_ADDR |= 0x2000000; | ||
92 | ADC_ADDR |= 0x4000000; | ||
93 | ADC_ADDR |= 0x8000000; | ||
94 | |||
95 | /* Start? */ | ||
96 | ADC_ADDR |= 0x20000000; | ||
97 | ADC_ADDR |= 0x80000000; | ||
98 | |||
99 | /* Wait 50ms for things to settle */ | ||
100 | sleep(HZ/20); | ||
101 | |||
102 | tick_add_task(adc_tick); | ||
103 | } | ||