summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
diff options
context:
space:
mode:
authorMark Arigo <markarigo@gmail.com>2009-02-13 04:25:09 +0000
committerMark Arigo <markarigo@gmail.com>2009-02-13 04:25:09 +0000
commit5d5bab7ed4e4f9e3b13defa94dbd8b65a767fdb0 (patch)
treeb12d0914f476a0c237223dc8397b10511f99207e /firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
parent8e5c4ce097526f7668d9ebe89b6cae40b756ed8b (diff)
downloadrockbox-5d5bab7ed4e4f9e3b13defa94dbd8b65a767fdb0.tar.gz
rockbox-5d5bab7ed4e4f9e3b13defa94dbd8b65a767fdb0.tar.bz2
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
Diffstat (limited to 'firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c')
-rw-r--r--firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c28
1 files changed, 17 insertions, 11 deletions
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;
}