summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorBrandon Low <lostlogic@rockbox.org>2006-03-02 13:37:51 +0000
committerBrandon Low <lostlogic@rockbox.org>2006-03-02 13:37:51 +0000
commit6d19a569be771c0ebe1f0adcdf28927bfff5681d (patch)
treeb024e3501b62df5b27c5189a575a536b9c708324 /firmware
parent8d0a32eb4b4fd7108b9ebae81f93b3909c3e477f (diff)
downloadrockbox-6d19a569be771c0ebe1f0adcdf28927bfff5681d.tar.gz
rockbox-6d19a569be771c0ebe1f0adcdf28927bfff5681d.zip
Improved battery status reporting for units which support usb power / charge
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8886 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/power.c3
-rw-r--r--firmware/powermgmt.c14
2 files changed, 10 insertions, 7 deletions
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index b62121298d..c6d49f5aa9 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -120,8 +120,7 @@ bool charger_inserted(void)
120 return adc_read(ADC_EXT_POWER) > 0x100; 120 return adc_read(ADC_EXT_POWER) > 0x100;
121#elif defined (HAVE_FMADC) 121#elif defined (HAVE_FMADC)
122 /* FM or V2, can also charge from the USB port */ 122 /* FM or V2, can also charge from the USB port */
123 return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF) || 123 return (adc_read(ADC_CHARGE_REGULATOR) < 0x1FF);
124 (adc_read(ADC_USB_POWER) < 0x1FF);
125#elif defined(TOSHIBA_GIGABEAT_F) 124#elif defined(TOSHIBA_GIGABEAT_F)
126 return false; 125 return false;
127#else 126#else
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index b61aed7366..ff635486c1 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -353,7 +353,7 @@ static void battery_status_update(void)
353 /* calculate estimated remaining running time */ 353 /* calculate estimated remaining running time */
354 /* discharging: remaining running time */ 354 /* discharging: remaining running time */
355 /* charging: remaining charging time */ 355 /* charging: remaining charging time */
356#ifdef HAVE_CHARGE_CTRL 356#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE)
357 if (charge_state == CHARGING) { 357 if (charge_state == CHARGING) {
358 powermgmt_est_runningtime_min = (100 - level) * battery_capacity / 100 358 powermgmt_est_runningtime_min = (100 - level) * battery_capacity / 100
359 * 60 / (CURRENT_MAX_CHG - runcurrent()); 359 * 60 / (CURRENT_MAX_CHG - runcurrent());
@@ -497,7 +497,11 @@ static void power_thread_sleep(int ticks)
497 * loop (including the subroutines), and end up back here where we 497 * loop (including the subroutines), and end up back here where we
498 * transition to the appropriate steady state charger on/off state. 498 * transition to the appropriate steady state charger on/off state.
499 */ 499 */
500 if(charger_inserted()) { 500 if(charger_inserted()
501#ifdef HAVE_USB_POWER
502 || usb_powered()
503#endif
504 ) {
501 switch(charger_input_state) { 505 switch(charger_input_state) {
502 case NO_CHARGER: 506 case NO_CHARGER:
503 case CHARGER_UNPLUGGED: 507 case CHARGER_UNPLUGGED:
@@ -572,6 +576,9 @@ static void power_thread_sleep(int ticks)
572 */ 576 */
573 battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000; 577 battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000;
574 578
579 /* update battery status every time an update is available */
580 battery_status_update();
581
575 } 582 }
576 583
577#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL) 584#if defined(DEBUG_FILE) && defined(HAVE_CHARGE_CTRL)
@@ -628,9 +635,6 @@ static void power_thread(void)
628 /* insert new value at the start, in centivolts 8-) */ 635 /* insert new value at the start, in centivolts 8-) */
629 power_history[0] = battery_centivolts; 636 power_history[0] = battery_centivolts;
630 637
631 /* update battery status every minute */
632 battery_status_update();
633
634#if CONFIG_BATTERY == BATT_LIION2200 638#if CONFIG_BATTERY == BATT_LIION2200
635 /* We use the information from the ADC_EXT_POWER ADC channel, which 639 /* We use the information from the ADC_EXT_POWER ADC channel, which
636 tells us the charging current from the LTC1734. When DC is 640 tells us the charging current from the LTC1734. When DC is