stmhal: Stop USB before entering DFU by software.

This commit is contained in:
Damien George 2014-05-21 19:25:34 +01:00
parent 008343f640
commit 6d197740cf
3 changed files with 9 additions and 0 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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);