stm32/mboot: Add option to automatically reset when USB is disconnected.
Enable in board config with: #define MBOOT_USB_RESET_ON_DISCONNECT (1)
This commit is contained in:
parent
fa23033fc4
commit
04fe62d06f
@ -1526,6 +1526,9 @@ enter_bootloader:
|
|||||||
uint32_t ss = systick_ms;
|
uint32_t ss = systick_ms;
|
||||||
int ss2 = -1;
|
int ss2 = -1;
|
||||||
#endif
|
#endif
|
||||||
|
#if MBOOT_USB_RESET_ON_DISCONNECT
|
||||||
|
bool has_connected = false;
|
||||||
|
#endif
|
||||||
for (;;) {
|
for (;;) {
|
||||||
#if USE_USB_POLLING
|
#if USE_USB_POLLING
|
||||||
#if MBOOT_USB_AUTODETECT_PORT || MICROPY_HW_USB_MAIN_DEV == USB_PHY_FS_ID
|
#if MBOOT_USB_AUTODETECT_PORT || MICROPY_HW_USB_MAIN_DEV == USB_PHY_FS_ID
|
||||||
@ -1559,6 +1562,15 @@ enter_bootloader:
|
|||||||
led_state(LED0, 0);
|
led_state(LED0, 0);
|
||||||
mp_hal_delay_ms(950);
|
mp_hal_delay_ms(950);
|
||||||
#endif
|
#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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user