Skip to content

Commit f254cfd

Browse files
committed
stmhal: Rename mp_const_vcp_interrupt to mp_kbd_exception.
mp_kbd_exception is now considered the standard variable name to hold the singleton KeyboardInterrupt exception. This patch also moves the creation of this object from pyb_usb_init() to main().
1 parent 29b5879 commit f254cfd

4 files changed

Lines changed: 6 additions & 7 deletions

File tree

stmhal/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ int main(void) {
438438
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash));
439439
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib));
440440
mp_obj_list_init(mp_sys_argv, 0);
441+
MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
441442

442443
// Initialise low-level sub-systems. Here we need to very basic things like
443444
// zeroing out memory and resetting any of the sub-systems. Following this

stmhal/mpconfigport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ extern const struct _mp_obj_module_t mp_module_network;
208208
#define MICROPY_PORT_ROOT_POINTERS \
209209
const char *readline_hist[8]; \
210210
\
211-
mp_obj_t mp_const_vcp_interrupt; \
211+
mp_obj_t mp_kbd_exception; \
212212
mp_obj_t pyb_hid_report_desc; \
213213
\
214214
mp_obj_t pyb_config_main; \

stmhal/pendsv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// PENDSV call that actually raises the exception. It must be non-static
3737
// otherwise gcc-5 optimises it away. It can point to the heap but is not
3838
// traced by GC. This is okay because we only ever set it to
39-
// mp_const_vcp_interrupt which is in the root-pointer set.
39+
// mp_kbd_exception which is in the root-pointer set.
4040
void *pendsv_object;
4141

4242
void pendsv_init(void) {

stmhal/usb.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ const mp_obj_tuple_t pyb_usb_hid_keyboard_obj = {
9696
};
9797

9898
void pyb_usb_init0(void) {
99-
// create an exception object for interrupting by VCP
100-
MP_STATE_PORT(mp_const_vcp_interrupt) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
101-
USBD_CDC_SetInterrupt(-1, MP_STATE_PORT(mp_const_vcp_interrupt));
99+
USBD_CDC_SetInterrupt(-1, MP_STATE_PORT(mp_kbd_exception));
102100
MP_STATE_PORT(pyb_hid_report_desc) = MP_OBJ_NULL;
103101
}
104102

@@ -146,9 +144,9 @@ bool usb_vcp_is_enabled(void) {
146144
void usb_vcp_set_interrupt_char(int c) {
147145
if (pyb_usb_flags & PYB_USB_FLAG_DEV_ENABLED) {
148146
if (c != -1) {
149-
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_const_vcp_interrupt));
147+
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
150148
}
151-
USBD_CDC_SetInterrupt(c, MP_STATE_PORT(mp_const_vcp_interrupt));
149+
USBD_CDC_SetInterrupt(c, MP_STATE_PORT(mp_kbd_exception));
152150
}
153151
}
154152

0 commit comments

Comments
 (0)