File tree Expand file tree Collapse file tree 6 files changed +10
-7
lines changed Expand file tree Collapse file tree 6 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ int switch_get(int sw) {
140
140
// TODO need an irq
141
141
void uart_rx_irq(void) {
142
142
if (c == interrupt_char) {
143
- MP_STATE_THREAD (mp_pending_exception) = MP_STATE_PORT(keyboard_interrupt_obj);
143
+ MP_STATE_MAIN_THREAD (mp_pending_exception) = MP_STATE_PORT(keyboard_interrupt_obj);
144
144
}
145
145
}
146
146
*/
Original file line number Diff line number Diff line change @@ -60,10 +60,10 @@ void pendsv_init(void) {
60
60
// the given exception object using nlr_jump in the context of the top-level
61
61
// thread.
62
62
void pendsv_kbd_intr (void ) {
63
- if (MP_STATE_THREAD (mp_pending_exception ) == MP_OBJ_NULL ) {
63
+ if (MP_STATE_MAIN_THREAD (mp_pending_exception ) == MP_OBJ_NULL ) {
64
64
mp_sched_keyboard_interrupt ();
65
65
} else {
66
- MP_STATE_THREAD (mp_pending_exception ) = MP_OBJ_NULL ;
66
+ MP_STATE_MAIN_THREAD (mp_pending_exception ) = MP_OBJ_NULL ;
67
67
pendsv_object = & MP_STATE_VM (mp_kbd_exception );
68
68
SCB -> ICSR = SCB_ICSR_PENDSVSET_Msk ;
69
69
}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ STATIC void sighandler(int signum) {
54
54
sigprocmask (SIG_SETMASK , & mask , NULL );
55
55
nlr_raise (MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception )));
56
56
#else
57
- if (MP_STATE_THREAD (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception ))) {
57
+ if (MP_STATE_MAIN_THREAD (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception ))) {
58
58
// this is the second time we are called, so die straight away
59
59
exit (1 );
60
60
}
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ void mp_hal_stdio_mode_orig(void) {
80
80
// the thread created for handling it might not be running yet so we'd miss the notification.
81
81
BOOL WINAPI console_sighandler (DWORD evt ) {
82
82
if (evt == CTRL_C_EVENT ) {
83
- if (MP_STATE_THREAD (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception ))) {
83
+ if (MP_STATE_MAIN_THREAD (mp_pending_exception ) == MP_OBJ_FROM_PTR (& MP_STATE_VM (mp_kbd_exception ))) {
84
84
// this is the second time we are called, so die straight away
85
85
exit (1 );
86
86
}
Original file line number Diff line number Diff line change @@ -285,12 +285,13 @@ extern mp_state_ctx_t mp_state_ctx;
285
285
286
286
#define MP_STATE_VM (x ) (mp_state_ctx.vm.x)
287
287
#define MP_STATE_MEM (x ) (mp_state_ctx.mem.x)
288
+ #define MP_STATE_MAIN_THREAD (x ) (mp_state_ctx.thread.x)
288
289
289
290
#if MICROPY_PY_THREAD
290
291
extern mp_state_thread_t * mp_thread_get_state (void );
291
292
#define MP_STATE_THREAD (x ) (mp_thread_get_state()->x)
292
293
#else
293
- #define MP_STATE_THREAD (x ) (mp_state_ctx.thread. x)
294
+ #define MP_STATE_THREAD (x ) MP_STATE_MAIN_THREAD( x)
294
295
#endif
295
296
296
297
#endif // MICROPY_INCLUDED_PY_MPSTATE_H
Original file line number Diff line number Diff line change 28
28
29
29
#include "py/runtime.h"
30
30
31
+ // Schedules an exception on the main thread (for exceptions "thrown" by async
32
+ // sources such as interrupts and UNIX signal handlers).
31
33
void MICROPY_WRAP_MP_SCHED_EXCEPTION (mp_sched_exception )(mp_obj_t exc ) {
32
- MP_STATE_THREAD (mp_pending_exception ) = exc ;
34
+ MP_STATE_MAIN_THREAD (mp_pending_exception ) = exc ;
33
35
#if MICROPY_ENABLE_SCHEDULER
34
36
if (MP_STATE_VM (sched_state ) == MP_SCHED_IDLE ) {
35
37
MP_STATE_VM (sched_state ) = MP_SCHED_PENDING ;
You can’t perform that action at this time.
0 commit comments