nrf: Add support to activate MICROPY_PY_SYS_STDFILES.

Fixes issue #5162.
This commit is contained in:
Damien George 2019-10-08 16:38:04 +11:00
parent 04fe62d06f
commit 2863dcdf4f
2 changed files with 12 additions and 1 deletions

View File

@ -156,6 +156,7 @@ SRC_LIB += $(addprefix lib/,\
libc/string0.c \
mp-readline/readline.c \
utils/pyexec.c \
utils/sys_stdio_mphal.c \
utils/interrupt_char.c \
timeutils/timeutils.c \
)
@ -342,7 +343,7 @@ $(BUILD)/$(OUTPUT_FILENAME).elf: $(OBJ)
$(Q)$(SIZE) $@
# List of sources for qstr extraction
SRC_QSTR += $(SRC_C) $(DRIVERS_SRC_C) $(SRC_BOARD_MODULES)
SRC_QSTR += $(SRC_C) $(SRC_LIB) $(DRIVERS_SRC_C) $(SRC_BOARD_MODULES)
# Append any auto-generated sources that are needed by sources listed in
# SRC_QSTR

View File

@ -30,6 +30,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "py/runtime.h"
#include "py/stream.h"
#include "uart.h"
#include "nrfx_errors.h"
#include "nrfx_config.h"
@ -53,6 +54,15 @@ void mp_hal_set_interrupt_char(int c) {
#endif
#if !MICROPY_PY_BLE_NUS
uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) {
uintptr_t ret = 0;
if ((poll_flags & MP_STREAM_POLL_RD) && MP_STATE_PORT(board_stdio_uart) != NULL
&& uart_rx_any(MP_STATE_PORT(board_stdio_uart))) {
ret |= MP_STREAM_POLL_RD;
}
return ret;
}
int mp_hal_stdin_rx_chr(void) {
for (;;) {
if (MP_STATE_PORT(board_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(board_stdio_uart))) {