diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-04-27 22:35:24 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-04-27 22:35:24 +0000 |
commit | 054c728c9ce72bd546232b2c544316b21ac6f799 (patch) | |
tree | 4c82c109e486ef7e5335f9e9f9c4d7b9304c177f | |
parent | 39ed7087b344eaed04bae81e12e2bb3cd4264787 (diff) | |
download | rockbox-054c728c9ce72bd546232b2c544316b21ac6f799.tar.gz rockbox-054c728c9ce72bd546232b2c544316b21ac6f799.zip |
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
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/adc-imx31.c | 10 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/adc-target.h | 35 |
2 files changed, 23 insertions, 22 deletions
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) | |||
73 | last_adc_read[input_select] = current_tick; | 73 | last_adc_read[input_select] = current_tick; |
74 | } | 74 | } |
75 | 75 | ||
76 | data = channels[input_select][(channel >> 1) & 3]; | 76 | data = channels[input_select][channel & 3]; |
77 | 77 | ||
78 | mutex_unlock(&adc_mtx); | 78 | mutex_unlock(&adc_mtx); |
79 | 79 | ||
80 | /* Extract the bitfield depending on even or odd channel number */ | 80 | /* Channels 0-3/8-11 in ADD1, 0-4/12-15 in ADD2 */ |
81 | return (channel & 1) ? MC13783_ADD2r(data) : MC13783_ADD1r(data); | 81 | return (channel & 4) ? MC13783_ADD2r(data) : MC13783_ADD1r(data); |
82 | } | 82 | } |
83 | 83 | ||
84 | /* Called when conversion is complete */ | 84 | /* Called when conversion is complete */ |
@@ -95,9 +95,9 @@ void adc_init(void) | |||
95 | /* Init so first reads get data */ | 95 | /* Init so first reads get data */ |
96 | last_adc_read[0] = last_adc_read[1] = current_tick-1; | 96 | last_adc_read[0] = last_adc_read[1] = current_tick-1; |
97 | 97 | ||
98 | /* Enable increment-by-read, thermistor */ | 98 | /* Enable increment-by-read, thermistor, charge current */ |
99 | mc13783_write(MC13783_ADC0, MC13783_ADINC2 | MC13783_ADINC1 | | 99 | mc13783_write(MC13783_ADC0, MC13783_ADINC2 | MC13783_ADINC1 | |
100 | MC13783_RTHEN); | 100 | MC13783_RTHEN | MC13783_CHRGICON); |
101 | /* Enable ADC, set multi-channel mode */ | 101 | /* Enable ADC, set multi-channel mode */ |
102 | mc13783_write(MC13783_ADC1, MC13783_ADEN); | 102 | mc13783_write(MC13783_ADC1, MC13783_ADEN); |
103 | /* Enable the ADCDONE interrupt - notifications are dispatched by | 103 | /* 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 @@ | |||
19 | #ifndef _ADC_TARGET_H_ | 19 | #ifndef _ADC_TARGET_H_ |
20 | #define _ADC_TARGET_H_ | 20 | #define _ADC_TARGET_H_ |
21 | 21 | ||
22 | /* only two channels used by the Gigabeat */ | 22 | /* 16 channels in groups of 8 - each conversion converts 8 channels in |
23 | * a group of 8 inputs */ | ||
23 | #define NUM_ADC_CHANNELS 16 | 24 | #define NUM_ADC_CHANNELS 16 |
24 | 25 | ||
25 | #define ADC_BATTERY 0 | 26 | #define ADC_BATTERY 0 /* Battery Voltage (BATT) */ |
26 | #define ADC_UNKNOWN_1 1 | 27 | #define ADC_UNUSED1 1 /* Battery Current (BATT-BATTISNS) */ |
27 | #define ADC_UNKNOWN_2 2 | 28 | #define ADC_APPLICATION_SUPPLY 2 /* Application Supply (BP) */ |
28 | #define ADC_UNKNOWN_3 3 | 29 | #define ADC_CHARGER_VOLTAGE 3 /* Charger Voltage (CHRGRAW) */ |
29 | #define ADC_UNKNOWN_4 4 | 30 | #define ADC_CHARGER_CURRENT 4 /* Charger Current (CHRGISNSP-CHRGISNSN) */ |
30 | #define ADC_UNKNOWN_5 5 | 31 | #define ADC_BATTERY_TEMP 5 /* General Purpose ADIN5 / Battery Pack Thermistor */ |
31 | #define ADC_UNKNOWN_6 6 | 32 | #define ADC_UNUSED6 6 /* General Purpose ADIN6 / Backup Voltage (LICELL) */ |
32 | #define ADC_UNKNOWN_7 7 | 33 | #define ADC_UNUSED7 7 /* General Purpose ADIN7 / UID / Die Temperature */ |
33 | #define ADC_HPREMOTE 8 | 34 | #define ADC_HPREMOTE 8 /* General-purpose ADIN8 (Remote control) */ |
34 | #define ADC_UNKNOWN_9 9 | 35 | #define ADC_UNUSED9 9 /* General-purpose ADIN9 */ |
35 | #define ADC_UNKNOWN_10 10 | 36 | #define ADC_UNUSED10 10 /* General-purpose ADIN10 */ |
36 | #define ADC_UNKNOWN_11 11 | 37 | #define ADC_UNUSED11 11 /* General-purpose ADIN11 */ |
37 | #define ADC_UNKNOWN_12 12 | 38 | #define ADC_UNUSED12 12 /* General-purpose TSX1/Touch screen X-plate 1 */ |
38 | #define ADC_UNKNOWN_13 13 | 39 | #define ADC_UNUSED13 13 /* General-purpose TSX2/Touch screen X-plate 2 */ |
39 | #define ADC_UNKNOWN_14 14 | 40 | #define ADC_UNUSED14 14 /* General-purpose TSY1/Touch screen Y-plate 1 */ |
40 | #define ADC_UNKNOWN_15 15 | 41 | #define ADC_UNUSED15 15 /* General-purpose TSY2/Touch screen Y-plate 2 */ |
41 | 42 | ||
42 | 43 | ||
43 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | 44 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ |