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) |
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 @@ /* define this if you have a light associated with the buttons */ /* #define HAVE_BUTTON_LIGHT */ -#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */ -#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */ -#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */ -#define BATTERY_CAPACITY_INC 50 /* capacity increment */ -#define BATTERY_TYPES_COUNT 1 /* only one type */ +#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */ +#define BATTERY_CAPACITY_MIN 630 /* min. capacity selectable */ +#define BATTERY_CAPACITY_MAX 630 /* max. capacity selectable */ +#define BATTERY_CAPACITY_INC 0 /* capacity increment */ +#define BATTERY_TYPES_COUNT 1 /* only one type */ /* Hardware controlled charging */ #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 @@ #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] = { - 3450 + 3550 }; const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = { - 3400 + 3500 }; /* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ @@ -48,19 +53,20 @@ const unsigned short percent_to_volt_charge[11] = }; #endif /* CONFIG_CHARGING */ -#define BATTERY_SCALE_FACTOR 6003 +#define BATTERY_SCALE_FACTOR 4200 /* full-scale ADC readout (2^10) in millivolt */ -/* adc readout - * max with charger connected: 690 - * max fully charged: 682 - * min just before shutdown: 570 - */ - /* Returns battery voltage from ADC [millivolts] */ unsigned int battery_adc_voltage(void) { - /* For now, assume as battery full (we need to calibrate) */ /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ - return 3990; + + /* 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; } |