lpc176x: Explicitly disconnect USB on a bootloader request
It appears some host machines may not recognize that the USB device has disconnected upon start of bootloader mode. Explicitly disable USB and add a 5ms delay to help signal the host of the upcoming change. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
60ff2e9dc1
commit
fbbe2cf9d6
|
@ -8,6 +8,7 @@
|
||||||
#include "LPC17xx.h" // LPC_SC
|
#include "LPC17xx.h" // LPC_SC
|
||||||
#include "autoconf.h" // CONFIG_SMOOTHIEWARE_BOOTLOADER
|
#include "autoconf.h" // CONFIG_SMOOTHIEWARE_BOOTLOADER
|
||||||
#include "board/irq.h" // irq_disable
|
#include "board/irq.h" // irq_disable
|
||||||
|
#include "board/misc.h" // timer_read_time
|
||||||
#include "byteorder.h" // cpu_to_le32
|
#include "byteorder.h" // cpu_to_le32
|
||||||
#include "command.h" // output
|
#include "command.h" // output
|
||||||
#include "generic/usb_cdc.h" // usb_notify_ep0
|
#include "generic/usb_cdc.h" // usb_notify_ep0
|
||||||
|
@ -248,9 +249,14 @@ usb_request_bootloader(void)
|
||||||
{
|
{
|
||||||
if (!CONFIG_SMOOTHIEWARE_BOOTLOADER)
|
if (!CONFIG_SMOOTHIEWARE_BOOTLOADER)
|
||||||
return;
|
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
|
// The "LPC17xx-DFU-Bootloader" will enter the bootloader if the
|
||||||
// watchdog timeout flag is set.
|
// watchdog timeout flag is set.
|
||||||
irq_disable();
|
|
||||||
LPC_WDT->WDMOD = 0x07;
|
LPC_WDT->WDMOD = 0x07;
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue