Skip to content

Commit

Permalink
Added 100us delay between USB power-down and system reset.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatev committed Jul 5, 2020
1 parent 791621b commit 044510b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/usb_vcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ static enum usbd_request_return_codes vcp_control_request(
struct usb_setup_data *req)) {

switch (req->bRequest) {

case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
g_usbd_is_connected = req->wValue & 1;

Expand All @@ -242,6 +241,11 @@ static enum usbd_request_return_codes vcp_control_request(
write_dfu_magicword();
kill_usb();

/* Wait ~100us (stm32f103). This appears to be
* necessary in specific USB environments. */
for(uint i = 0; i < 1200; i++)
__asm__("nop");

scb_reset_system();

// Won't actually return
Expand Down
5 changes: 5 additions & 0 deletions dfu-bootloader/usbdfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ static void usbdfu_getstatus_complete(usbd_device *usbd_dev, struct usb_setup_da
write_magic_word(MAGICWORD_LOAD_APP);
kill_usb();

/* Wait ~100us (stm32f103). This appears to be
* necessary in specific USB environments. */
for(i = 0; i < 1200; i++)
__asm__("nop");

scb_reset_system();

return; /* Will never return. */
Expand Down

0 comments on commit 044510b

Please sign in to comment.