move reload exception to reload.c

This commit is contained in:
Roy Hooper 2018-05-14 17:41:17 -04:00
parent 698912633f
commit 92b1cb5743
4 changed files with 29 additions and 7 deletions

View File

@ -188,6 +188,7 @@ PY_O_BASENAME = \
objtype.o \ objtype.o \
objzip.o \ objzip.o \
opmethods.o \ opmethods.o \
reload.o \
sequence.o \ sequence.o \
stream.o \ stream.o \
binary.o \ binary.o \

16
py/reload.c Normal file
View File

@ -0,0 +1,16 @@
//
// Created by Roy Hooper on 2018-05-14.
//
#include "reload.h"
#include "py/mpstate.h"
void mp_raise_reload_exception(void) {
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception));
#if MICROPY_ENABLE_SCHEDULER
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
}
#endif
}

10
py/reload.h Normal file
View File

@ -0,0 +1,10 @@
//
// Created by Roy Hooper on 2018-05-14.
//
#ifndef CIRCUITPYTHON_RELOAD_H
#define CIRCUITPYTHON_RELOAD_H
void mp_raise_reload_exception(void);
#endif //CIRCUITPYTHON_RELOAD_H

View File

@ -25,6 +25,7 @@
*/ */
#include "py/obj.h" #include "py/obj.h"
#include "py/runtime.h" #include "py/runtime.h"
#include "py/reload.h"
#include "lib/utils/interrupt_char.h" #include "lib/utils/interrupt_char.h"
#include "supervisor/shared/autoreload.h" #include "supervisor/shared/autoreload.h"
@ -101,13 +102,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_s
//| //|
STATIC mp_obj_t supervisor_reload(void) { STATIC mp_obj_t supervisor_reload(void) {
reload_requested = true; reload_requested = true;
mp_raise_reload_exception();
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception));
#if MICROPY_ENABLE_SCHEDULER
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
}
#endif
return mp_const_none; return mp_const_none;
} }
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload); MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload);