summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/mboot/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c
index a0f1f1eac..015800ce4 100644
--- a/ports/stm32/mboot/main.c
+++ b/ports/stm32/mboot/main.c
@@ -1526,6 +1526,9 @@ enter_bootloader:
uint32_t ss = systick_ms;
int ss2 = -1;
#endif
+ #if MBOOT_USB_RESET_ON_DISCONNECT
+ bool has_connected = false;
+ #endif
for (;;) {
#if USE_USB_POLLING
#if MBOOT_USB_AUTODETECT_PORT || MICROPY_HW_USB_MAIN_DEV == USB_PHY_FS_ID
@@ -1559,6 +1562,15 @@ enter_bootloader:
led_state(LED0, 0);
mp_hal_delay_ms(950);
#endif
+
+ #if MBOOT_USB_RESET_ON_DISCONNECT
+ if (pyb_usbdd.hUSBDDevice.dev_state == USBD_STATE_CONFIGURED) {
+ has_connected = true;
+ }
+ if (has_connected && pyb_usbdd.hUSBDDevice.dev_state == USBD_STATE_SUSPENDED) {
+ do_reset();
+ }
+ #endif
}
}