diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-12-20 13:58:58 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-03-05 22:01:27 +0200 |
commit | d3a4d39687f941d12d727b80c79dd98ebae03674 (patch) | |
tree | 155e0c8a446f1cd4d8d99701c04bd271342464a6 /esp8266/main.c | |
parent | 077448328a42e732c1ae3a063670b71914ed489c (diff) | |
download | micropython-d3a4d39687f941d12d727b80c79dd98ebae03674.tar.gz micropython-d3a4d39687f941d12d727b80c79dd98ebae03674.zip |
esp8266: Support raising KeyboardInterrupt on Ctrl+C.
Diffstat (limited to 'esp8266/main.c')
-rw-r--r-- | esp8266/main.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/esp8266/main.c b/esp8266/main.c index 4fd1189288..3e12008ce6 100644 --- a/esp8266/main.c +++ b/esp8266/main.c @@ -47,6 +47,7 @@ STATIC void mp_reset(void) { mp_init(); mp_obj_list_init(mp_sys_path, 0); mp_obj_list_init(mp_sys_argv, 0); + MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt); #if MICROPY_MODULE_FROZEN pyexec_frozen_module("main"); #endif @@ -83,6 +84,10 @@ mp_obj_t mp_builtin_open(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) { } MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); +void mp_keyboard_interrupt(void) { + MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception); +} + void nlr_jump_fail(void *val) { printf("NLR jump failed\n"); for (;;) { |