diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-06-06 22:23:52 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-06-06 22:23:52 +0000 |
commit | 0dd1f8ec11f28fe34c93ba97af95eb2be2fef44f (patch) | |
tree | e3e77d4e6b25b82c82b3570cd8c4a988c7788e66 /firmware/drivers/power.c | |
parent | 8c9e22580e220b793130ed3ac67b9c54e85b3d0f (diff) | |
download | rockbox-0dd1f8ec11f28fe34c93ba97af95eb2be2fef44f.tar.gz rockbox-0dd1f8ec11f28fe34c93ba97af95eb2be2fef44f.zip |
Work-in-progress rework of charging status reading & display: * Changed several charging related HAVE_* macros into one multi-value CONFIG_CHARGING. * Always use proper macros for charging states. * Battery symbol charging animation now starts from current level on all targets with charging. Two-colour animation kept for non-b&w targets. Round down fill level while charging as before, but round to nearest pixel value for discharging on all targets. * Charging anim fixed on player. * Some code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10080 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/power.c')
-rw-r--r-- | firmware/drivers/power.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index c4b9fb5b7d..bda03b0f8b 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "pcf50606.h" | 29 | #include "pcf50606.h" |
30 | #include "usb.h" | 30 | #include "usb.h" |
31 | 31 | ||
32 | #ifdef HAVE_CHARGE_CTRL | 32 | #if CONFIG_CHARGING == CHARGING_CONTROL |
33 | bool charger_enabled; | 33 | bool charger_enabled; |
34 | #endif | 34 | #endif |
35 | 35 | ||
@@ -92,7 +92,7 @@ void power_init(void) | |||
92 | or_b(0x20, &PBIORL); | 92 | or_b(0x20, &PBIORL); |
93 | or_b(0x20, &PBDRL); /* hold power */ | 93 | or_b(0x20, &PBDRL); /* hold power */ |
94 | #endif | 94 | #endif |
95 | #ifdef HAVE_CHARGE_CTRL | 95 | #if CONFIG_CHARGING == CHARGING_CONTROL |
96 | PBCR2 &= ~0x0c00; /* GPIO for PB5 */ | 96 | PBCR2 &= ~0x0c00; /* GPIO for PB5 */ |
97 | or_b(0x20, &PBIORL); /* Set charging control bit to output */ | 97 | or_b(0x20, &PBIORL); /* Set charging control bit to output */ |
98 | charger_enable(false); /* Default to charger OFF */ | 98 | charger_enable(false); /* Default to charger OFF */ |
@@ -106,7 +106,7 @@ void power_init(void) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | #ifdef HAVE_CHARGING | 109 | #ifdef CONFIG_CHARGING |
110 | bool charger_inserted(void) | 110 | bool charger_inserted(void) |
111 | { | 111 | { |
112 | #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) | 112 | #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES) |
@@ -115,7 +115,7 @@ bool charger_inserted(void) | |||
115 | return (P7 & 0x80) == 0; | 115 | return (P7 & 0x80) == 0; |
116 | #elif defined(IAUDIO_X5) | 116 | #elif defined(IAUDIO_X5) |
117 | return (GPIO1_READ & 0x01000000)?true:false; | 117 | return (GPIO1_READ & 0x01000000)?true:false; |
118 | #elif defined(HAVE_CHARGE_CTRL) | 118 | #elif CONFIG_CHARGING == CHARGING_CONTROL |
119 | /* Recorder */ | 119 | /* Recorder */ |
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) |
@@ -133,9 +133,9 @@ bool charger_inserted(void) | |||
133 | return (PADR & 1) == 0; | 133 | return (PADR & 1) == 0; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | #endif /* HAVE_CHARGING */ | 136 | #endif /* CONFIG_CHARGING */ |
137 | 137 | ||
138 | #ifdef HAVE_CHARGE_CTRL | 138 | #if CONFIG_CHARGING == CHARGING_CONTROL |
139 | void charger_enable(bool on) | 139 | void charger_enable(bool on) |
140 | { | 140 | { |
141 | if(on) | 141 | if(on) |
@@ -151,14 +151,22 @@ void charger_enable(bool on) | |||
151 | } | 151 | } |
152 | #endif | 152 | #endif |
153 | 153 | ||
154 | #ifdef HAVE_CHARGE_STATE | 154 | #if CONFIG_CHARGING == CHARGING_MONITOR |
155 | /* Returns true if the unit is charging the batteries. */ | 155 | /* Returns true if the unit is charging the batteries. */ |
156 | bool charging_state(void) { | 156 | bool charging_state(void) { |
157 | #if defined(IRIVER_H100_SERIES) | 157 | #if CONFIG_BATTERY == BATT_LIION2200 |
158 | /* We use the information from the ADC_EXT_POWER ADC channel, which | ||
159 | tells us the charging current from the LTC1734. When DC is | ||
160 | connected (either via the external adapter, or via USB), we try | ||
161 | to determine if it is actively charging or only maintaining the | ||
162 | charge. My tests show that ADC readings below about 0x80 means | ||
163 | that the LTC1734 is only maintaining the charge. */ | ||
164 | return adc_read(ADC_EXT_POWER) >= 0x80; | ||
165 | #elif defined(IRIVER_H100_SERIES) /* FIXME */ | ||
158 | return charger_inserted(); | 166 | return charger_inserted(); |
159 | #elif defined(IRIVER_H300_SERIES) | 167 | #elif defined IRIVER_H300_SERIES |
160 | return (GPIO_READ & 0x00800000)?true:false; | 168 | return (GPIO_READ & 0x00800000)?true:false; |
161 | #elif defined(IPOD_VIDEO) | 169 | #elif defined IPOD_VIDEO |
162 | return (GPIOB_INPUT_VAL & 0x01)?false:true; | 170 | return (GPIOB_INPUT_VAL & 0x01)?false:true; |
163 | #endif | 171 | #endif |
164 | } | 172 | } |