summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Dziok <b0hoon@o2.pl>2012-02-26 23:08:15 +0100
committerSzymon Dziok <b0hoon@o2.pl>2012-03-17 19:20:21 +0100
commit740722f91338d8571eddbb16983368661a4d87c0 (patch)
tree5f271e6973ab7d78920bc94d94fc07e13ac364ea
parente5b5041583e389e6866b210683a09c97a10077d3 (diff)
downloadrockbox-740722f91338d8571eddbb16983368661a4d87c0.tar.gz
rockbox-740722f91338d8571eddbb16983368661a4d87c0.tar.bz2
rockbox-740722f91338d8571eddbb16983368661a4d87c0.zip
HDD6330: Simplify strange OF voltage calculation, it's linear anyway.
Change-Id: I33ecad4a265a4c7e8883da7b6d28fb061a4c8e68
-rw-r--r--firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
index 7d132523e6..938d8ce14c 100644
--- a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
+++ b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
@@ -24,11 +24,6 @@
#include "adc.h"
#include "powermgmt.h"
-#define SMLAL(lo, hi, x, y) \
- asm volatile ("smlal %0, %1, %2, %3" \
- : "+r" (lo), "+r" (hi) \
- : "%r" (x), "r" (y))
-
const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
{
3550
@@ -53,20 +48,11 @@ const unsigned short percent_to_volt_charge[11] =
};
#endif /* CONFIG_CHARGING */
-#define BATTERY_SCALE_FACTOR 4200
+#define BATTERY_SCALE_FACTOR 4536
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
int _battery_voltage(void)
{
- /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
-
- /* This may be overly complicated (pulled from the OF) */
- int lo = 0;
- int val = adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR;
-
- SMLAL(lo, val, 0x8a42f871, val);
- val>>= 9;
- val -= (val >> 31);
- return val;
+ return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}