h300: enable usb charging for charge mode and disk mode

This enables USB charging when the bootloader is in charge mode or
disk mode. As a byproduct there is a small change in behavior where
charge mode is all that is available if it is triggered by the USB
cable insertion. Disk mode only becomes available if the user requests
to continue the boot process by pressing the power button. It had to be
done this way as there's no way to tell this early whether the user
wants to simply charge or trigger disk mode as well.

Change-Id: I32f29398b22a76e5e754efdc9beecae39dd122d5
This commit is contained in:
James Buren 2020-11-14 12:10:58 +00:00
parent d5a2aeb6c4
commit 5a223080fa

View file

@ -146,6 +146,7 @@ void main(void)
bool rtc_alarm;
int button;
int mask;
bool usb_charge = false;
/* We want to read the buttons as early as possible, before the user
releases the ON button */
@ -246,6 +247,13 @@ void main(void)
start_iriver_fw();
}
/* enable usb charging for charge mode and disk mode */
if (usb_detect() == USB_INSERTED)
{
usb_charging_enable(USB_CHARGING_ENABLE);
usb_charge = true;
}
if(charger_inserted())
{
const char charging_msg[] = "Charging...";
@ -289,9 +297,6 @@ void main(void)
check_battery();
break;
}
if(usb_detect() == USB_INSERTED)
request_start = true;
}
if(!request_start)
{
@ -340,6 +345,13 @@ void main(void)
lcd_update();
}
/* disable usb charging if we enabled it earlier */
if (usb_charge)
{
usb_charging_enable(USB_CHARGING_DISABLE);
usb_charge = false;
}
rc = storage_init();
if(rc)
{