From 451ee0b11c4eb1e60370c5fef94bc85945d8e092 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Mon, 13 Mar 2006 16:11:30 +0000 Subject: Charging state reporting for iriver players. Values calibrated with 1900 mAh Ionity battery; might need recalibration with the stock battery. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9030 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/power.c | 5 +++++ firmware/export/config-h100.h | 3 +++ firmware/export/config-h120.h | 3 +++ firmware/powermgmt.c | 11 ++++++++--- 4 files changed, 19 insertions(+), 3 deletions(-) (limited to 'firmware') diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index 9f3a10cc84..3df8460222 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c @@ -150,8 +150,13 @@ void charger_enable(bool on) #endif #ifdef HAVE_CHARGE_STATE +/* Returns true if the unit is charging the batteries. */ bool charging_state(void) { +#if defined(IRIVER_H100_SERIES) + return charger_inserted(); +#else /* Iriver H300 */ return (GPIO_READ & 0x00800000)?true:false; +#endif } #endif diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 87598c208e..d35a35bb60 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h @@ -78,6 +78,9 @@ /* Define this if the platform can charge batteries */ #define HAVE_CHARGING 1 +/* For units with a hardware charger that reports charge state */ +#define HAVE_CHARGE_STATE 1 + /* define this if the hardware can be powered off while charging */ #define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h index fd62243d8a..8426940da8 100644 --- a/firmware/export/config-h120.h +++ b/firmware/export/config-h120.h @@ -73,6 +73,9 @@ /* Define this if the platform can charge batteries */ #define HAVE_CHARGING 1 +/* For units with a hardware charger that reports charge state */ +#define HAVE_CHARGE_STATE 1 + /* define this if the hardware can be powered off while charging */ #define HAVE_POWEROFF_WHILE_CHARGING diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index e4330a48c0..8f4f22fb3f 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -140,7 +140,10 @@ static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = { 310, 355, 363, 369, 372, 374, 376, 378, 380, 386, 405 } /* NiMH */ #elif CONFIG_BATTERY == BATT_LIPOL1300 /* Below 337 the backlight starts flickering during HD access */ - { 337, 358, 365, 369, 372, 377, 383, 389, 397, 406, 413 } + /* Calibrated for Ionity 1900 mAh battery. If necessary, re-calibrate + * for the 1300 mAh stock battery. */ +// { 337, 358, 365, 369, 372, 377, 383, 389, 397, 406, 413 } + { 337, 366, 372, 374, 378, 381, 385, 392, 399, 408, 417 } #else /* NiMH */ /* original values were taken directly after charging, but it should show 100% after turning off the device for some hours, too */ @@ -156,7 +159,9 @@ charger_input_state_type charger_input_state IDATA_ATTR; static const short percent_to_volt_charge[11] = { #if CONFIG_BATTERY == BATT_LIPOL1300 - 340, 349, 358, 367, 376, 385, 394, 403, 408, 413, 418 /* Estimated */ + /* Calibrated for 1900 mAh Ionity battery (estimated 90% charge when + entering in trickle-charging). We will never reach 100%. */ + 340, 390, 394, 399, 400, 404, 407, 413, 417, 422, 426 #else /* values guessed, see http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone @@ -533,8 +538,8 @@ static void power_thread_sleep(int ticks) #ifdef HAVE_CHARGE_STATE switch (charger_input_state) { case CHARGER_UNPLUGGED: - charge_state = DISCHARGING; case NO_CHARGER: + charge_state = DISCHARGING; break; case CHARGER_PLUGGED: case CHARGER: -- cgit v1.2.3