From 7d7969114da36a99afc4d80576ff9b089cb09e50 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 11 Jan 2009 10:07:22 +0000 Subject: c200v1/e200v1: Add battery charging. This should be usable on v2 players but those should be evaluated for current, endpoint voltage and whether or not accurate battery readings may always be obtained (which determines algorithm setup and behavior). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19748 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/as3514.h | 33 +++++++++++++++++++++++++++++++-- firmware/export/config-c200.h | 5 +++-- firmware/export/config-e200.h | 5 +++-- firmware/export/powermgmt.h | 7 +++++-- 4 files changed, 42 insertions(+), 8 deletions(-) (limited to 'firmware/export') diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index 07aa0ebfe2..9489d1ae0d 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -249,8 +249,37 @@ extern void audiohw_set_frequency(int fsel); #define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */ #define ADC_VBAT 12 /* Single cell battery voltage */ -#define ADC_UNREG_POWER ADC_BVDD /* For compatibility */ - +/* AS3514_CHARGER */ +#define TMPSUP_OFF (0x1 << 7) +#define CHG_I (0x7 << 4) +#define CHG_I_400MA (0x7 << 4) +#define CHG_I_350MA (0x6 << 4) +#define CHG_I_300MA (0x5 << 4) +#define CHG_I_250MA (0x4 << 4) +#define CHG_I_200MA (0x3 << 4) +#define CHG_I_150MA (0x2 << 4) +#define CHG_I_100MA (0x1 << 4) +#define CHG_I_50MA (0x0 << 4) +#define CHG_V (0x7 << 1) +#define CHG_V_4_25V (0x7 << 1) +#define CHG_V_4_20V (0x6 << 1) +#define CHG_V_4_15V (0x5 << 1) +#define CHG_V_4_10V (0x4 << 1) +#define CHG_V_4_05V (0x3 << 1) +#define CHG_V_4_00V (0x2 << 1) +#define CHG_V_3_95V (0x1 << 1) +#define CHG_V_3_90V (0x0 << 1) +#define CHG_OFF (0x1 << 0) + +/* AS3514_IRQ_ENRD0 */ +#define CHG_TMPHIGH (0x1 << 7) +#define CHG_ENDOFCH (0x1 << 6) +#define CHG_STATUS (0x1 << 5) +#define CHG_CHANGED (0x1 << 4) +#define USB_STATUS (0x1 << 3) +#define USB_CHANGED (0x1 << 2) +#define RVDD_WASLOW (0x1 << 1) +#define BVDD_ISLOW (0x1 << 0) #define AS3514_I2C_ADDR 0x46 diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h index f4ab33fb56..d68d21455f 100644 --- a/firmware/export/config-c200.h +++ b/firmware/export/config-c200.h @@ -123,8 +123,9 @@ #define BATTERY_CAPACITY_INC 0 /* capacity increment */ #define BATTERY_TYPES_COUNT 1 /* only one type */ -/* Hardware controlled charging? FIXME */ -#define CONFIG_CHARGING CHARGING_SIMPLE +/* Charging implemented in a target-specific algorithm */ +#define CONFIG_CHARGING CHARGING_TARGET +#define HAVE_POWEROFF_WHILE_CHARGING /* define this if the unit can be powered or charged via USB */ #define HAVE_USB_POWER diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 602a84707c..2be64d95cc 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h @@ -120,8 +120,9 @@ #define BATTERY_CAPACITY_INC 0 /* capacity increment */ #define BATTERY_TYPES_COUNT 1 /* only one type */ -/* Hardware controlled charging? FIXME */ -#define CONFIG_CHARGING CHARGING_SIMPLE +/* Charging implemented in a target-specific algorithm */ +#define CONFIG_CHARGING CHARGING_TARGET +#define HAVE_POWEROFF_WHILE_CHARGING /* define current usage levels */ #define CURRENT_NORMAL 30 /* Toni's measurements in Nov 2008 */ diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 5be3a39c1d..39e2e6eab9 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -27,7 +27,7 @@ enum charge_state_type { - /* sorted by increasing charging current */ + /* sorted by increasing charging current (do not change!) */ #if CONFIG_CHARGING >= CHARGING_MONITOR CHARGE_STATE_DISABLED = -2, /* Disable charger use (safety measure) */ CHARGE_STATE_ERROR = -1, /* Some error occurred that should not allow @@ -143,13 +143,16 @@ unsigned int battery_voltage(void); /* filtered batt. voltage in millivolts */ #ifdef HAVE_BATTERY_SWITCH unsigned int input_millivolts(void); /* voltage that device is running from */ +#endif /* HAVE_BATTERY_SWITCH */ +#if defined(HAVE_BATTERY_SWITCH) || defined(HAVE_RESET_BATTERY_FILTER) /* Set the filtered battery voltage (to adjust it before beginning a charge * cycle for instance where old, loaded readings will likely be invalid). * Also readjust when battery switch is opened or closed. */ void reset_battery_filter(int millivolts); -#endif /* HAVE_BATTERY_SWITCH */ +#endif /* HAVE_BATTERY_SWITCH || HAVE_RESET_BATTERY_FILTER */ + /* read unfiltered battery info */ void battery_read_info(int *voltage, int *level); -- cgit v1.2.3