From 054c728c9ce72bd546232b2c544316b21ac6f799 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 27 Apr 2008 22:35:24 +0000 Subject: Gigabeat S: Define the used ADC channels, get the channel order correct, enable charge current channel conversion. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17272 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/imx31/gigabeat-s/adc-imx31.c | 10 +++---- firmware/target/arm/imx31/gigabeat-s/adc-target.h | 35 ++++++++++++----------- 2 files changed, 23 insertions(+), 22 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c b/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c index 764e2e4bde..27c6957184 100644 --- a/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c @@ -73,12 +73,12 @@ unsigned short adc_read(int channel) last_adc_read[input_select] = current_tick; } - data = channels[input_select][(channel >> 1) & 3]; + data = channels[input_select][channel & 3]; mutex_unlock(&adc_mtx); - /* Extract the bitfield depending on even or odd channel number */ - return (channel & 1) ? MC13783_ADD2r(data) : MC13783_ADD1r(data); + /* Channels 0-3/8-11 in ADD1, 0-4/12-15 in ADD2 */ + return (channel & 4) ? MC13783_ADD2r(data) : MC13783_ADD1r(data); } /* Called when conversion is complete */ @@ -95,9 +95,9 @@ void adc_init(void) /* Init so first reads get data */ last_adc_read[0] = last_adc_read[1] = current_tick-1; - /* Enable increment-by-read, thermistor */ + /* Enable increment-by-read, thermistor, charge current */ mc13783_write(MC13783_ADC0, MC13783_ADINC2 | MC13783_ADINC1 | - MC13783_RTHEN); + MC13783_RTHEN | MC13783_CHRGICON); /* Enable ADC, set multi-channel mode */ mc13783_write(MC13783_ADC1, MC13783_ADEN); /* Enable the ADCDONE interrupt - notifications are dispatched by diff --git a/firmware/target/arm/imx31/gigabeat-s/adc-target.h b/firmware/target/arm/imx31/gigabeat-s/adc-target.h index 6b066b0b59..0b74ad84eb 100644 --- a/firmware/target/arm/imx31/gigabeat-s/adc-target.h +++ b/firmware/target/arm/imx31/gigabeat-s/adc-target.h @@ -19,25 +19,26 @@ #ifndef _ADC_TARGET_H_ #define _ADC_TARGET_H_ -/* only two channels used by the Gigabeat */ +/* 16 channels in groups of 8 - each conversion converts 8 channels in + * a group of 8 inputs */ #define NUM_ADC_CHANNELS 16 -#define ADC_BATTERY 0 -#define ADC_UNKNOWN_1 1 -#define ADC_UNKNOWN_2 2 -#define ADC_UNKNOWN_3 3 -#define ADC_UNKNOWN_4 4 -#define ADC_UNKNOWN_5 5 -#define ADC_UNKNOWN_6 6 -#define ADC_UNKNOWN_7 7 -#define ADC_HPREMOTE 8 -#define ADC_UNKNOWN_9 9 -#define ADC_UNKNOWN_10 10 -#define ADC_UNKNOWN_11 11 -#define ADC_UNKNOWN_12 12 -#define ADC_UNKNOWN_13 13 -#define ADC_UNKNOWN_14 14 -#define ADC_UNKNOWN_15 15 +#define ADC_BATTERY 0 /* Battery Voltage (BATT) */ +#define ADC_UNUSED1 1 /* Battery Current (BATT-BATTISNS) */ +#define ADC_APPLICATION_SUPPLY 2 /* Application Supply (BP) */ +#define ADC_CHARGER_VOLTAGE 3 /* Charger Voltage (CHRGRAW) */ +#define ADC_CHARGER_CURRENT 4 /* Charger Current (CHRGISNSP-CHRGISNSN) */ +#define ADC_BATTERY_TEMP 5 /* General Purpose ADIN5 / Battery Pack Thermistor */ +#define ADC_UNUSED6 6 /* General Purpose ADIN6 / Backup Voltage (LICELL) */ +#define ADC_UNUSED7 7 /* General Purpose ADIN7 / UID / Die Temperature */ +#define ADC_HPREMOTE 8 /* General-purpose ADIN8 (Remote control) */ +#define ADC_UNUSED9 9 /* General-purpose ADIN9 */ +#define ADC_UNUSED10 10 /* General-purpose ADIN10 */ +#define ADC_UNUSED11 11 /* General-purpose ADIN11 */ +#define ADC_UNUSED12 12 /* General-purpose TSX1/Touch screen X-plate 1 */ +#define ADC_UNUSED13 13 /* General-purpose TSX2/Touch screen X-plate 2 */ +#define ADC_UNUSED14 14 /* General-purpose TSY1/Touch screen Y-plate 1 */ +#define ADC_UNUSED15 15 /* General-purpose TSY2/Touch screen Y-plate 2 */ #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ -- cgit v1.2.3