Skip to content

Commit 93c76d2

Browse files
committed
zephyr: Add Ctrl+C handling.
1 parent 1b76f88 commit 93c76d2

4 files changed

Lines changed: 4 additions & 1 deletion

File tree

zephyr/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SRC_C = main.c \
3737
lib/utils/stdout_helpers.c \
3838
lib/utils/printf.c \
3939
lib/utils/pyexec.c \
40+
lib/utils/interrupt_char.c \
4041
lib/mp-readline/readline.c \
4142
$(BUILD)/frozen.c \
4243
$(SRC_MOD)

zephyr/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "py/gc.h"
1010
#include "py/stackctrl.h"
1111
#include "lib/utils/pyexec.h"
12+
#include "lib/mp-readline/readline.h"
1213

1314
void do_str(const char *src, mp_parse_input_kind_t input_kind) {
1415
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) {
4445
gc_init(heap, heap + sizeof(heap));
4546
#endif
4647
mp_init();
48+
MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
4749
pyexec_frozen_module("main.py");
4850
#if MICROPY_REPL_EVENT_DRIVEN
4951
pyexec_event_repl_init();

zephyr/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef long mp_off_t;
4646
#define MP_STATE_PORT MP_STATE_VM
4747

4848
#define MICROPY_PORT_ROOT_POINTERS \
49+
mp_obj_t mp_kbd_exception; \
4950
const char *readline_hist[8];
5051

5152
// Include Zephyr's autoconf.h, which should be made first by Zephyr makefiles

zephyr/mphalport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
static inline mp_uint_t mp_hal_ticks_ms(void) { return 0; }
2-
static inline void mp_hal_set_interrupt_char(char c) {}

0 commit comments

Comments
 (0)