Skip to content

Commit f0aa0d1

Browse files
committed
modmachine: Expose keyboard interrupt as a python function.
1 parent 2992e34 commit f0aa0d1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

py/modmicropython.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ static mp_obj_t mp_micropython_schedule(mp_obj_t function, mp_obj_t arg) {
166166
static MP_DEFINE_CONST_FUN_OBJ_2(mp_micropython_schedule_obj, mp_micropython_schedule);
167167
#endif
168168

169+
#if MICROPY_KBD_EXCEPTION
170+
static mp_obj_t mp_micropython_keyboard_interrupt(void) {
171+
mp_sched_keyboard_interrupt();
172+
return mp_const_none;
173+
}
174+
static MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_keyboard_interrupt_obj, mp_micropython_keyboard_interrupt);
175+
#endif
176+
169177
static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
170178
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_micropython) },
171179
{ MP_ROM_QSTR(MP_QSTR_const), MP_ROM_PTR(&mp_identity_obj) },
@@ -206,6 +214,9 @@ static const mp_rom_map_elem_t mp_module_micropython_globals_table[] = {
206214
#if MICROPY_ENABLE_SCHEDULER
207215
{ MP_ROM_QSTR(MP_QSTR_schedule), MP_ROM_PTR(&mp_micropython_schedule_obj) },
208216
#endif
217+
#if MICROPY_KBD_EXCEPTION
218+
{MP_ROM_QSTR(MP_QSTR_keyboard_interrupt), MP_ROM_PTR(&mp_micropython_keyboard_interrupt_obj)},
219+
#endif
209220
};
210221

211222
static MP_DEFINE_CONST_DICT(mp_module_micropython_globals, mp_module_micropython_globals_table);

0 commit comments

Comments
 (0)