move reload exception to reload.c
This commit is contained in:
parent
698912633f
commit
92b1cb5743
1
py/py.mk
1
py/py.mk
@ -188,6 +188,7 @@ PY_O_BASENAME = \
|
||||
objtype.o \
|
||||
objzip.o \
|
||||
opmethods.o \
|
||||
reload.o \
|
||||
sequence.o \
|
||||
stream.o \
|
||||
binary.o \
|
||||
|
16
py/reload.c
Normal file
16
py/reload.c
Normal 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
10
py/reload.h
Normal 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
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/reload.h"
|
||||
|
||||
#include "lib/utils/interrupt_char.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) {
|
||||
reload_requested = true;
|
||||
|
||||
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
|
||||
mp_raise_reload_exception();
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload);
|
||||
|
Loading…
x
Reference in New Issue
Block a user