summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/runtime.h1
-rw-r--r--py/scheduler.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/py/runtime.h b/py/runtime.h
index 1c078ae81a..063971883a 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -64,6 +64,7 @@ extern const byte mp_binary_op_method_name[];
void mp_init(void);
void mp_deinit(void);
+void mp_keyboard_interrupt(void);
void mp_handle_pending(bool raise_exc);
void mp_handle_pending_tail(mp_uint_t atomic_state);
diff --git a/py/scheduler.c b/py/scheduler.c
index ff88be9583..250c859831 100644
--- a/py/scheduler.c
+++ b/py/scheduler.c
@@ -28,6 +28,17 @@
#include "py/runtime.h"
+#if MICROPY_KBD_EXCEPTION
+void mp_keyboard_interrupt(void) {
+ MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception));
+ #if MICROPY_ENABLE_SCHEDULER
+ if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
+ MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
+ }
+ #endif
+}
+#endif
+
#if MICROPY_ENABLE_SCHEDULER
#define IDX_MASK(i) ((i) & (MICROPY_SCHEDULER_DEPTH - 1))