From 8fb5c8fdd506518ebdcca0b0628fbfb5c77c38a2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 7 Feb 2020 12:07:50 +1100 Subject: [PATCH] py/scheduler: Allow a port to specify attrs for mp_keyboard_interrupt. Functions like mp_keyboard_interrupt() may need to be called from an IRQ handler and may need to be in a special memory section, so provide a generic wrapping macro for a port to do this. The macro name is chosen to be MICROPY_WRAP_ so that (in the future with more wrappers) each function could potentially be handled separately. --- py/mpconfig.h | 7 +++++++ py/scheduler.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/py/mpconfig.h b/py/mpconfig.h index 8e06153a83..f2754ddd1a 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -1438,6 +1438,13 @@ typedef double mp_float_t; #define MICROPY_PORT_ROOT_POINTERS #endif +/*****************************************************************************/ +/* Hooks for a port to wrap functions with attributes */ + +#ifndef MICROPY_WRAP_MP_KEYBOARD_INTERRUPT +#define MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(f) f +#endif + /*****************************************************************************/ /* Miscellaneous settings */ diff --git a/py/scheduler.c b/py/scheduler.c index 250c859831..ca91e42da6 100644 --- a/py/scheduler.c +++ b/py/scheduler.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #if MICROPY_KBD_EXCEPTION -void mp_keyboard_interrupt(void) { +void MICROPY_WRAP_MP_KEYBOARD_INTERRUPT(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) {