diff options
author | Damien George <damien.p.george@gmail.com> | 2020-02-06 20:25:54 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-07 16:08:26 +1100 |
commit | 9efb36bfa66d5846c14f21778c25dff7dd733826 (patch) | |
tree | f87dd0a7a4a891f4042cbb6722d81718e3660e49 /py/scheduler.c | |
parent | 5a91cd9ff3e97b74ad6c9a615f810b8fcebbe110 (diff) |
py/scheduler: Move mp_keyboard_interrupt from lib/utils to py core.
This function is tightly coupled to the state and behaviour of the
scheduler, and is a core part of the runtime: to schedule a pending
exception. So move it there.
Diffstat (limited to 'py/scheduler.c')
-rw-r--r-- | py/scheduler.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/py/scheduler.c b/py/scheduler.c index ff88be958..250c85983 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)) |