1
0
Fork 0
forked from len0rd/rockbox

Charging state reporting on H3x0

Don't read the GPIO every refresh of statusbar or gwps for plugged state, use a
variable exported from powermgmt instead.
Allow Custom WPS to access %bc for battery charge state on targets that support
this.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8383 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Brandon Low 2006-01-19 07:47:34 +00:00
parent 13414ae77a
commit cdacab3d89
7 changed files with 100 additions and 29 deletions

View file

@ -72,6 +72,9 @@
/* Define this if the platform can charge batteries */
#define HAVE_CHARGING 1
/* For units with a hardware charger that reports charge state */
#define HAVE_CHARGE_STATE 1
/* define this if the hardware can be powered off while charging */
#define HAVE_POWEROFF_WHILE_CHARGING

View file

@ -25,6 +25,7 @@ extern bool charger_enabled;
void power_init(void);
bool charger_inserted(void);
bool charging_state(void);
void charger_enable(bool on);
void ide_power_enable(bool on);
bool ide_powered(void);

View file

@ -79,18 +79,38 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute
#endif /* HAVE_CHARGE_CTRL */
#if defined(HAVE_CHARGE_CTRL) || (CONFIG_BATTERY == BATT_LIION2200)
#if defined(HAVE_CHARGE_CTRL) || \
(CONFIG_BATTERY == BATT_LIION2200) || \
defined(HAVE_CHARGE_STATE)
typedef enum {
DISCHARGING,
CHARGING,
#ifdef HAVE_CHARGE_CTRL
TOPOFF,
TRICKLE
#endif
} charge_state_type;
/* tells what the charger is doing */
extern charge_state_type charge_state;
#endif /* defined(HAVE_CHARGE_CTRL) || (CONFIG_BATTERY == BATT_LIION2200) */
#ifdef HAVE_CHARGING
/*
* Flag that the charger has been plugged in/removed: this is set for exactly
* one time through the power loop when the charger has been plugged in.
*/
typedef enum {
NO_CHARGER,
CHARGER_UNPLUGGED, /* transient state */
CHARGER_PLUGGED, /* transient state */
CHARGER
} charger_input_state_type;
/* tells the state of the charge input */
extern charger_input_state_type charger_input_state;
#endif
#ifdef HAVE_MMC /* Values for Ondio */
# define CURRENT_NORMAL 95 /* average, nearly proportional to 1/U */
# define CURRENT_USB 1 /* host powered in USB mode; avoid zero-div */
@ -106,9 +126,13 @@ extern charge_state_type charge_state;
# define CURRENT_MIN_CHG 70 /* minimum charge current */
# define MIN_CHG_V 8500 /* at 8.5v charger voltage get CURRENT_MIN_CHG */
# define CURRENT_MAX_CHG 350 /* maximum charging current */
# ifdef IRIVER_H300_SERIES
# define CURRENT_MAX_CHG 650 /* maximum charging current */
# else
# define CURRENT_MAX_CHG 350 /* maximum charging current */
# endif
# define MAX_CHG_V 10250 /* anything over 10.25v gives CURRENT_MAX_CHG */
#endif /* HAVE_MMC */
#endif /* not HAVE_MMC */
extern unsigned int bat; /* filtered battery voltage, centivolts */
extern unsigned short power_history[POWER_HISTORY_LEN];