summaryrefslogtreecommitdiffstats
path: root/firmware
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 /firmware
parent861525852c858d9d98040cc00786d744ac732e16 (diff)
downloadrockbox-25ebc858428b123aa03e816fe15e02991c91c4f6.tar.gz
rockbox-25ebc858428b123aa03e816fe15e02991c91c4f6.tar.bz2
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
Diffstat (limited to 'firmware')
-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 @@
#include "kernel.h"
/* Do this so we may read all channels in a single SPI message */
-static const unsigned char reg_array[NUM_ADC_CHANNELS/2] =
+static const unsigned char reg_array[4] =
{
MC13783_ADC2,
MC13783_ADC2,
MC13783_ADC2,
MC13783_ADC2,
- MC13783_ADC2,
- MC13783_ADC2,
- MC13783_ADC2,
- MC13783_ADC2,
};
-static uint32_t channels[2][NUM_ADC_CHANNELS/2];
+static uint32_t channels[2][4];
static struct wakeup adc_wake;
static struct mutex adc_mtx;
static long last_adc_read[2]; /* One for each input group */
@@ -49,10 +45,10 @@ unsigned short adc_read(int channel)
if ((unsigned)channel >= NUM_ADC_CHANNELS)
return ADC_READ_ERROR;
- mutex_lock(&adc_mtx);
-
input_select = channel >> 3;
+ mutex_lock(&adc_mtx);
+
/* Limit the traffic through here */
if (TIME_AFTER(current_tick, last_adc_read[input_select]))
{
@@ -72,13 +68,12 @@ unsigned short adc_read(int channel)
/* Read all 8 channels that are converted - two channels in each
* word. */
- mc13783_read_regset(reg_array, channels[input_select],
- NUM_ADC_CHANNELS/2);
+ mc13783_read_regset(reg_array, channels[input_select], 4);
last_adc_read[input_select] = current_tick;
}
- data = channels[input_select][channel & 7];
+ data = channels[input_select][(channel >> 1) & 3];
mutex_unlock(&adc_mtx);