mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-01-22 01:30:35 -05:00
echoplayer: add charger detection and USB current limit setting
Note that USB current limiting is more or less wishful thinking; only the charge current is limited, but the system could easily draw more than 100 mA by itself. Change-Id: I1083b015f0abea5a39a602ca8d7b142d3613b46b
This commit is contained in:
parent
cd20bc7d16
commit
bc32d43c17
2 changed files with 21 additions and 5 deletions
|
|
@ -108,9 +108,7 @@
|
|||
#define USB_PRODUCT_ID 0xEC01
|
||||
#define USB_DEVBSS_ATTR __attribute__((aligned(32)))
|
||||
#define HAVE_USB_POWER
|
||||
//#define HAVE_USB_CHARGING_ENABLE
|
||||
//#define HAVE_USB_CHARGING_IN_THREAD
|
||||
//#define TARGET_USB_CHARGING_DEFAULT USB_CHARGING_FORCE
|
||||
#define HAVE_USB_CHARGING_ENABLE
|
||||
#define HAVE_BOOTLOADER_USB_MODE
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
static struct mutex power_1v8_lock;
|
||||
static int power_1v8_refcount;
|
||||
|
||||
/* TODO: calibrate battery curve */
|
||||
unsigned short battery_level_disksafe = 3500;
|
||||
unsigned short battery_level_shutoff = 3400;
|
||||
|
||||
|
|
@ -87,14 +88,31 @@ void system_reboot(void)
|
|||
power_off();
|
||||
}
|
||||
|
||||
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||
void usb_charging_maxcurrent_change(int maxcurrent)
|
||||
{
|
||||
const int conf_500ma = GPIOF_OUTPUT(0, GPIO_TYPE_PUSH_PULL,
|
||||
GPIO_SPEED_LOW, GPIO_PULL_DISABLED);
|
||||
const int conf_100ma = GPIOF_INPUT(GPIO_PULL_DISABLED);
|
||||
|
||||
if (maxcurrent > 100)
|
||||
gpio_configure_single(GPIO_CHARGER_CHARGING, conf_500ma);
|
||||
else
|
||||
gpio_configure_single(GPIO_CHARGER_CHARGING, conf_100ma);
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int power_input_status(void)
|
||||
{
|
||||
return POWER_INPUT_USB_CHARGER;
|
||||
if (gpio_get_level(GPIO_USB_VBUS))
|
||||
return POWER_INPUT_USB_CHARGER;
|
||||
|
||||
return POWER_INPUT_NONE;
|
||||
}
|
||||
|
||||
bool charging_state(void)
|
||||
{
|
||||
return true;
|
||||
return gpio_get_level(GPIO_CHARGER_CHARGING) == 0;
|
||||
}
|
||||
|
||||
int _battery_voltage(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue