Skip to content

Commit a770ba1

Browse files
committed
stmhal: Use core-provided keyboard exception object.
1 parent d89cafd commit a770ba1

4 files changed

Lines changed: 3 additions & 4 deletions

File tree

stmhal/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ 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);
442441

443442
// Initialise low-level sub-systems. Here we need to very basic things like
444443
// 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
@@ -42,6 +42,7 @@
4242
#define MICROPY_ENABLE_GC (1)
4343
#define MICROPY_ENABLE_FINALISER (1)
4444
#define MICROPY_STACK_CHECK (1)
45+
#define MICROPY_KBD_EXCEPTION (1)
4546
#define MICROPY_HELPER_REPL (1)
4647
#define MICROPY_REPL_EMACS_KEYS (1)
4748
#define MICROPY_REPL_AUTO_INDENT (1)
@@ -208,7 +209,6 @@ extern const struct _mp_obj_module_t mp_module_network;
208209
#define MICROPY_PORT_ROOT_POINTERS \
209210
const char *readline_hist[8]; \
210211
\
211-
mp_obj_t mp_kbd_exception; \
212212
mp_obj_t pyb_hid_report_desc; \
213213
\
214214
mp_obj_t pyb_config_main; \

stmhal/usb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ bool usb_vcp_is_enabled(void) {
144144
void usb_vcp_set_interrupt_char(int c) {
145145
if (pyb_usb_flags & PYB_USB_FLAG_DEV_ENABLED) {
146146
if (c != -1) {
147-
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
147+
mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)));
148148
}
149149
USBD_CDC_SetInterrupt(c);
150150
}

stmhal/usbd_cdc_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ static int8_t CDC_Itf_Receive(uint8_t* Buf, uint32_t *Len) {
353353
if (*src == user_interrupt_char) {
354354
char_found = true;
355355
// raise exception when interrupts are finished
356-
pendsv_nlr_jump(MP_STATE_PORT(mp_kbd_exception));
356+
pendsv_nlr_jump(&MP_STATE_VM(mp_kbd_exception));
357357
} else {
358358
if (char_found) {
359359
*dest = *src;

0 commit comments

Comments
 (0)