summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-10-08 17:45:52 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-10-08 17:45:52 +0000
commit43079ea07f13a7631cd3c0e5993638235427a476 (patch)
tree13ff7f3370f2793797fe9bd51e4e459a5dda695f /firmware
parent5cf1c97aea10864ecb6c3836a5c17845a5906d79 (diff)
multiple battery types prepared (CONFIG_BATTERY)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5227 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/config-fmrecorder.h8
-rw-r--r--firmware/export/config-h100.h5
-rw-r--r--firmware/export/config-ondiofm.h3
-rw-r--r--firmware/export/config-ondiosp.h3
-rw-r--r--firmware/export/config-player.h5
-rw-r--r--firmware/export/config-recorder.h5
-rw-r--r--firmware/export/config-recorderv2.h8
-rw-r--r--firmware/export/config.h5
-rw-r--r--firmware/export/powermgmt.h4
-rw-r--r--firmware/powermgmt.c10
10 files changed, 38 insertions, 18 deletions
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
index af7ca91315..8d3f1a1051 100644
--- a/firmware/export/config-fmrecorder.h
+++ b/firmware/export/config-fmrecorder.h
@@ -25,9 +25,6 @@
/* Define this if you have a FM Recorder key system */
#define HAVE_FMADC 1
-/* Define this if you have a LiIon battery */
-#define HAVE_LIION
-
/* Define this if you need to power on ATA */
#define NEEDS_ATA_POWER_ON
@@ -37,6 +34,9 @@
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIION2200
+
/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
#define BATTERY_SCALE_FACTOR 8081
@@ -61,7 +61,7 @@
/* How to detect USB */
#define USB_FMRECORDERSTYLE 1
-/* Define this if the platform has batteries */
+/* Define this if the platform can charge batteries */
#define HAVE_BATTERIES 1
/* The start address index for ROM builds */
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index 343fc89b42..a3e982a062 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -16,7 +16,10 @@
/* Define this if you have a Motorola SCF5249 */
#define CONFIG_CPU MCF5249
-/* Define this if the platform has batteries */
+/* Type of mobile power, FIXME: probably different, make new type */
+#define CONFIG_BATTERY BATT_LIION2200
+
+/* Define this if the platform can charge batteries */
#define HAVE_BATTERIES 1
/* The start address index for ROM builds */
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index f7d9a8f33f..f7cff94f5e 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -22,6 +22,9 @@
/* Define this to the CPU frequency */
#define CPU_FREQ 12000000
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_3AAA_ALKALINE
+
/* Battery scale factor (measured from Jörg's FM) */
#define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index b4c9f0d572..111787ffc9 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -19,6 +19,9 @@
/* Define this to the CPU frequency */
#define CPU_FREQ 12000000
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_3AAA_ALKALINE
+
/* Battery scale factor (measured from Jörg's FM) */
#define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */
diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h
index 8bd63c42e6..d457ef40fd 100644
--- a/firmware/export/config-player.h
+++ b/firmware/export/config-player.h
@@ -22,6 +22,9 @@
/* Define this to the CPU frequency */
#define CPU_FREQ 12000000 /* cycle time ~83.3ns */
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_4AA_NIMH
+
/* Battery scale factor (?) */
#define BATTERY_SCALE_FACTOR 6546
@@ -44,7 +47,7 @@
/* How to detect USB */
#define USB_PLAYERSTYLE 1
-/* Define this if the platform has batteries */
+/* Define this if the platform can charge batteries */
#define HAVE_BATTERIES 1
/* Define this for programmable LED available */
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
index 89e19f32f6..1e90a05248 100644
--- a/firmware/export/config-recorder.h
+++ b/firmware/export/config-recorder.h
@@ -34,6 +34,9 @@
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_4AA_NIMH
+
/* Battery scale factor (?) */
#define BATTERY_SCALE_FACTOR 6465
@@ -52,7 +55,7 @@
/* How to detect USB */
#define USB_RECORDERSTYLE 1
-/* Define this if the platform has batteries */
+/* Define this if the platform can charge batteries */
#define HAVE_BATTERIES 1
/* The start address index for ROM builds */
diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h
index 56967cfa10..b676a180ed 100644
--- a/firmware/export/config-recorderv2.h
+++ b/firmware/export/config-recorderv2.h
@@ -25,9 +25,6 @@
/* Define this if you have a FM Recorder key system */
#define HAVE_FMADC 1
-/* Define this if you have a LiIon battery */
-#define HAVE_LIION
-
/* Define this if you need to power on ATA */
#define NEEDS_ATA_POWER_ON
@@ -37,6 +34,9 @@
/* Define this to the CPU frequency */
#define CPU_FREQ 11059200
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIION2200
+
/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
#define BATTERY_SCALE_FACTOR 8081
@@ -61,7 +61,7 @@
/* How to detect USB */
#define USB_FMRECORDERSTYLE 1
-/* Define this if the platform has batteries */
+/* Define this if the platform can charge batteries */
#define HAVE_BATTERIES 1
/* The start address index for ROM builds */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index fd757b1ab1..76a2bd9316 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -40,6 +40,11 @@
#define RECORDER_PAD 1
#define ONDIO_PAD 2
+/* CONFIG_BATTERY */
+#define BATT_LIION2200 2200 /* FM/V2 recorder type */
+#define BATT_4AA_NIMH 1500
+#define BATT_3AAA_ALKALINE 1000
+
/* now go and pick yours */
#if defined(ARCHOS_PLAYER)
#include "config-player.h"
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index eb0ba29f28..1a54006a7d 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -19,7 +19,7 @@
#ifndef _POWERMGMT_H_
#define _POWERMGMT_H_
-#ifdef HAVE_LIION /* FM Recorder, LiIon */
+#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */
#define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */
#define BATTERY_LEVEL_EMPTY 265 /* 2.65V */
#define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */
@@ -71,7 +71,7 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute
#endif /* HAVE_CHARGE_CTRL */
-#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_LIION)
+#if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200
extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
#endif
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 155d11e609..e7486635d0 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -92,7 +92,7 @@ static const int poweroff_idle_timeout_value[15] =
static const int percent_to_volt_decharge[11] =
/* voltages (centivolt) of 0%, 10%, ... 100% when charging disabled */
{
-#ifdef HAVE_LIION
+#if CONFIG_BATTERY == BATT_LIION2200
/* measured values */
260, 285, 295, 303, 311, 320, 330, 345, 360, 380, 400
#else /* NiMH */
@@ -112,7 +112,7 @@ void set_battery_capacity(int capacity)
battery_capacity = 1500;
}
-#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_LIION)
+#if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200
int charge_state = 0; /* at the beginning, the
charger does nothing */
#endif
@@ -443,7 +443,7 @@ static void power_thread(void)
int i;
int avg, ok_samples, spin_samples;
int current = 0;
-#ifdef HAVE_LIION
+#if CONFIG_BATTERY == BATT_LIION2200
int charging_current;
#endif
#ifdef HAVE_CHARGE_CTRL
@@ -535,7 +535,7 @@ static void power_thread(void)
#endif /* MEM == 8 */
#endif /* HAVE_CHARGE_CONTROL */
-#ifdef HAVE_LIION
+#if CONFIG_BATTERY == BATT_LIION2200
/* We use the information from the ADC_EXT_POWER ADC channel, which
tells us the charging current from the LTC1734. When DC is
connected (either via the external adapter, or via USB), we try
@@ -790,7 +790,7 @@ static void power_thread(void)
powermgmt_last_cycle_startstop_min++;
#endif /* HAVE_CHARGE_CTRL*/
-#endif /* HAVE_LIION */
+#endif /* # if CONFIG_BATTERY == BATT_LIION2200 */
/* sleep for roughly a minute */
#ifdef HAVE_CHARGE_CTRL