From 124df6f8d07b53542b6960dbeea9b63bff469a67 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 25 Oct 2014 18:19:55 +0100 Subject: py: Add mp_pending_exception global variable, for VM soft interrupt. This allows to implement KeyboardInterrupt on unix, and a much safer ctrl-C in stmhal port. First ctrl-C is a soft one, with hope that VM will notice it; second ctrl-C is a hard one that kills anything (for both unix and stmhal). One needs to check for a pending exception in the VM only for jump opcodes. Others can't produce an infinite loop (infinite recursion is caught by stack check). --- stmhal/usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stmhal/usb.c') diff --git a/stmhal/usb.c b/stmhal/usb.c index c522b6443..4211c8829 100644 --- a/stmhal/usb.c +++ b/stmhal/usb.c @@ -50,7 +50,7 @@ STATIC mp_obj_t mp_const_vcp_interrupt = MP_OBJ_NULL; void pyb_usb_init0(void) { // create an exception object for interrupting by VCP - mp_const_vcp_interrupt = mp_obj_new_exception_msg(&mp_type_OSError, "VCPInterrupt"); + mp_const_vcp_interrupt = mp_obj_new_exception(&mp_type_KeyboardInterrupt); USBD_CDC_SetInterrupt(VCP_CHAR_NONE, mp_const_vcp_interrupt); } -- cgit v1.2.3