Commit 6d197740 authored by Damien George's avatar Damien George
Browse files

stmhal: Stop USB before entering DFU by software.

parent 008343f6
......@@ -65,6 +65,7 @@
/// \function bootloader()
/// Activate the bootloader without BOOT* pins.
STATIC NORETURN mp_obj_t pyb_bootloader(void) {
pyb_usb_dev_stop();
storage_flush();
HAL_RCC_DeInit();
......
......@@ -75,6 +75,13 @@ void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
#endif
}
void pyb_usb_dev_stop(void) {
if (dev_is_enabled) {
USBD_Stop(&hUSBDDevice);
dev_is_enabled = 0;
}
}
bool usb_vcp_is_enabled(void) {
return dev_is_enabled;
}
......
......@@ -42,6 +42,7 @@ typedef enum {
} usb_storage_medium_t;
void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium);
void pyb_usb_dev_stop(void);
bool usb_vcp_is_enabled(void);
bool usb_vcp_is_connected(void);
void usb_vcp_set_interrupt_char(int c);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment