diff options
author | Damien George <damien.p.george@gmail.com> | 2014-05-21 19:25:34 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-05-21 19:25:34 +0100 |
commit | 6d197740cf7067c65f40574f7cf0707480bbf461 (patch) | |
tree | 7d434232d43782fd4cbb6dc4dce450ca72e180db | |
parent | 008343f6408ca6ec3be153e94b6e7824f2ce5a47 (diff) |
stmhal: Stop USB before entering DFU by software.
-rw-r--r-- | stmhal/modpyb.c | 1 | ||||
-rw-r--r-- | stmhal/usb.c | 7 | ||||
-rw-r--r-- | stmhal/usb.h | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index 43a017751..7ec25038b 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -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(); diff --git a/stmhal/usb.c b/stmhal/usb.c index fd8cbb95a..ef7e8a62e 100644 --- a/stmhal/usb.c +++ b/stmhal/usb.c @@ -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; } diff --git a/stmhal/usb.h b/stmhal/usb.h index 8b8562ce6..3bd30ba92 100644 --- a/stmhal/usb.h +++ b/stmhal/usb.h @@ -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); |