summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/usb.c')
-rw-r--r--stmhal/usb.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/stmhal/usb.c b/stmhal/usb.c
index 50a5a7420d..0bda0aaeb2 100644
--- a/stmhal/usb.c
+++ b/stmhal/usb.c
@@ -45,12 +45,11 @@ USBD_HandleTypeDef hUSBDDevice;
#endif
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(&mp_type_KeyboardInterrupt);
- USBD_CDC_SetInterrupt(-1, mp_const_vcp_interrupt);
+ MP_STATE_PORT(mp_const_vcp_interrupt) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
+ USBD_CDC_SetInterrupt(-1, MP_STATE_PORT(mp_const_vcp_interrupt));
}
void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
@@ -102,9 +101,9 @@ bool usb_vcp_is_connected(void) {
void usb_vcp_set_interrupt_char(int c) {
if (dev_is_enabled) {
if (c != -1) {
- mp_obj_exception_clear_traceback(mp_const_vcp_interrupt);
+ mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_const_vcp_interrupt));
}
- USBD_CDC_SetInterrupt(c, mp_const_vcp_interrupt);
+ USBD_CDC_SetInterrupt(c, MP_STATE_PORT(mp_const_vcp_interrupt));
}
}