Skip to content

Commit 0b52359

Browse files
authored
Generate stacktrace and reset exception for ctrl-c interrupt
Added code in mp_hal_delay_ms() to generate stacktrace and reset exception for ctrl-c interrupt
1 parent e381f59 commit 0b52359

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

supervisor/shared/tick.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ void mp_hal_delay_ms(mp_uint_t delay) {
105105
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
106106
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
107107
WATCHDOG_EXCEPTION_CHECK()) {
108+
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
109+
{
110+
// clear exception and generate stacktrace
111+
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
112+
nlr_raise(mp_obj_new_exception(&mp_type_KeyboardInterrupt));
113+
}
108114
break;
109115
}
110116
remaining = end_tick - port_get_raw_ticks(NULL);

0 commit comments

Comments
 (0)