From 5bdb2fccdb9846e75e499593c6183346eca3e660 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 5 Mar 2022 09:39:46 +0000 Subject: x1000: bootloader: refactor usb handling Drop init_usb(), instead initialize USB early in the main function so the hardware is placed into a known good state after a USB boot. The impact on boot time should be minimal. Change-Id: I9774ddfc2c27811363bdb0c54cb0e57b5ca59d73 --- bootloader/x1000.c | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'bootloader/x1000.c') diff --git a/bootloader/x1000.c b/bootloader/x1000.c index 1c9f3cd2fa..bc56b8f822 100644 --- a/bootloader/x1000.c +++ b/bootloader/x1000.c @@ -56,43 +56,6 @@ #include #include -/* Flags to indicate if hardware was already initialized */ -bool usb_inited = false; - -/* Set to true if a SYS_USB_CONNECTED event is seen - * Set to false if a SYS_USB_DISCONNECTED event is seen */ -bool is_usb_connected = false; - -void init_usb(void) -{ - if(usb_inited) - return; - - usb_init(); - usb_start_monitoring(); - usb_inited = true; -} - -void usb_mode(void) -{ - init_usb(); - - if(!is_usb_connected) - splash2(0, "Waiting for USB", "Press " BL_QUIT_NAME " to go back"); - - while(!is_usb_connected) - if(get_button(TIMEOUT_BLOCK) == BL_QUIT) - return; - - splash(0, "USB mode"); - usb_acknowledge(SYS_USB_CONNECTED_ACK); - - while(is_usb_connected) - get_button(TIMEOUT_BLOCK); - - splash(3*HZ, "USB disconnected"); -} - void main(void) { system_init(); @@ -110,6 +73,9 @@ void main(void) filesystem_init(); + usb_init(); + usb_start_monitoring(); + /* It's OK if this doesn't mount anything. Any disk access should * be guarded by a call to check_disk() to see if the disk is really * present, blocking with an "insert SD card" prompt if appropriate. */ -- cgit v1.2.3