diff options
-rw-r--r-- | bootloader/xduoox3.c | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/bootloader/xduoox3.c b/bootloader/xduoox3.c index b53d92b647..ff6b81aa25 100644 --- a/bootloader/xduoox3.c +++ b/bootloader/xduoox3.c | |||
@@ -26,7 +26,9 @@ | |||
26 | #include "font.h" | 26 | #include "font.h" |
27 | #include "lcd.h" | 27 | #include "lcd.h" |
28 | #include "file.h" | 28 | #include "file.h" |
29 | #ifdef HAVE_BOOTLOADER_USB_MODE | ||
29 | #include "usb.h" | 30 | #include "usb.h" |
31 | #endif | ||
30 | #include "system.h" | 32 | #include "system.h" |
31 | #include "button.h" | 33 | #include "button.h" |
32 | #include "common.h" | 34 | #include "common.h" |
@@ -80,7 +82,7 @@ static int usb_inited = 0; | |||
80 | 82 | ||
81 | static void usb_mode(void) | 83 | static void usb_mode(void) |
82 | { | 84 | { |
83 | int button; | 85 | int button = 0; |
84 | 86 | ||
85 | /* Init USB, but only once */ | 87 | /* Init USB, but only once */ |
86 | if (!usb_inited) { | 88 | if (!usb_inited) { |
@@ -92,32 +94,28 @@ static void usb_mode(void) | |||
92 | init_lcd(); | 94 | init_lcd(); |
93 | reset_screen(); | 95 | reset_screen(); |
94 | 96 | ||
95 | /* Wait for threads to connect */ | 97 | /* Wait for USB */ |
96 | show_splash(HZ/2, "Waiting for USB"); | 98 | show_splash(0, "Waiting for USB"); |
97 | 99 | while(1) { | |
98 | while (1) { | ||
99 | button = button_get_w_tmo(HZ/2); | 100 | button = button_get_w_tmo(HZ/2); |
100 | |||
101 | if (button == SYS_USB_CONNECTED) | ||
102 | break; /* Hit */ | ||
103 | |||
104 | if (button == BUTTON_POWER) | 101 | if (button == BUTTON_POWER) |
105 | return; | 102 | return; |
103 | if (button == SYS_USB_CONNECTED) | ||
104 | break; /* Hit */ | ||
106 | } | 105 | } |
107 | 106 | ||
108 | if (button == SYS_USB_CONNECTED) { | 107 | /* Got the message - wait for disconnect */ |
109 | /* Got the message - wait for disconnect */ | 108 | show_splash(0, "Bootloader USB mode"); |
110 | show_splash(0, "Bootloader USB mode"); | ||
111 | 109 | ||
112 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | 110 | usb_acknowledge(SYS_USB_CONNECTED_ACK); |
113 | 111 | ||
114 | while (1) | 112 | while(1) { |
115 | { | 113 | button = button_get_w_tmo(HZ/2); |
116 | button = button_get(true); | 114 | if (button == SYS_USB_DISCONNECTED) |
117 | if (button == SYS_USB_DISCONNECTED) | 115 | break; |
118 | break; | ||
119 | } | ||
120 | } | 116 | } |
117 | |||
118 | show_splash(HZ*2, "USB disconnected"); | ||
121 | } | 119 | } |
122 | #endif | 120 | #endif |
123 | 121 | ||
@@ -196,8 +194,10 @@ int main(void) | |||
196 | #endif | 194 | #endif |
197 | 195 | ||
198 | button_init(); | 196 | button_init(); |
197 | enable_irq(); | ||
198 | |||
199 | int btn = button_read_device(); | 199 | int btn = button_read_device(); |
200 | if(btn & BUTTON_PLAY) { | 200 | if(btn & BUTTON_POWER) { |
201 | verbose = true; | 201 | verbose = true; |
202 | } | 202 | } |
203 | 203 | ||
@@ -209,20 +209,14 @@ int main(void) | |||
209 | 209 | ||
210 | filesystem_init(); | 210 | filesystem_init(); |
211 | 211 | ||
212 | /* Don't mount the disks yet, there could be file system/partition errors | ||
213 | which are fixable in USB mode */ | ||
214 | |||
215 | #ifdef HAVE_BOOTLOADER_USB_MODE | 212 | #ifdef HAVE_BOOTLOADER_USB_MODE |
216 | 213 | /* Enter USB mode if USB is plugged and POWER button is pressed */ | |
217 | /* Enter USB mode if USB is plugged and PLAY button is pressed */ | 214 | if (btn & BUTTON_POWER) { |
218 | if(btn & BUTTON_PLAY) { | 215 | usb_mode(); |
219 | if(usb_detect() == USB_INSERTED) | 216 | reset_screen(); |
220 | usb_mode(); | ||
221 | } | 217 | } |
222 | #endif /* HAVE_BOOTLOADER_USB_MODE */ | 218 | #endif /* HAVE_BOOTLOADER_USB_MODE */ |
223 | 219 | ||
224 | reset_screen(); | ||
225 | |||
226 | #ifndef SHOW_LOGO | 220 | #ifndef SHOW_LOGO |
227 | printf(MODEL_NAME" Rockbox Bootloader"); | 221 | printf(MODEL_NAME" Rockbox Bootloader"); |
228 | printf("Version %s", rbversion); | 222 | printf("Version %s", rbversion); |
@@ -235,15 +229,9 @@ int main(void) | |||
235 | printf("Error: %s", loader_strerror(rc)); | 229 | printf("Error: %s", loader_strerror(rc)); |
236 | } | 230 | } |
237 | 231 | ||
238 | #if 1 | ||
239 | /* Power off */ | 232 | /* Power off */ |
240 | sleep(5*HZ); | 233 | sleep(5*HZ); |
241 | power_off(); | 234 | power_off(); |
242 | #else | ||
243 | /* Halt */ | ||
244 | while (1) | ||
245 | core_idle(); | ||
246 | #endif | ||
247 | 235 | ||
248 | return 0; | 236 | return 0; |
249 | } | 237 | } |