summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/power.c5
-rw-r--r--firmware/export/config-h100.h3
-rw-r--r--firmware/export/config-h120.h3
-rw-r--r--firmware/powermgmt.c11
4 files changed, 19 insertions, 3 deletions
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)
150#endif 150#endif
151 151
152#ifdef HAVE_CHARGE_STATE 152#ifdef HAVE_CHARGE_STATE
153/* Returns true if the unit is charging the batteries. */
153bool charging_state(void) { 154bool charging_state(void) {
155#if defined(IRIVER_H100_SERIES)
156 return charger_inserted();
157#else /* Iriver H300 */
154 return (GPIO_READ & 0x00800000)?true:false; 158 return (GPIO_READ & 0x00800000)?true:false;
159#endif
155} 160}
156#endif 161#endif
157 162
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 @@
78/* Define this if the platform can charge batteries */ 78/* Define this if the platform can charge batteries */
79#define HAVE_CHARGING 1 79#define HAVE_CHARGING 1
80 80
81/* For units with a hardware charger that reports charge state */
82#define HAVE_CHARGE_STATE 1
83
81/* define this if the hardware can be powered off while charging */ 84/* define this if the hardware can be powered off while charging */
82#define HAVE_POWEROFF_WHILE_CHARGING 85#define HAVE_POWEROFF_WHILE_CHARGING
83 86
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 @@
73/* Define this if the platform can charge batteries */ 73/* Define this if the platform can charge batteries */
74#define HAVE_CHARGING 1 74#define HAVE_CHARGING 1
75 75
76/* For units with a hardware charger that reports charge state */
77#define HAVE_CHARGE_STATE 1
78
76/* define this if the hardware can be powered off while charging */ 79/* define this if the hardware can be powered off while charging */
77#define HAVE_POWEROFF_WHILE_CHARGING 80#define HAVE_POWEROFF_WHILE_CHARGING
78 81
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] =
140 { 310, 355, 363, 369, 372, 374, 376, 378, 380, 386, 405 } /* NiMH */ 140 { 310, 355, 363, 369, 372, 374, 376, 378, 380, 386, 405 } /* NiMH */
141#elif CONFIG_BATTERY == BATT_LIPOL1300 141#elif CONFIG_BATTERY == BATT_LIPOL1300
142 /* Below 337 the backlight starts flickering during HD access */ 142 /* Below 337 the backlight starts flickering during HD access */
143 { 337, 358, 365, 369, 372, 377, 383, 389, 397, 406, 413 } 143 /* Calibrated for Ionity 1900 mAh battery. If necessary, re-calibrate
144 * for the 1300 mAh stock battery. */
145// { 337, 358, 365, 369, 372, 377, 383, 389, 397, 406, 413 }
146 { 337, 366, 372, 374, 378, 381, 385, 392, 399, 408, 417 }
144#else /* NiMH */ 147#else /* NiMH */
145 /* original values were taken directly after charging, but it should show 148 /* original values were taken directly after charging, but it should show
146 100% after turning off the device for some hours, too */ 149 100% after turning off the device for some hours, too */
@@ -156,7 +159,9 @@ charger_input_state_type charger_input_state IDATA_ATTR;
156static const short percent_to_volt_charge[11] = 159static const short percent_to_volt_charge[11] =
157{ 160{
158#if CONFIG_BATTERY == BATT_LIPOL1300 161#if CONFIG_BATTERY == BATT_LIPOL1300
159 340, 349, 358, 367, 376, 385, 394, 403, 408, 413, 418 /* Estimated */ 162 /* Calibrated for 1900 mAh Ionity battery (estimated 90% charge when
163 entering in trickle-charging). We will never reach 100%. */
164 340, 390, 394, 399, 400, 404, 407, 413, 417, 422, 426
160#else 165#else
161 /* values guessed, see 166 /* values guessed, see
162 http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone 167 http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
@@ -533,8 +538,8 @@ static void power_thread_sleep(int ticks)
533#ifdef HAVE_CHARGE_STATE 538#ifdef HAVE_CHARGE_STATE
534 switch (charger_input_state) { 539 switch (charger_input_state) {
535 case CHARGER_UNPLUGGED: 540 case CHARGER_UNPLUGGED:
536 charge_state = DISCHARGING;
537 case NO_CHARGER: 541 case NO_CHARGER:
542 charge_state = DISCHARGING;
538 break; 543 break;
539 case CHARGER_PLUGGED: 544 case CHARGER_PLUGGED:
540 case CHARGER: 545 case CHARGER: