aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lpc176x/usbserial.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lpc176x/usbserial.c b/src/lpc176x/usbserial.c
index d6db8565..847746d8 100644
--- a/src/lpc176x/usbserial.c
+++ b/src/lpc176x/usbserial.c
@@ -8,6 +8,7 @@
#include "LPC17xx.h" // LPC_SC
#include "autoconf.h" // CONFIG_SMOOTHIEWARE_BOOTLOADER
#include "board/irq.h" // irq_disable
+#include "board/misc.h" // timer_read_time
#include "byteorder.h" // cpu_to_le32
#include "command.h" // output
#include "generic/usb_cdc.h" // usb_notify_ep0
@@ -248,9 +249,14 @@ usb_request_bootloader(void)
{
if (!CONFIG_SMOOTHIEWARE_BOOTLOADER)
return;
+ // Disable USB and pause for 5ms so host recognizes a disconnect
+ irq_disable();
+ sie_cmd_write(SIE_CMD_SET_DEVICE_STATUS, 0);
+ uint32_t end = timer_read_time() + timer_from_us(5000);
+ while (timer_is_before(timer_read_time(), end))
+ ;
// The "LPC17xx-DFU-Bootloader" will enter the bootloader if the
// watchdog timeout flag is set.
- irq_disable();
LPC_WDT->WDMOD = 0x07;
NVIC_SystemReset();
}