diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-02-13 04:25:09 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-02-13 04:25:09 +0000 |
commit | 5d5bab7ed4e4f9e3b13defa94dbd8b65a767fdb0 (patch) | |
tree | b12d0914f476a0c237223dc8397b10511f99207e | |
parent | 8e5c4ce097526f7668d9ebe89b6cae40b756ed8b (diff) | |
download | rockbox-5d5bab7ed4e4f9e3b13defa94dbd8b65a767fdb0.tar.gz rockbox-5d5bab7ed4e4f9e3b13defa94dbd8b65a767fdb0.zip |
Philips HDD1630 - working battery voltage readings. Still needs to be calibrated.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19998 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-x | firmware/export/config-hdd1630.h | 10 | ||||
-rw-r--r-- | firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c | 28 |
2 files changed, 22 insertions, 16 deletions
diff --git a/firmware/export/config-hdd1630.h b/firmware/export/config-hdd1630.h index 605a0453ed..7ccad010fe 100755 --- a/firmware/export/config-hdd1630.h +++ b/firmware/export/config-hdd1630.h | |||
@@ -118,11 +118,11 @@ | |||
118 | /* define this if you have a light associated with the buttons */ | 118 | /* define this if you have a light associated with the buttons */ |
119 | /* #define HAVE_BUTTON_LIGHT */ | 119 | /* #define HAVE_BUTTON_LIGHT */ |
120 | 120 | ||
121 | #define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ | 121 | #define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */ |
122 | #define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */ | 122 | #define BATTERY_CAPACITY_MIN 630 /* min. capacity selectable */ |
123 | #define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */ | 123 | #define BATTERY_CAPACITY_MAX 630 /* max. capacity selectable */ |
124 | #define BATTERY_CAPACITY_INC 50 /* capacity increment */ | 124 | #define BATTERY_CAPACITY_INC 0 /* capacity increment */ |
125 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 125 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
126 | 126 | ||
127 | /* Hardware controlled charging */ | 127 | /* Hardware controlled charging */ |
128 | #define CONFIG_CHARGING CHARGING_SIMPLE | 128 | #define CONFIG_CHARGING CHARGING_SIMPLE |
diff --git a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c index 0bb9458fe7..33bbb6af48 100644 --- a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c | |||
@@ -24,14 +24,19 @@ | |||
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 | |||
27 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = | 32 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = |
28 | { | 33 | { |
29 | 3450 | 34 | 3550 |
30 | }; | 35 | }; |
31 | 36 | ||
32 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = | 37 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = |
33 | { | 38 | { |
34 | 3400 | 39 | 3500 |
35 | }; | 40 | }; |
36 | 41 | ||
37 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ | 42 | /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ |
@@ -48,19 +53,20 @@ const unsigned short percent_to_volt_charge[11] = | |||
48 | }; | 53 | }; |
49 | #endif /* CONFIG_CHARGING */ | 54 | #endif /* CONFIG_CHARGING */ |
50 | 55 | ||
51 | #define BATTERY_SCALE_FACTOR 6003 | 56 | #define BATTERY_SCALE_FACTOR 4200 |
52 | /* full-scale ADC readout (2^10) in millivolt */ | 57 | /* full-scale ADC readout (2^10) in millivolt */ |
53 | 58 | ||
54 | /* adc readout | ||
55 | * max with charger connected: 690 | ||
56 | * max fully charged: 682 | ||
57 | * min just before shutdown: 570 | ||
58 | */ | ||
59 | |||
60 | /* Returns battery voltage from ADC [millivolts] */ | 59 | /* Returns battery voltage from ADC [millivolts] */ |
61 | unsigned int battery_adc_voltage(void) | 60 | unsigned int battery_adc_voltage(void) |
62 | { | 61 | { |
63 | /* For now, assume as battery full (we need to calibrate) */ | ||
64 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ | 62 | /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ |
65 | return 3990; | 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; | ||
66 | } | 72 | } |