From 1f450fe42cef43d9f6c6d9513f5f80640719c06a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sat, 19 Mar 2016 22:19:21 +0100 Subject: [PATCH] nrf5x: add blocking retarget impl --- port/nrf5x/pca10028/armgcc/Makefile | 2 +- .../nrf5x/{retarget.c => retarget_blocking.c} | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) rename port/nrf5x/{retarget.c => retarget_blocking.c} (77%) diff --git a/port/nrf5x/pca10028/armgcc/Makefile b/port/nrf5x/pca10028/armgcc/Makefile index e65a797d9..64d8d81b6 100755 --- a/port/nrf5x/pca10028/armgcc/Makefile +++ b/port/nrf5x/pca10028/armgcc/Makefile @@ -71,7 +71,7 @@ INC_PATHS += -I$(abspath ../../../../../components/toolchain/gcc) # BTstack territory BTSTACK_ROOT = ../../../../../components/btstack C_SOURCE_FILES += $(abspath $(BTSTACK_ROOT)/port/nrf5x/main.c) -C_SOURCE_FILES += $(abspath $(BTSTACK_ROOT)/port/retarget.c) +C_SOURCE_FILES += $(abspath $(BTSTACK_ROOT)/port/retarget_blocking.c) C_SOURCE_FILES += $(abspath $(BTSTACK_ROOT)/platform/embedded/btstack_run_loop_embedded.c) C_SOURCE_FILES += $(abspath $(BTSTACK_ROOT)/src/ble/ad_parser.c) C_SOURCE_FILES += $(abspath $(BTSTACK_ROOT)/src/btstack_linked_list.c) diff --git a/port/nrf5x/retarget.c b/port/nrf5x/retarget_blocking.c similarity index 77% rename from port/nrf5x/retarget.c rename to port/nrf5x/retarget_blocking.c index 91462b94a..c77def4d5 100755 --- a/port/nrf5x/retarget.c +++ b/port/nrf5x/retarget_blocking.c @@ -10,6 +10,8 @@ * */ +// BTstack patch: block on full outgoing buffer + #if !defined(NRF_LOG_USES_RTT) || NRF_LOG_USES_RTT != 1 #include @@ -45,7 +47,11 @@ int fputc(int ch, FILE * p_file) { UNUSED_PARAMETER(p_file); - UNUSED_VARIABLE(app_uart_put((uint8_t)ch)); + int res; + do { + res = app_uart_put((uint8_t)ch); + } while (res); + return ch; } @@ -60,7 +66,11 @@ int _write(int file, const char * p_char, int len) for (i = 0; i < len; i++) { - UNUSED_VARIABLE(app_uart_put(*p_char++)); + int res; + do { + res = app_uart_put((uint8_t)*p_char); + } while (res); + p_char++; } return len; @@ -89,7 +99,11 @@ __ATTRIBUTES size_t __write(int file, const unsigned char * p_char, size_t len) for (i = 0; i < len; i++) { - UNUSED_VARIABLE(app_uart_put(*p_char++)); + int res; + do { + res = app_uart_put((uint8_t)*p_char); + } while (res); + p_char++; } return len;