提交 04fe62d0 编写于 作者: A Andrew Leech 提交者: Damien George

stm32/mboot: Add option to automatically reset when USB is disconnected.

Enable in board config with: #define MBOOT_USB_RESET_ON_DISCONNECT (1)
上级 fa23033f
......@@ -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
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册