summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tatung
diff options
context:
space:
mode:
authorMark Arigo <markarigo@gmail.com>2009-01-27 03:19:57 +0000
committerMark Arigo <markarigo@gmail.com>2009-01-27 03:19:57 +0000
commit04992ef050a2bef8387f84efc6988211c34e19b7 (patch)
treeb9f5682b66fde3548ae059c4a6b0785024997274 /firmware/target/arm/tatung
parenta4e7bc383ed296b532a648a02db62a06c99c9ad8 (diff)
downloadrockbox-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
Diffstat (limited to 'firmware/target/arm/tatung')
-rw-r--r--firmware/target/arm/tatung/tpj1022/adc-target.h9
-rw-r--r--firmware/target/arm/tatung/tpj1022/adc-tpj1022.c103
2 files changed, 0 insertions, 112 deletions
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
28static unsigned short adcdata[NUM_ADC_CHANNELS];
29
30/* Scan ADC so that adcdata[channel] gets updated */
31unsigned 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 */
60unsigned short adc_read(int channel)
61{
62 return adcdata[channel];
63}
64
65static int adc_counter;
66
67static 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
79void 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}