From 04992ef050a2bef8387f84efc6988211c34e19b7 Mon Sep 17 00:00:00 2001 From: Mark Arigo Date: Tue, 27 Jan 2009 03:19:57 +0000 Subject: 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 --- firmware/target/arm/adc-pp5020.c | 6 ++ firmware/target/arm/iriver/h10/adc-target.h | 6 -- firmware/target/arm/olympus/mrobe-100/adc-target.h | 6 -- firmware/target/arm/philips/hdd1630/adc-target.h | 6 -- firmware/target/arm/tatung/tpj1022/adc-target.h | 9 -- firmware/target/arm/tatung/tpj1022/adc-tpj1022.c | 103 --------------------- 6 files changed, 6 insertions(+), 130 deletions(-) delete mode 100644 firmware/target/arm/tatung/tpj1022/adc-tpj1022.c (limited to 'firmware/target/arm') 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 @@ #include "thread.h" #include "adc.h" +#define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) +#define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) +#define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) +#define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) +#define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) + static unsigned short adcdata[NUM_ADC_CHANNELS]; /* 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 @@ #ifndef _ADC_TARGET_H_ #define _ADC_TARGET_H_ -#define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) -#define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) -#define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) -#define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) -#define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) - #define NUM_ADC_CHANNELS 4 #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 @@ #ifndef _ADC_TARGET_H_ #define _ADC_TARGET_H_ -#define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) -#define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) -#define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) -#define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) -#define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) - #define NUM_ADC_CHANNELS 4 #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 @@ #ifndef _ADC_TARGET_H_ #define _ADC_TARGET_H_ -#define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) -#define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) -#define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) -#define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) -#define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) - #define NUM_ADC_CHANNELS 4 #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 @@ #ifndef _ADC_TARGET_H_ #define _ADC_TARGET_H_ -#define ADC_ENABLE_ADDR (*(volatile unsigned long*)(0x70000010)) -#define ADC_ENABLE 0x1100 - -#define ADC_ADDR (*(volatile unsigned long*)(0x7000ad00)) -#define ADC_STATUS (*(volatile unsigned long*)(0x7000ad04)) -#define ADC_DATA_1 (*(volatile unsigned long*)(0x7000ad20)) -#define ADC_DATA_2 (*(volatile unsigned long*)(0x7000ad24)) -#define ADC_INIT (*(volatile unsigned long*)(0x7000ad2c)) - #define NUM_ADC_CHANNELS 4 #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 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2006 by Barry Wardell - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ -#include "config.h" -#include "cpu.h" -#include "system.h" -#include "kernel.h" -#include "thread.h" -#include "adc.h" - -static unsigned short adcdata[NUM_ADC_CHANNELS]; - -/* Scan ADC so that adcdata[channel] gets updated */ -unsigned short adc_scan(int channel) -{ - unsigned int adc_data_1; - unsigned int adc_data_2; - - /* Initialise */ - ADC_ADDR=0x130; - ADC_STATUS=0; /* 4 bytes, 1 per channel. Each byte is 0 if the channel is - off, 0x40 if the channel is on */ - - /* Enable Channel */ - ADC_ADDR |= (0x1000000<> (8*channel)) & 0xff); - adc_data_2 = ((ADC_DATA_2 >> (8*channel+6)) & 0x3); - - adcdata[channel] = (adc_data_1<<2 | adc_data_2); - - return adcdata[channel]; -} - -/* Read 10-bit channel data */ -unsigned short adc_read(int channel) -{ - return adcdata[channel]; -} - -static int adc_counter; - -static void adc_tick(void) -{ - if(++adc_counter == HZ) - { - adc_counter = 0; - adc_scan(ADC_BATTERY); - adc_scan(ADC_UNKNOWN_1); - adc_scan(ADC_UNKNOWN_2); - adc_scan(ADC_SCROLLPAD); - } -} - -void adc_init(void) -{ - /* Enable ADC */ - ADC_ENABLE_ADDR |= ADC_ENABLE; - - /* Initialise */ - ADC_INIT=0; - ADC_ADDR=0x130; - ADC_STATUS=0; - - /* Enable Channels 1-4 */ - ADC_ADDR |= 0x1000000; - ADC_ADDR |= 0x2000000; - ADC_ADDR |= 0x4000000; - ADC_ADDR |= 0x8000000; - - /* Start? */ - ADC_ADDR |= 0x20000000; - ADC_ADDR |= 0x80000000; - - /* Wait 50ms for things to settle */ - sleep(HZ/20); - - tick_add_task(adc_tick); -} -- cgit v1.2.3