diff options
author | Boris Gjenero <dreamlayers@rockbox.org> | 2011-12-31 18:31:47 +0000 |
---|---|---|
committer | Boris Gjenero <dreamlayers@rockbox.org> | 2011-12-31 18:31:47 +0000 |
commit | 5cd8aec39a05a78c6ae7b9c81d2c0f8acf0aac48 (patch) | |
tree | 86f77e720f5ed3d97aec0c8e31e64da0676d1a5c | |
parent | a5e44591c24260d0411bfe8e6de9a9c683dd1534 (diff) | |
download | rockbox-5cd8aec39a05a78c6ae7b9c81d2c0f8acf0aac48.tar.gz rockbox-5cd8aec39a05a78c6ae7b9c81d2c0f8acf0aac48.zip |
Fix FS#7631 : Archos V2 and FM Recorder charging screen problems
ATA power is off in the charging screen to avoid problems when the battery
is deeply discharged. Without ATA power, Archos FM and V2 Recorders measure
battery voltage as 0V, leading to an unwanted low battery shutdown. This
change delays powermgmt_init() on those targets until after ATA power is
turned on by storage_init(). The charging screen displays input current,
so there is some visible feedback on charging progress.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31484 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/main.c | 11 | ||||
-rw-r--r-- | apps/screens.c | 16 |
2 files changed, 23 insertions, 4 deletions
diff --git a/apps/main.c b/apps/main.c index 5715057ee2..9846f116be 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -506,7 +506,12 @@ static void init(void) | |||
506 | 506 | ||
507 | button_init(); | 507 | button_init(); |
508 | 508 | ||
509 | /* Don't initialize power management here if it could incorrectly | ||
510 | * measure battery voltage, and it's not needed for charging. */ | ||
511 | #if !defined(NEED_ATA_POWER_BATT_MEASURE) || \ | ||
512 | (CONFIG_CHARGING > CHARGING_MONITOR) | ||
509 | powermgmt_init(); | 513 | powermgmt_init(); |
514 | #endif | ||
510 | 515 | ||
511 | #if CONFIG_TUNER | 516 | #if CONFIG_TUNER |
512 | radio_init(); | 517 | radio_init(); |
@@ -567,6 +572,12 @@ static void init(void) | |||
567 | panicf("ata: %d", rc); | 572 | panicf("ata: %d", rc); |
568 | } | 573 | } |
569 | 574 | ||
575 | #if defined(NEED_ATA_POWER_BATT_MEASURE) && \ | ||
576 | (CONFIG_CHARGING <= CHARGING_MONITOR) | ||
577 | /* After storage_init(), ATA power must be on, so battery voltage | ||
578 | * can be measured. Initialize power management if it was delayed. */ | ||
579 | powermgmt_init(); | ||
580 | #endif | ||
570 | #ifdef HAVE_EEPROM_SETTINGS | 581 | #ifdef HAVE_EEPROM_SETTINGS |
571 | CHART(">eeprom_settings_init"); | 582 | CHART(">eeprom_settings_init"); |
572 | eeprom_settings_init(); | 583 | eeprom_settings_init(); |
diff --git a/apps/screens.c b/apps/screens.c index b261a2d3dc..8d4585f7b3 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -59,6 +59,10 @@ | |||
59 | #include "dsp.h" | 59 | #include "dsp.h" |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #if defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2) | ||
63 | #include "adc.h" | ||
64 | #endif | ||
65 | |||
62 | #if (CONFIG_STORAGE & STORAGE_MMC) && (defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM)) | 66 | #if (CONFIG_STORAGE & STORAGE_MMC) && (defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM)) |
63 | int mmc_remove_request(void) | 67 | int mmc_remove_request(void) |
64 | { | 68 | { |
@@ -94,14 +98,17 @@ static void charging_display_info(bool animate) | |||
94 | static unsigned phase = 3; | 98 | static unsigned phase = 3; |
95 | unsigned i; | 99 | unsigned i; |
96 | 100 | ||
97 | #ifdef NEED_ATA_POWER_BATT_MEASURE | 101 | #if !defined(NEED_ATA_POWER_BATT_MEASURE) |
98 | if (ide_powered()) /* FM and V2 can only measure when ATA power is on */ | ||
99 | #endif | ||
100 | { | 102 | { |
101 | int battv = battery_voltage(); | 103 | int battv = battery_voltage(); |
102 | lcd_putsf(0, 7, " Batt: %d.%02dV %d%% ", battv / 1000, | 104 | lcd_putsf(0, 7, " Batt: %d.%02dV %d%% ", battv / 1000, |
103 | (battv % 1000) / 10, battery_level()); | 105 | (battv % 1000) / 10, battery_level()); |
104 | } | 106 | } |
107 | #elif defined(ARCHOS_FMRECORDER) || defined(ARCHOS_RECORDERV2) | ||
108 | /* IDE power is normally off here, so display input current instead */ | ||
109 | lcd_putsf(7, 7, "%dmA ", | ||
110 | (adc_read(ADC_EXT_POWER) * EXT_SCALE_FACTOR) / 10000); | ||
111 | #endif | ||
105 | 112 | ||
106 | #ifdef ARCHOS_RECORDER | 113 | #ifdef ARCHOS_RECORDER |
107 | lcd_puts(0, 2, "Charge mode:"); | 114 | lcd_puts(0, 2, "Charge mode:"); |
@@ -263,7 +270,8 @@ int charging_screen(void) | |||
263 | rc = 2; | 270 | rc = 2; |
264 | else if (usb_detect() == USB_INSERTED) | 271 | else if (usb_detect() == USB_INSERTED) |
265 | rc = 3; | 272 | rc = 3; |
266 | else if (!charger_inserted()) | 273 | /* do not depend on power management thread here */ |
274 | else if (!(power_input_status() & POWER_INPUT_MAIN_CHARGER)) | ||
267 | rc = 1; | 275 | rc = 1; |
268 | } while (!rc); | 276 | } while (!rc); |
269 | 277 | ||