stmhal: Stop USB before entering DFU by software.
This commit is contained in:
parent
008343f640
commit
6d197740cf
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user