summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-04-14 04:22:47 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-04-14 04:22:47 +0000
commit25ebc858428b123aa03e816fe15e02991c91c4f6 (patch)
tree24b8b885922a2ad8b436b62d3a637a7f67db5ee1
parent861525852c858d9d98040cc00786d744ac732e16 (diff)
downloadrockbox-25ebc858428b123aa03e816fe15e02991c91c4f6.tar.gz
rockbox-25ebc858428b123aa03e816fe15e02991c91c4f6.zip
Oops...simple math proves elusive at times. Get the array calcs right.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17104 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/adc-imx31.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c b/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c
index b1b79a7989..dfaaab9177 100644
--- a/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c
@@ -23,19 +23,15 @@
23#include "kernel.h" 23#include "kernel.h"
24 24
25/* Do this so we may read all channels in a single SPI message */ 25/* Do this so we may read all channels in a single SPI message */
26static const unsigned char reg_array[NUM_ADC_CHANNELS/2] = 26static const unsigned char reg_array[4] =
27{ 27{
28 MC13783_ADC2, 28 MC13783_ADC2,
29 MC13783_ADC2, 29 MC13783_ADC2,
30 MC13783_ADC2, 30 MC13783_ADC2,
31 MC13783_ADC2, 31 MC13783_ADC2,
32 MC13783_ADC2,
33 MC13783_ADC2,
34 MC13783_ADC2,
35 MC13783_ADC2,
36}; 32};
37 33
38static uint32_t channels[2][NUM_ADC_CHANNELS/2]; 34static uint32_t channels[2][4];
39static struct wakeup adc_wake; 35static struct wakeup adc_wake;
40static struct mutex adc_mtx; 36static struct mutex adc_mtx;
41static long last_adc_read[2]; /* One for each input group */ 37static long last_adc_read[2]; /* One for each input group */
@@ -49,10 +45,10 @@ unsigned short adc_read(int channel)
49 if ((unsigned)channel >= NUM_ADC_CHANNELS) 45 if ((unsigned)channel >= NUM_ADC_CHANNELS)
50 return ADC_READ_ERROR; 46 return ADC_READ_ERROR;
51 47
52 mutex_lock(&adc_mtx);
53
54 input_select = channel >> 3; 48 input_select = channel >> 3;
55 49
50 mutex_lock(&adc_mtx);
51
56 /* Limit the traffic through here */ 52 /* Limit the traffic through here */
57 if (TIME_AFTER(current_tick, last_adc_read[input_select])) 53 if (TIME_AFTER(current_tick, last_adc_read[input_select]))
58 { 54 {
@@ -72,13 +68,12 @@ unsigned short adc_read(int channel)
72 68
73 /* Read all 8 channels that are converted - two channels in each 69 /* Read all 8 channels that are converted - two channels in each
74 * word. */ 70 * word. */
75 mc13783_read_regset(reg_array, channels[input_select], 71 mc13783_read_regset(reg_array, channels[input_select], 4);
76 NUM_ADC_CHANNELS/2);
77 72
78 last_adc_read[input_select] = current_tick; 73 last_adc_read[input_select] = current_tick;
79 } 74 }
80 75
81 data = channels[input_select][channel & 7]; 76 data = channels[input_select][(channel >> 1) & 3];
82 77
83 mutex_unlock(&adc_mtx); 78 mutex_unlock(&adc_mtx);
84 79