From 6e74d24f30bca3fb70876b1fb9a6b3a59850b83c Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 16 Feb 2017 18:05:06 +1100 Subject: py: Add micropython.schedule() function and associated runtime code. --- lib/utils/interrupt_char.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/utils/interrupt_char.c') diff --git a/lib/utils/interrupt_char.c b/lib/utils/interrupt_char.c index ab4efd911..344db88c7 100644 --- a/lib/utils/interrupt_char.c +++ b/lib/utils/interrupt_char.c @@ -46,4 +46,9 @@ void mp_keyboard_interrupt(void) { #else MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception); #endif + #if MICROPY_ENABLE_SCHEDULER + if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { + MP_STATE_VM(sched_state) = MP_SCHED_PENDING; + } + #endif } -- cgit v1.2.3 From ab954ed5136af8be910b3c3fb9246bad6289a3a4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 2 Jun 2017 12:03:57 +1000 Subject: lib/utils/interrupt_char: Remove support for KBD_EXCEPTION disabled. If a port is using interrupt_char.c then it must enable MICROPY_KBD_EXCEPTION. This is the case for all official ports. --- lib/utils/interrupt_char.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lib/utils/interrupt_char.c') diff --git a/lib/utils/interrupt_char.c b/lib/utils/interrupt_char.c index 344db88c7..fca0f95b5 100644 --- a/lib/utils/interrupt_char.c +++ b/lib/utils/interrupt_char.c @@ -27,28 +27,24 @@ #include "py/obj.h" #include "py/mpstate.h" +#if MICROPY_KBD_EXCEPTION + int mp_interrupt_char; void mp_hal_set_interrupt_char(int c) { if (c != -1) { - #if MICROPY_KBD_EXCEPTION mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); - #else - mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception)); - #endif } mp_interrupt_char = c; } void mp_keyboard_interrupt(void) { - #if MICROPY_KBD_EXCEPTION MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)); - #else - MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception); - #endif #if MICROPY_ENABLE_SCHEDULER if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { MP_STATE_VM(sched_state) = MP_SCHED_PENDING; } #endif } + +#endif -- cgit v1.2.3