summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-04-14 06:52:38 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-04-14 06:52:38 +0000
commit0257547d58ce05db0331d7b541f07ce020a7649e (patch)
tree8de7d722df1d44d380782ea8f24feef23846885a /firmware
parent25ebc858428b123aa03e816fe15e02991c91c4f6 (diff)
downloadrockbox-0257547d58ce05db0331d7b541f07ce020a7649e.tar.gz
rockbox-0257547d58ce05db0331d7b541f07ce020a7649e.tar.bz2
rockbox-0257547d58ce05db0331d7b541f07ce020a7649e.zip
Gigabeat S: Make ADC battery voltage reading correct. Tiny tweak to ADC driver traffic limiting.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17105 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/adc-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/powermgmt-imx31.c7
2 files changed, 3 insertions, 6 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c b/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c
index dfaaab9177..764e2e4bde 100644
--- a/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/adc-imx31.c
@@ -50,7 +50,7 @@ unsigned short adc_read(int channel)
mutex_lock(&adc_mtx);
/* Limit the traffic through here */
- if (TIME_AFTER(current_tick, last_adc_read[input_select]))
+ if (current_tick != last_adc_read[input_select])
{
/* Keep enable, start conversion, increment from channel 0,
* increment from channel 4 */
diff --git a/firmware/target/arm/imx31/gigabeat-s/powermgmt-imx31.c b/firmware/target/arm/imx31/gigabeat-s/powermgmt-imx31.c
index 7441100a7d..53996f8cd7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/powermgmt-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/powermgmt-imx31.c
@@ -48,13 +48,10 @@ const unsigned short percent_to_volt_charge[11] =
3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990
};
-/* ADC[0] is (530) at discharge and 625 at full charge */
-#define BATTERY_SCALE_FACTOR 6605
-/* full-scale ADC readout (2^10) in millivolt */
-
/* Returns battery voltage from ADC [millivolts] */
unsigned int battery_adc_voltage(void)
{
- return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
+ /* ADC reading 0-1023 = 2400mV-4700mV */
+ return ((adc_read(ADC_BATTERY) * 2303) >> 10) + 2400;
}