summaryrefslogtreecommitdiff
path: root/bootloader/x1000
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader/x1000')
-rw-r--r--bootloader/x1000/recovery.c2
-rw-r--r--bootloader/x1000/utils.c25
-rw-r--r--bootloader/x1000/x1000bootloader.h1
3 files changed, 26 insertions, 2 deletions
diff --git a/bootloader/x1000/recovery.c b/bootloader/x1000/recovery.c
index 809bd6578a..4d806b26a4 100644
--- a/bootloader/x1000/recovery.c
+++ b/bootloader/x1000/recovery.c
@@ -26,8 +26,6 @@
26#include "kernel.h" 26#include "kernel.h"
27#include <string.h> 27#include <string.h>
28 28
29extern void usb_mode(void);
30
31enum { 29enum {
32 MENUITEM_HEADING, 30 MENUITEM_HEADING,
33 MENUITEM_ACTION, 31 MENUITEM_ACTION,
diff --git a/bootloader/x1000/utils.c b/bootloader/x1000/utils.c
index f4dbac4c5e..56ac6d1fff 100644
--- a/bootloader/x1000/utils.c
+++ b/bootloader/x1000/utils.c
@@ -23,6 +23,13 @@
23#include "storage.h" 23#include "storage.h"
24#include "button.h" 24#include "button.h"
25#include "kernel.h" 25#include "kernel.h"
26#include "usb.h"
27
28/* Set to true if a SYS_USB_CONNECTED event is seen
29 * Set to false if a SYS_USB_DISCONNECTED event is seen
30 * Handled by the gui code since that's how events are delivered
31 * TODO: this is an ugly kludge */
32bool is_usb_connected = false;
26 33
27/* this is both incorrect and incredibly racy... */ 34/* this is both incorrect and incredibly racy... */
28int check_disk(bool wait) 35int check_disk(bool wait)
@@ -43,3 +50,21 @@ int check_disk(bool wait)
43 50
44 return DISK_PRESENT; 51 return DISK_PRESENT;
45} 52}
53
54void usb_mode(void)
55{
56 if(!is_usb_connected)
57 splash2(0, "Waiting for USB", "Press " BL_QUIT_NAME " to cancel");
58
59 while(!is_usb_connected)
60 if(get_button(TIMEOUT_BLOCK) == BL_QUIT)
61 return;
62
63 splash(0, "USB mode");
64 usb_acknowledge(SYS_USB_CONNECTED_ACK);
65
66 while(is_usb_connected)
67 get_button(TIMEOUT_BLOCK);
68
69 splash(3*HZ, "USB disconnected");
70}
diff --git a/bootloader/x1000/x1000bootloader.h b/bootloader/x1000/x1000bootloader.h
index bb35cd3b78..60353e59fd 100644
--- a/bootloader/x1000/x1000bootloader.h
+++ b/bootloader/x1000/x1000bootloader.h
@@ -104,6 +104,7 @@ enum {
104}; 104};
105 105
106int check_disk(bool wait); 106int check_disk(bool wait);
107void usb_mode(void);
107 108
108void recovery_menu(void) __attribute__((noreturn)); 109void recovery_menu(void) __attribute__((noreturn));
109 110