aboutsummaryrefslogtreecommitdiff
path: root/stmhal/usb.c
diff options
context:
space:
mode:
authorDamien George2014-08-04 11:09:51 +0100
committerDamien George2014-08-04 11:09:51 +0100
commitccacdf44b6c5241ce05769e777008767a7ed8939 (patch)
tree30dfaa47c94ad4cc321750169830a2d0cd603305 /stmhal/usb.c
parent8dbbbbc793554f920cf352b0e67da46abe3974cf (diff)
stmhal: Clean up reset/soft-reset code; fix bug init'ing VCP exc.
Make a clearer distinction between init functions that must be done before any scripts can run (xxx_init0) and those that can be safely deferred (xxx_init). Fix bug initialising USB VCP exception. Addresses issue #788. Re-order some init function to improve reliability of reset/soft-reset.
Diffstat (limited to 'stmhal/usb.c')
-rw-r--r--stmhal/usb.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/stmhal/usb.c b/stmhal/usb.c
index 7db8ca218..40c474f43 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -45,8 +45,14 @@
USBD_HandleTypeDef hUSBDDevice;
#endif
-static int dev_is_enabled = 0;
-mp_obj_t mp_const_vcp_interrupt = MP_OBJ_NULL;
+STATIC int dev_is_enabled = 0;
+STATIC mp_obj_t mp_const_vcp_interrupt = MP_OBJ_NULL;
+
+void pyb_usb_init0(void) {
+ // create an exception object for interrupting by VCP
+ mp_const_vcp_interrupt = mp_obj_new_exception_msg(&mp_type_OSError, "VCPInterrupt");
+ USBD_CDC_SetInterrupt(VCP_CHAR_NONE, mp_const_vcp_interrupt);
+}
void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
#ifdef USE_DEVICE_MODE
@@ -72,9 +78,6 @@ void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
USBD_Start(&hUSBDDevice);
}
dev_is_enabled = 1;
-
- // create an exception object for interrupting by VCP
- mp_const_vcp_interrupt = mp_obj_new_exception_msg(&mp_type_OSError, "VCPInterrupt");
#endif
}