Skip to content

Issue #2865 -Clean up after ctrl-c interrupt in sleep #3043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 23, 2020
2 changes: 2 additions & 0 deletions shared-module/time/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "py/mphal.h"
#include "supervisor/port.h"
#include "supervisor/shared/tick.h"
#include "py/obj.h"
#include "py/mpstate.h"

uint64_t common_hal_time_monotonic(void) {
return supervisor_ticks_ms64();
Expand Down
6 changes: 6 additions & 0 deletions supervisor/shared/tick.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ void mp_hal_delay_ms(mp_uint_t delay) {
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)) ||
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
WATCHDOG_EXCEPTION_CHECK()) {
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_obj_new_exception(&mp_type_KeyboardInterrupt));
}
break;
}
remaining = end_tick - port_get_raw_ticks(NULL);
Expand Down