From 72abe51713a886d7607e0fd70120e5aa888a2348 Mon Sep 17 00:00:00 2001 From: Naveen Kaje Date: Mon, 1 Oct 2018 14:04:59 -0500 Subject: [PATCH 1/2] NRF52: setup the UART_RTS pin during startup to enable console RX While investigating the RX issue on NRF52_DK after SDK 14 updates, it is observed that the RX FIFO doesn't get filled up, when the flow control is disabled. Hence the readable never returns true. If using Serial interface, the stdio file handles (0, 1, 2) get opened. This results in configuring the flow control for STDIO, and it is observed that the RX FIFO gets filled. However, if RawSerial is used, the STDIO file handles don't get opened. During the debug process it was observed that if the flow control is configured once and then set to disabled, RX worked as expected. Alternative to this approach is that user application specifically enables flow control as done in mbed's Greentea test suite. See https://goo.gl/r8nBYH See https://goo.gl/8VB2qg step 14 for _initio's description. See test code to reproduce the issue and test fix here: https://goo.gl/AQU1xG Description The change in behavior with NRF52's UART RX is documented here. #6891 This change is a fix for the above issue. --- .../TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c index 53daa7e4ff..d9496a4226 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c @@ -39,6 +39,8 @@ #include "nrf.h" #include "cmsis_nvic.h" #include "stdint.h" +#include "PinNames.h" +#include "hal/gpio_api.h" #if defined(SOFTDEVICE_PRESENT) #include "nrf_sdm.h" @@ -110,3 +112,11 @@ void nrf_reloc_vector_table(void) SCB->VTOR = (uint32_t) nrf_dispatch_vector; #endif } + +void mbed_sdk_init(void) +{ + gpio_t rts; + gpio_init_out(&rts, STDIO_UART_RTS); + /* Set STDIO_UART_RTS as gpio driven low */ + gpio_write(&rts, 0); +} From fa480c4f155224a3af101a33208e9d06e7e6157b Mon Sep 17 00:00:00 2001 From: Naveen Kaje Date: Mon, 1 Oct 2018 14:04:59 -0500 Subject: [PATCH 2/2] NRF52: setup the UART_RTS pin during startup to enable console RX While investigating the RX issue on NRF52_DK after SDK 14 updates, it is observed that the RX FIFO doesn't get filled up, when the flow control is disabled. Hence the readable never returns true. If using Serial interface, the stdio file handles (0, 1, 2) get opened. This results in configuring the flow control for STDIO, and it is observed that the RX FIFO gets filled. However, if RawSerial is used, the STDIO file handles don't get opened. During the debug process it was observed that if the flow control is configured once and then set to disabled, RX worked as expected. Alternative to this approach is that user application specifically enables flow control as done in mbed's Greentea test suite. See https://goo.gl/r8nBYH See https://goo.gl/8VB2qg step 14 for _initio's description. See test code to reproduce the issue and test fix here: https://goo.gl/AQU1xG Description The change in behavior with NRF52's UART RX is documented here. #6891 This change is a fix for the above issue. --- .../TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c index d9496a4226..851fa5510a 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/reloc_vector_table.c @@ -113,6 +113,7 @@ void nrf_reloc_vector_table(void) #endif } +#if (STDIO_UART_RTS != NC) void mbed_sdk_init(void) { gpio_t rts; @@ -120,3 +121,4 @@ void mbed_sdk_init(void) /* Set STDIO_UART_RTS as gpio driven low */ gpio_write(&rts, 0); } +#endif