diff options
author | Szymon Dziok <b0hoon@o2.pl> | 2012-02-26 23:08:15 +0100 |
---|---|---|
committer | Szymon Dziok <b0hoon@o2.pl> | 2012-03-17 19:20:21 +0100 |
commit | 740722f91338d8571eddbb16983368661a4d87c0 (patch) | |
tree | 5f271e6973ab7d78920bc94d94fc07e13ac364ea /firmware/target/arm/philips | |
parent | e5b5041583e389e6866b210683a09c97a10077d3 (diff) | |
download | rockbox-740722f91338d8571eddbb16983368661a4d87c0.tar.gz rockbox-740722f91338d8571eddbb16983368661a4d87c0.zip |
HDD6330: Simplify strange OF voltage calculation, it's linear anyway.
Change-Id: I33ecad4a265a4c7e8883da7b6d28fb061a4c8e68
Diffstat (limited to 'firmware/target/arm/philips')
-rw-r--r-- | firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c | 18 |
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 @@ | |||
24 | #include "adc.h" | 24 | #include "adc.h" |
25 | #include "powermgmt.h" | 25 | #include "powermgmt.h" |
26 | 26 | ||
27 | #define SMLAL(lo, hi, x, y) \ | ||
28 | asm volatile ("smlal %0, %1, %2, %3" \ | ||
29 | : "+r" (lo), "+r" (hi) \ | ||
30 | : "%r" (x), "r" (y)) | ||
31 | |||
32 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 27 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = |
33 | { | 28 | { |
34 | 3550 | 29 | 3550 |
@@ -53,20 +48,11 @@ const unsigned short percent_to_volt_charge[11] = | |||
53 | }; | 48 | }; |
54 | #endif /* CONFIG_CHARGING */ | 49 | #endif /* CONFIG_CHARGING */ |
55 | 50 | ||
56 | #define BATTERY_SCALE_FACTOR 4200 | 51 | #define BATTERY_SCALE_FACTOR 4536 |
57 | /* full-scale ADC readout (2^10) in millivolt */ | 52 | /* full-scale ADC readout (2^10) in millivolt */ |
58 | 53 | ||
59 | /* Returns battery voltage from ADC [millivolts] */ | 54 | /* Returns battery voltage from ADC [millivolts] */ |
60 | int _battery_voltage(void) | 55 | int _battery_voltage(void) |
61 | { | 56 | { |
62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | 57 | return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; |
63 | |||
64 | /* This may be overly complicated (pulled from the OF) */ | ||
65 | int lo = 0; | ||
66 | int val = adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR; | ||
67 | |||
68 | SMLAL(lo, val, 0x8a42f871, val); | ||
69 | val>>= 9; | ||
70 | val -= (val >> 31); | ||
71 | return val; | ||
72 | } | 58 | } |