summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2006-09-23 17:47:54 +0000
committerBarry Wardell <rockbox@barrywardell.net>2006-09-23 17:47:54 +0000
commit5a79b4e015366fa2ee7c06cf29b3237275db369a (patch)
treec69b042757caec05b46146c96db2c934a0e68438
parent193611367ab739c284be26060f707776804757b9 (diff)
downloadrockbox-5a79b4e015366fa2ee7c06cf29b3237275db369a.zip
rockbox-5a79b4e015366fa2ee7c06cf29b3237275db369a.tar.gz
rockbox-5a79b4e015366fa2ee7c06cf29b3237275db369a.tar.bz2
rockbox-5a79b4e015366fa2ee7c06cf29b3237275db369a.tar.xz
Add ADC to I/O ports debug menu on H10. Fix battery level reading empty when starting up on H10. Calibrated battery for H10 20GB.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11036 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c12
-rw-r--r--apps/main.c2
-rw-r--r--firmware/export/config-h10.h6
-rw-r--r--firmware/export/config-h10_5gb.h2
-rw-r--r--firmware/powermgmt.c16
-rwxr-xr-xfirmware/target/arm/iriver/h10/adc-h10.c21
6 files changed, 37 insertions, 22 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 00e7f55..af1b812 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1123,7 +1123,17 @@ bool dbg_ports(void)
lcd_puts(0, line++, buf);
snprintf(buf, sizeof(buf), "GPIO_F: %02x GPIO_L: %02x", gpio_f, gpio_l);
lcd_puts(0, line++, buf);
-
+#if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
+ line++;
+ snprintf(buf, sizeof(buf), "ADC_BATTERY: %02x", adc_read(ADC_BATTERY));
+ lcd_puts(0, line++, buf);
+ snprintf(buf, sizeof(buf), "ADC_UNKNOWN_1: %02x", adc_read(ADC_UNKNOWN_1));
+ lcd_puts(0, line++, buf);
+ snprintf(buf, sizeof(buf), "ADC_UNKNOWN_2: %02x", adc_read(ADC_UNKNOWN_2));
+ lcd_puts(0, line++, buf);
+ snprintf(buf, sizeof(buf), "ADC_SCROLLPAD: %02x", adc_read(ADC_SCROLLPAD));
+ lcd_puts(0, line++, buf);
+#endif
lcd_update();
if (action_userabort(HZ/10))
return false;
diff --git a/apps/main.c b/apps/main.c
index 90bd13e..2ceb24d 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -417,7 +417,7 @@ void init(void)
settings_calc_config_sector();
-#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD)
+#if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IRIVER_H10_PAD)
#ifdef SETTINGS_RESET
/* Reset settings if holding the rec button. */
if ((button_status() & SETTINGS_RESET) == SETTINGS_RESET)
diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h
index df42068..df778e2 100644
--- a/firmware/export/config-h10.h
+++ b/firmware/export/config-h10.h
@@ -65,9 +65,7 @@
#define CONFIG_BACKLIGHT BL_H10 /* TODO: figure this out, probably not necessary
because of 'target' stuff */
-#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity
- TODO: check this, probably different
- for different models too */
+#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */
#ifndef SIMULATOR
@@ -83,7 +81,7 @@
#define BATTERY_CAPACITY_MAX 1600 /* max. capacity selectable */
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
-#define BATTERY_SCALE_FACTOR 5865
+#define BATTERY_SCALE_FACTOR 4688
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE
diff --git a/firmware/export/config-h10_5gb.h b/firmware/export/config-h10_5gb.h
index 35d5467..aefc21c 100644
--- a/firmware/export/config-h10_5gb.h
+++ b/firmware/export/config-h10_5gb.h
@@ -79,7 +79,7 @@
#define BATTERY_CAPACITY_MAX 900 /* max. capacity selectable */
#define BATTERY_CAPACITY_INC 10 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
-#define BATTERY_SCALE_FACTOR 5865
+#define BATTERY_SCALE_FACTOR 4688
/* Hardware controlled charging */
#define CONFIG_CHARGING CHARGING_SIMPLE
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index f1e1aac..be63aae 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -169,6 +169,10 @@ static const unsigned int battery_level_dangerous[BATTERY_TYPES_COUNT] =
105, 115 /* alkaline, NiHM */
#elif CONFIG_BATTERY == BATT_LIPOL1300 /* iRiver H1x0 */
339
+#elif CONFIG_BATTERY == BATT_LPCS355385 /* iriver H10 20GB */
+ 378
+#elif CONFIG_BATTERY == BATT_BP009 /* iriver H10 5/6GB */
+ 378
#else /* Player/recorder, NiMH */
475
#endif
@@ -190,6 +194,12 @@ static const short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
* 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 }
+#elif CONFIG_BATTERY == BATT_LPCS355385
+ /* iriver H10 20GB */
+ { 378, 382, 386, 390, 395, 399, 404, 408, 413, 417, 422 }
+#elif CONFIG_BATTERY == BATT_BP009
+ /* iriver H10 5/6GB: Same as 20GB for now */
+ { 378, 382, 386, 390, 395, 399, 404, 408, 413, 417, 422 }
#elif CONFIG_BATTERY == BATT_1AA
/* These values are the same as for 3AAA divided by 3. */
/* May need recalibration. */
@@ -213,6 +223,12 @@ static const short percent_to_volt_charge[11] =
/* 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
+#elif CONFIG_BATTERY == BATT_LPCS355385
+ /* iriver H10 20GB: Same as iPod for now */
+ 388, 392, 396, 400, 406, 410, 415, 419, 424, 428, 433
+#elif CONFIG_BATTERY == BATT_BP009
+ /* iriver H10 5/6GB: Same as iPod for now */
+ 388, 392, 396, 400, 406, 410, 415, 419, 424, 428, 433
#else
/* values guessed, see
http://www.seattlerobotics.org/encoder/200210/LiIon2.pdf until someone
diff --git a/firmware/target/arm/iriver/h10/adc-h10.c b/firmware/target/arm/iriver/h10/adc-h10.c
index 134b90b..0dc0e8a 100755
--- a/firmware/target/arm/iriver/h10/adc-h10.c
+++ b/firmware/target/arm/iriver/h10/adc-h10.c
@@ -81,21 +81,12 @@ void adc_init(void)
/* Initialise */
ADC_INIT=0;
- ADC_ADDR=0x130;
- ADC_STATUS=0;
-
- /* Enable Channels 1-4 */
- ADC_ADDR |= 0x1000000;
- ADC_ADDR |= 0x2000000;
- ADC_ADDR |= 0x4000000;
- ADC_ADDR |= 0x8000000;
-
- /* Start? */
- ADC_ADDR |= 0x20000000;
- ADC_ADDR |= 0x80000000;
-
- /* Wait 50ms for things to settle */
- sleep(HZ/20);
+
+ /* Force a scan of all channels to get initial values */
+ adc_scan(ADC_BATTERY);
+ adc_scan(ADC_UNKNOWN_1);
+ adc_scan(ADC_UNKNOWN_2);
+ adc_scan(ADC_SCROLLPAD);
tick_add_task(adc_tick);
}