Skip to content

Commit 92b1cb5

Browse files
committed
move reload exception to reload.c
1 parent 6989126 commit 92b1cb5

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

py/py.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ PY_O_BASENAME = \
188188
objtype.o \
189189
objzip.o \
190190
opmethods.o \
191+
reload.o \
191192
sequence.o \
192193
stream.o \
193194
binary.o \

py/reload.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// Created by Roy Hooper on 2018-05-14.
3+
//
4+
5+
#include "reload.h"
6+
#include "py/mpstate.h"
7+
8+
void mp_raise_reload_exception(void) {
9+
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception));
10+
#if MICROPY_ENABLE_SCHEDULER
11+
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
12+
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
13+
}
14+
#endif
15+
16+
}

py/reload.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Created by Roy Hooper on 2018-05-14.
3+
//
4+
5+
#ifndef CIRCUITPYTHON_RELOAD_H
6+
#define CIRCUITPYTHON_RELOAD_H
7+
8+
void mp_raise_reload_exception(void);
9+
10+
#endif //CIRCUITPYTHON_RELOAD_H

shared-bindings/supervisor/__init__.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626
#include "py/obj.h"
2727
#include "py/runtime.h"
28+
#include "py/reload.h"
2829

2930
#include "lib/utils/interrupt_char.h"
3031
#include "supervisor/shared/autoreload.h"
@@ -101,13 +102,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_s
101102
//|
102103
STATIC mp_obj_t supervisor_reload(void) {
103104
reload_requested = true;
104-
105-
MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception));
106-
#if MICROPY_ENABLE_SCHEDULER
107-
if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) {
108-
MP_STATE_VM(sched_state) = MP_SCHED_PENDING;
109-
}
110-
#endif
105+
mp_raise_reload_exception();
111106
return mp_const_none;
112107
}
113108
MP_DEFINE_CONST_FUN_OBJ_0(supervisor_reload_obj, supervisor_reload);

0 commit comments

Comments
 (0)