added Ctrl+C interrupt

This commit is contained in:
hathach 2017-12-29 22:43:31 +07:00
parent a021a9e5f0
commit 7f79a0e78c
3 changed files with 122 additions and 110 deletions

View File

@ -151,6 +151,7 @@ SRC_C += \
lib/timeutils/timeutils.c \ lib/timeutils/timeutils.c \
lib/utils/buffer_helper.c \ lib/utils/buffer_helper.c \
lib/utils/context_manager_helpers.c \ lib/utils/context_manager_helpers.c \
lib/utils/interrupt_char.c \
lib/utils/pyexec.c \ lib/utils/pyexec.c \
lib/libc/string0.c \ lib/libc/string0.c \
lib/mp-readline/readline.c \ lib/mp-readline/readline.c \

View File

@ -32,6 +32,8 @@
#include "hal_uart.h" #include "hal_uart.h"
#include "fifo.h" #include "fifo.h"
#include "lib/utils/interrupt_char.h"
#ifdef HAL_UART_MODULE_ENABLED #ifdef HAL_UART_MODULE_ENABLED
FIFO_DEF(_ff_uart, 128, uint8_t, true, UARTE0_UART0_IRQn); FIFO_DEF(_ff_uart, 128, uint8_t, true, UARTE0_UART0_IRQn);
@ -162,7 +164,15 @@ void UARTE0_UART0_IRQHandler(void)
if (p_instance->EVENTS_RXDRDY) if (p_instance->EVENTS_RXDRDY)
{ {
uint8_t ch = (uint8_t) p_instance->RXD; uint8_t ch = (uint8_t) p_instance->RXD;
// Keyboard interrupt
if (mp_interrupt_char != -1 && ch == mp_interrupt_char)
{
mp_keyboard_interrupt();
}else
{
fifo_write(_ff_uart, &ch); fifo_write(_ff_uart, &ch);
}
p_instance->EVENTS_RXDRDY = 0x0UL; p_instance->EVENTS_RXDRDY = 0x0UL;
} }

View File

@ -65,8 +65,7 @@
#define MICROPY_FATFS_NUM_PERSISTENT (1) #define MICROPY_FATFS_NUM_PERSISTENT (1)
//#define MICROPY_FATFS_MAX_SS (4096) //#define MICROPY_FATFS_MAX_SS (4096)
#define FILESYSTEM_BLOCK_SIZE (512)
#define FILESYSTEM_BLOCK_SIZE 512
#define MICROPY_VFS (1) #define MICROPY_VFS (1)
#define MICROPY_VFS_FAT (MICROPY_VFS) #define MICROPY_VFS_FAT (MICROPY_VFS)
@ -98,6 +97,7 @@
#define MICROPY_PY_BUILTINS_HELP (1) #define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_TEXT nrf5_help_text #define MICROPY_PY_BUILTINS_HELP_TEXT nrf5_help_text
#define MICROPY_PY_BUILTINS_HELP_MODULES (1) #define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_PY_BUILTINS_INPUT (1)
#define MICROPY_MODULE_BUILTIN_INIT (1) #define MICROPY_MODULE_BUILTIN_INIT (1)
#define MICROPY_PY_ALL_SPECIAL_METHODS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (0)
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
@ -130,6 +130,8 @@
#define MICROPY_PY_MACHINE_SPI_MIN_DELAY (0) #define MICROPY_PY_MACHINE_SPI_MIN_DELAY (0)
#define MICROPY_PY_FRAMEBUF (0) #define MICROPY_PY_FRAMEBUF (0)
#define MICROPY_KBD_EXCEPTION (1)
#ifndef MICROPY_HW_LED_COUNT #ifndef MICROPY_HW_LED_COUNT
#define MICROPY_HW_LED_COUNT (0) #define MICROPY_HW_LED_COUNT (0)
#endif #endif
@ -264,25 +266,24 @@ extern const struct _mp_obj_module_t ble_module;
{ MP_OBJ_NEW_QSTR (MP_QSTR_microcontroller ), (mp_obj_t)&microcontroller_module }, \ { MP_OBJ_NEW_QSTR (MP_QSTR_microcontroller ), (mp_obj_t)&microcontroller_module }, \
{ MP_OBJ_NEW_QSTR (MP_QSTR_os ), (mp_obj_t)&os_module }, \ { MP_OBJ_NEW_QSTR (MP_QSTR_os ), (mp_obj_t)&os_module }, \
{ MP_OBJ_NEW_QSTR (MP_QSTR_random ), (mp_obj_t)&random_module }, \ { MP_OBJ_NEW_QSTR (MP_QSTR_random ), (mp_obj_t)&random_module }, \
/*{ MP_OBJ_NEW_QSTR(MP_QSTR_storage), (mp_obj_t)&storage_module },*/\ { MP_OBJ_NEW_QSTR (MP_QSTR_storage ), (mp_obj_t)&storage_module },\
{ MP_ROM_QSTR(MP_QSTR_pyb), MP_ROM_PTR(&pyb_module) }, \
{ MP_ROM_QSTR(MP_QSTR_machine), MP_ROM_PTR(&machine_module) }, \
{ MP_ROM_QSTR(MP_QSTR_utime), MP_ROM_PTR(&mp_module_utime) }, \
{ MP_OBJ_NEW_QSTR (MP_QSTR_supervisor ), (mp_obj_t)&supervisor_module }, \ { MP_OBJ_NEW_QSTR (MP_QSTR_supervisor ), (mp_obj_t)&supervisor_module }, \
{ MP_OBJ_NEW_QSTR (MP_QSTR_time ), (mp_obj_t)&time_module }, \ { MP_OBJ_NEW_QSTR (MP_QSTR_time ), (mp_obj_t)&time_module }, \
{ MP_ROM_QSTR (MP_QSTR_pyb ), MP_ROM_PTR(&pyb_module) }, \
{ MP_ROM_QSTR (MP_QSTR_utime ), MP_ROM_PTR(&mp_module_utime) }, \
MUSIC_MODULE \ MUSIC_MODULE \
RANDOM_MODULE \ RANDOM_MODULE \
/*BLE_MODULE \ /*BLE_MODULE \
UBLUEPY_MODULE \*/ UBLUEPY_MODULE \*/
#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
{ MP_ROM_QSTR (MP_QSTR_time ), MP_ROM_PTR(&mp_module_utime) }, \ { MP_ROM_QSTR (MP_QSTR_time ), MP_ROM_PTR(&mp_module_utime) }, \
// extra built in names to add to the global namespace // extra built in names to add to the global namespace
#define MICROPY_PORT_BUILTINS \ #define MICROPY_PORT_BUILTINS \
{ MP_ROM_QSTR (MP_QSTR_help), MP_ROM_PTR(&mp_builtin_help_obj) }, \ { MP_ROM_QSTR (MP_QSTR_help), MP_ROM_PTR(&mp_builtin_help_obj) }, \
{ MP_OBJ_NEW_QSTR (MP_QSTR_input), (mp_obj_t)&mp_builtin_input_obj }, \
{ MP_ROM_QSTR (MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, \ { MP_ROM_QSTR (MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, \
// extra constants // extra constants