diff options
| author | hathach <thach@tinyusb.org> | 2018-01-16 00:03:22 +0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-01-18 11:32:47 -0800 |
| commit | 5e6f113779a638590cf34c57936f4512c365fa0a (patch) | |
| tree | 24a7f430f84898fe6de9b214bfe64e4b3ff65703 | |
| parent | fda065ea89c383cbf16df3b8101d897d485ba6b2 (diff) | |
add REPL via bleuart
| -rw-r--r-- | ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld | 2 | ||||
| -rw-r--r-- | ports/nrf/drivers/bluetooth/ble_uart.c | 4 | ||||
| -rw-r--r-- | ports/nrf/supervisor/serial.c | 18 |
3 files changed, 16 insertions, 8 deletions
diff --git a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld index 183822f92..a1c128e37 100644 --- a/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld +++ b/ports/nrf/boards/feather52/custom_nrf52832_dfu_app_2.0.1.ld @@ -25,7 +25,7 @@ MEMORY FLASH_ISR (rx) : ORIGIN = 0x0001c000, LENGTH = 0x001000 /* sector 0, 4 KiB */ FLASH_TEXT (rx) : ORIGIN = 0x0001d000, LENGTH = 0x03C000 /* APP - ISR, 240 KiB */ FLASH_FATFS (r) : ORIGIN = 0x00059000, LENGTH = 0x019000 /* File system 100KB KB */ - RAM (xrw) : ORIGIN = 0x200039c0, LENGTH = 0x0c640 /* 49.5 KiB, give 8KiB headroom for softdevice */ + RAM (xrw) : ORIGIN = 0x20003000, LENGTH = 0x0D000 /* 52 KiB, give 8KiB headroom for softdevice */ } /* produce a link error if there is not this amount of RAM for these sections */ diff --git a/ports/nrf/drivers/bluetooth/ble_uart.c b/ports/nrf/drivers/bluetooth/ble_uart.c index cc829750c..c66e7afd4 100644 --- a/ports/nrf/drivers/bluetooth/ble_uart.c +++ b/ports/nrf/drivers/bluetooth/ble_uart.c @@ -105,6 +105,10 @@ int mp_hal_stdin_rx_chr(void) { return (int)byte; } +bool mp_hal_stdin_any(void) { + return !isBufferEmpty(mp_rx_ring_buffer); +} + void mp_hal_stdout_tx_strn(const char *str, size_t len) { uint8_t *buf = (uint8_t *)str; size_t send_len; diff --git a/ports/nrf/supervisor/serial.c b/ports/nrf/supervisor/serial.c index 465c8394c..51e61bce7 100644 --- a/ports/nrf/supervisor/serial.c +++ b/ports/nrf/supervisor/serial.c @@ -32,15 +32,18 @@ #include "pins.h" #include "hal_uart.h" +#if (MICROPY_PY_BLE_NUS) +#include "ble_uart.h" +#endif + void serial_init(void) { -// uart_init0(); -// -// mp_obj_t args[2] = { -// MP_OBJ_NEW_SMALL_INT(0), -// MP_OBJ_NEW_SMALL_INT(115200), -// }; -// MP_STATE_PORT(pyb_stdio_uart) = machine_hard_uart_type.make_new((mp_obj_t)&machine_hard_uart_type, MP_ARRAY_SIZE(args), 0, args); +#if MICROPY_PY_BLE_NUS + ble_uart_init0(); + while (!ble_uart_enabled()) { + ; + } +#else hal_uart_init_t param = { .id = 0, @@ -56,6 +59,7 @@ void serial_init(void) { }; hal_uart_init( UART_BASE(0), ¶m); +#endif } |
