supervisor: use mp_handle_pending to check for exceptions
This commit is contained in:
parent
f8a9e11ff4
commit
1033e89561
@ -30,6 +30,7 @@
|
||||
#include "lib/oofatfs/ff.h"
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/mpstate.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "supervisor/shared/status_leds.h"
|
||||
|
||||
@ -45,16 +46,7 @@ int mp_hal_stdin_rx_chr(void) {
|
||||
#ifdef MICROPY_VM_HOOK_LOOP
|
||||
MICROPY_VM_HOOK_LOOP
|
||||
#endif
|
||||
// Check to see if we've been CTRL-Ced by autoreload or the user.
|
||||
if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) {
|
||||
// clear exception and generate stacktrace
|
||||
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
|
||||
nlr_raise(&MP_STATE_VM(mp_kbd_exception));
|
||||
}
|
||||
if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) || WATCHDOG_EXCEPTION_CHECK()) {
|
||||
// stop reading immediately
|
||||
return EOF;
|
||||
}
|
||||
mp_handle_pending();
|
||||
if (serial_bytes_available()) {
|
||||
toggle_rx_led();
|
||||
return serial_read();
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "supervisor/shared/tick.h"
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include "py/runtime.h"
|
||||
#include "supervisor/linker.h"
|
||||
#include "supervisor/filesystem.h"
|
||||
#include "supervisor/background_callback.h"
|
||||
@ -149,17 +150,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
|
||||
while (remaining > 0) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
// Check to see if we've been CTRL-Ced by autoreload or the user.
|
||||
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
|
||||
{
|
||||
// clear exception and generate stacktrace
|
||||
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
|
||||
nlr_raise(&MP_STATE_VM(mp_kbd_exception));
|
||||
}
|
||||
if( MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
|
||||
WATCHDOG_EXCEPTION_CHECK()) {
|
||||
// stop sleeping immediately
|
||||
break;
|
||||
}
|
||||
mp_handle_pending();
|
||||
remaining = end_tick - port_get_raw_ticks(NULL);
|
||||
// We break a bit early so we don't risk setting the alarm before the time when we call
|
||||
// sleep.
|
||||
|
Loading…
Reference in New Issue
Block a user