summaryrefslogtreecommitdiffstatshomepage
path: root/zephyr
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-09-29 10:24:56 -0700
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-10-10 23:02:51 +0300
commit93c76d2b06e0f52395dc2d5fa1d7fae54c9164f7 (patch)
tree892dfa30adfcdef871d3cf3db01ab5ec208ae451 /zephyr
parent1b76f88e7a04e6accbfd1caab325a7dfd4717ef8 (diff)
downloadmicropython-93c76d2b06e0f52395dc2d5fa1d7fae54c9164f7.tar.gz
micropython-93c76d2b06e0f52395dc2d5fa1d7fae54c9164f7.zip
zephyr: Add Ctrl+C handling.
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/Makefile1
-rw-r--r--zephyr/main.c2
-rw-r--r--zephyr/mpconfigport.h1
-rw-r--r--zephyr/mphalport.h1
4 files changed, 4 insertions, 1 deletions
diff --git a/zephyr/Makefile b/zephyr/Makefile
index 501fb0a310..2cc314b533 100644
--- a/zephyr/Makefile
+++ b/zephyr/Makefile
@@ -37,6 +37,7 @@ SRC_C = main.c \
lib/utils/stdout_helpers.c \
lib/utils/printf.c \
lib/utils/pyexec.c \
+ lib/utils/interrupt_char.c \
lib/mp-readline/readline.c \
$(BUILD)/frozen.c \
$(SRC_MOD)
diff --git a/zephyr/main.c b/zephyr/main.c
index d6ac56943c..3bd768f686 100644
--- a/zephyr/main.c
+++ b/zephyr/main.c
@@ -9,6 +9,7 @@
#include "py/gc.h"
#include "py/stackctrl.h"
#include "lib/utils/pyexec.h"
+#include "lib/mp-readline/readline.h"
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, src, strlen(src), 0);
@@ -44,6 +45,7 @@ int real_main(void) {
gc_init(heap, heap + sizeof(heap));
#endif
mp_init();
+ MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
pyexec_frozen_module("main.py");
#if MICROPY_REPL_EVENT_DRIVEN
pyexec_event_repl_init();
diff --git a/zephyr/mpconfigport.h b/zephyr/mpconfigport.h
index 5d021b6aa2..2c5fad21b7 100644
--- a/zephyr/mpconfigport.h
+++ b/zephyr/mpconfigport.h
@@ -46,6 +46,7 @@ typedef long mp_off_t;
#define MP_STATE_PORT MP_STATE_VM
#define MICROPY_PORT_ROOT_POINTERS \
+ mp_obj_t mp_kbd_exception; \
const char *readline_hist[8];
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles
diff --git a/zephyr/mphalport.h b/zephyr/mphalport.h
index 60d68bd2d6..1bb64e0002 100644
--- a/zephyr/mphalport.h
+++ b/zephyr/mphalport.h
@@ -1,2 +1 @@
static inline mp_uint_t mp_hal_ticks_ms(void) { return 0; }
-static inline void mp_hal_set_interrupt_char(char c) {}