diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/config-gigabeat-s.h | 12 | ||||
-rw-r--r-- | firmware/export/config.h | 2 | ||||
-rw-r--r-- | firmware/export/powermgmt.h | 48 | ||||
-rw-r--r-- | firmware/export/usb.h | 3 |
4 files changed, 49 insertions, 16 deletions
diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h index 54a3de2d19..b4c30268ba 100644 --- a/firmware/export/config-gigabeat-s.h +++ b/firmware/export/config-gigabeat-s.h | |||
@@ -2,7 +2,6 @@ | |||
2 | * This config file is for toshiba Gigabeat S | 2 | * This config file is for toshiba Gigabeat S |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #define NO_LOW_BATTERY_SHUTDOWN | ||
6 | #define TARGET_TREE /* this target is using the target tree system */ | 5 | #define TARGET_TREE /* this target is using the target tree system */ |
7 | 6 | ||
8 | #define TOSHIBA_GIGABEAT_S 1 | 7 | #define TOSHIBA_GIGABEAT_S 1 |
@@ -132,8 +131,10 @@ | |||
132 | #define BATTERY_CAPACITY_INC 25 /* capacity increment */ | 131 | #define BATTERY_CAPACITY_INC 25 /* capacity increment */ |
133 | #define BATTERY_TYPES_COUNT 1 /* only one type */ | 132 | #define BATTERY_TYPES_COUNT 1 /* only one type */ |
134 | 133 | ||
135 | /* Hardware controlled charging with monitoring */ | 134 | /* TODO: have a proper status displayed in the bootloader and have it |
136 | #define CONFIG_CHARGING CHARGING_MONITOR | 135 | * work! */ |
136 | /* Charing implemented in a target-specific algorithm */ | ||
137 | #define CONFIG_CHARGING CHARGING_TARGET | ||
137 | 138 | ||
138 | /* define this if the hardware can be powered off while charging */ | 139 | /* define this if the hardware can be powered off while charging */ |
139 | #define HAVE_POWEROFF_WHILE_CHARGING | 140 | #define HAVE_POWEROFF_WHILE_CHARGING |
@@ -146,8 +147,9 @@ | |||
146 | #define CPU_FREQ 264000000 /* Set by retailOS loader */ | 147 | #define CPU_FREQ 264000000 /* Set by retailOS loader */ |
147 | 148 | ||
148 | /* define this if the unit can be powered or charged via USB */ | 149 | /* define this if the unit can be powered or charged via USB */ |
149 | //#define HAVE_USB_POWER /* Disable for now */ | 150 | #define HAVE_USB_POWER |
150 | //#define HAVE_USB_CHARGING_ENABLE | 151 | #define USBPOWER_BUTTON BUTTON_MENU |
152 | #define USBPOWER_BTN_IGNORE BUTTON_POWER | ||
151 | 153 | ||
152 | /* define this if the unit has a battery switch or battery can be removed | 154 | /* define this if the unit has a battery switch or battery can be removed |
153 | * when running */ | 155 | * when running */ |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 75aa76a898..d484805532 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -117,6 +117,8 @@ | |||
117 | #define CHARGING_SIMPLE 1 /* Simple, hardware controlled charging */ | 117 | #define CHARGING_SIMPLE 1 /* Simple, hardware controlled charging */ |
118 | #define CHARGING_MONITOR 2 /* Hardware controlled charging with monitoring */ | 118 | #define CHARGING_MONITOR 2 /* Hardware controlled charging with monitoring */ |
119 | #define CHARGING_CONTROL 3 /* Software controlled charging */ | 119 | #define CHARGING_CONTROL 3 /* Software controlled charging */ |
120 | #define CHARGING_TARGET 4 /* Anything the target implements that is not | ||
121 | a generic implementation */ | ||
120 | 122 | ||
121 | /* CONFIG_LCD */ | 123 | /* CONFIG_LCD */ |
122 | #define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */ | 124 | #define LCD_SSD1815 1 /* as used by Archos Recorders and Ondios */ |
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index 70c4b70d7a..c333795ad7 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h | |||
@@ -30,17 +30,26 @@ | |||
30 | #define CHARGE_END_LONGD 50 /* stop when N minutes have passed with | 30 | #define CHARGE_END_LONGD 50 /* stop when N minutes have passed with |
31 | * avg delta being < -0.02 V */ | 31 | * avg delta being < -0.02 V */ |
32 | 32 | ||
33 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
34 | typedef enum { /* sorted by increasing charging current */ | 33 | typedef enum { /* sorted by increasing charging current */ |
34 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
35 | CHARGE_STATE_DISABLED = -2, /* Disable charger use */ | ||
36 | CHARGE_STATE_ERROR = -1, /* Some error occurred that should not allow | ||
37 | further attempts without user intervention */ | ||
38 | #endif | ||
35 | DISCHARGING = 0, | 39 | DISCHARGING = 0, |
40 | #if CONFIG_CHARGING >= CHARGING_MONITOR | ||
36 | TRICKLE, /* Can occur for CONFIG_CHARGING >= CHARGING_MONITOR */ | 41 | TRICKLE, /* Can occur for CONFIG_CHARGING >= CHARGING_MONITOR */ |
42 | /* For LiIon, the low-current precharge mode if battery | ||
43 | was very low */ | ||
37 | TOPOFF, /* Can occur for CONFIG_CHARGING == CHARGING_CONTROL */ | 44 | TOPOFF, /* Can occur for CONFIG_CHARGING == CHARGING_CONTROL */ |
38 | CHARGING /* Can occur for all CONFIG_CHARGING options */ | 45 | /* For LiIon, constant voltage phase */ |
46 | CHARGING, /* Can occur for all CONFIG_CHARGING options */ | ||
47 | /* For LiIon, the constant current phase */ | ||
48 | #endif | ||
39 | } charge_state_type; | 49 | } charge_state_type; |
40 | 50 | ||
41 | /* tells what the charger is doing */ | 51 | /* tells what the charger is doing */ |
42 | extern charge_state_type charge_state; | 52 | extern charge_state_type charge_state; |
43 | #endif /* CONFIG_CHARGING >= CHARGING_MONITOR */ | ||
44 | 53 | ||
45 | #ifdef CONFIG_CHARGING | 54 | #ifdef CONFIG_CHARGING |
46 | /* | 55 | /* |
@@ -48,10 +57,10 @@ extern charge_state_type charge_state; | |||
48 | * one time through the power loop when the charger has been plugged in. | 57 | * one time through the power loop when the charger has been plugged in. |
49 | */ | 58 | */ |
50 | typedef enum { | 59 | typedef enum { |
51 | NO_CHARGER, | 60 | NO_CHARGER = 0, /* No charger is present */ |
52 | CHARGER_UNPLUGGED, /* transient state */ | 61 | CHARGER_UNPLUGGED, /* Transitional state during CHARGER=>NO_CHARGER */ |
53 | CHARGER_PLUGGED, /* transient state */ | 62 | CHARGER_PLUGGED, /* Transitional state during NO_CHARGER=>CHARGER */ |
54 | CHARGER | 63 | CHARGER /* Charger is present */ |
55 | } charger_input_state_type; | 64 | } charger_input_state_type; |
56 | 65 | ||
57 | /* tells the state of the charge input */ | 66 | /* tells the state of the charge input */ |
@@ -154,6 +163,11 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute | |||
154 | # define MAX_CHG_V 10250 /* anything over 10.25v gives CURRENT_MAX_CHG */ | 163 | # define MAX_CHG_V 10250 /* anything over 10.25v gives CURRENT_MAX_CHG */ |
155 | #endif /* not ONDIO */ | 164 | #endif /* not ONDIO */ |
156 | 165 | ||
166 | #if CONFIG_CHARGING == CHARGING_TARGET | ||
167 | /* Include target-specific definitions */ | ||
168 | #include "powermgmt-target.h" | ||
169 | #endif | ||
170 | |||
157 | extern unsigned short power_history[POWER_HISTORY_LEN]; | 171 | extern unsigned short power_history[POWER_HISTORY_LEN]; |
158 | extern const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT]; | 172 | extern const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT]; |
159 | extern const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT]; | 173 | extern const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT]; |
@@ -165,6 +179,12 @@ extern const unsigned short percent_to_volt_charge[11]; | |||
165 | /* Start up power management thread */ | 179 | /* Start up power management thread */ |
166 | void powermgmt_init(void); | 180 | void powermgmt_init(void); |
167 | 181 | ||
182 | /* Do target portion of init (for CHARGING_TARGET) - called on power thread */ | ||
183 | void powermgmt_init_target(void); | ||
184 | |||
185 | /* Handle frequent tasks and call charging_algorithm_small_step */ | ||
186 | void power_thread_sleep(int ticks); | ||
187 | |||
168 | #endif /* SIMULATOR */ | 188 | #endif /* SIMULATOR */ |
169 | 189 | ||
170 | /* Returns battery statust */ | 190 | /* Returns battery statust */ |
@@ -173,12 +193,20 @@ int battery_time(void); /* minutes */ | |||
173 | unsigned int battery_adc_voltage(void); /* voltage from ADC in millivolts */ | 193 | unsigned int battery_adc_voltage(void); /* voltage from ADC in millivolts */ |
174 | unsigned int battery_voltage(void); /* filtered batt. voltage in millivolts */ | 194 | unsigned int battery_voltage(void); /* filtered batt. voltage in millivolts */ |
175 | 195 | ||
196 | /* Set the filtered battery voltage (to adjust it before beginning a charge | ||
197 | cycle for instance where old, loaded readings will likely be invalid). */ | ||
198 | void set_filtered_battery_voltage(int millivolts); | ||
199 | |||
176 | /* read unfiltered battery info */ | 200 | /* read unfiltered battery info */ |
177 | void battery_read_info(int *voltage, int *level); | 201 | void battery_read_info(int *voltage, int *level); |
178 | 202 | ||
179 | /* Tells if the battery level is safe for disk writes */ | 203 | /* Tells if the battery level is safe for disk writes */ |
180 | bool battery_level_safe(void); | 204 | bool battery_level_safe(void); |
181 | 205 | ||
206 | #ifdef TARGET_POWERMGMT_FILTER_CHARGE_STATE | ||
207 | int powermgmt_filter_charge_state(void); | ||
208 | #endif | ||
209 | |||
182 | void set_poweroff_timeout(int timeout); | 210 | void set_poweroff_timeout(int timeout); |
183 | void set_battery_capacity(int capacity); /* set local battery capacity value */ | 211 | void set_battery_capacity(int capacity); /* set local battery capacity value */ |
184 | void set_battery_type(int type); /* set local battery type */ | 212 | void set_battery_type(int type); /* set local battery type */ |
@@ -190,7 +218,11 @@ void reset_poweroff_timer(void); | |||
190 | void cancel_shutdown(void); | 218 | void cancel_shutdown(void); |
191 | void shutdown_hw(void); | 219 | void shutdown_hw(void); |
192 | void sys_poweroff(void); | 220 | void sys_poweroff(void); |
221 | /* Returns true if the system should force shutdown for some reason - | ||
222 | * eg. low battery */ | ||
223 | bool query_force_shutdown(void); | ||
193 | #ifdef HAVE_ACCESSORY_SUPPLY | 224 | #ifdef HAVE_ACCESSORY_SUPPLY |
194 | void accessory_supply_set(bool); | 225 | void accessory_supply_set(bool); |
195 | #endif | 226 | #endif |
196 | #endif | 227 | |
228 | #endif /* _POWERMGMT_H_ */ | ||
diff --git a/firmware/export/usb.h b/firmware/export/usb.h index 00517b2475..c8bbf28267 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h | |||
@@ -54,9 +54,6 @@ enum { | |||
54 | #elif CONFIG_KEYPAD == GIGABEAT_PAD | 54 | #elif CONFIG_KEYPAD == GIGABEAT_PAD |
55 | #define USBPOWER_BUTTON BUTTON_MENU | 55 | #define USBPOWER_BUTTON BUTTON_MENU |
56 | #define USBPOWER_BTN_IGNORE BUTTON_POWER | 56 | #define USBPOWER_BTN_IGNORE BUTTON_POWER |
57 | #elif CONFIG_KEYPAD == GIGABEAT_S_PAD | ||
58 | #define USBPOWER_BUTTON BUTTON_MENU | ||
59 | #define USBPOWER_BTN_IGNORE BUTTON_BACK | ||
60 | #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \ | 57 | #elif (CONFIG_KEYPAD == IRIVER_H10_PAD) || \ |
61 | (CONFIG_KEYPAD == MROBE100_PAD) | 58 | (CONFIG_KEYPAD == MROBE100_PAD) |
62 | #define USBPOWER_BUTTON BUTTON_RIGHT | 59 | #define USBPOWER_BUTTON BUTTON_RIGHT |