From 7beb8d3f4b9705eb748b4163d793747f182d7949 Mon Sep 17 00:00:00 2001 From: Naveen Kaje Date: Thu, 18 Oct 2018 15:58:05 -0500 Subject: [PATCH] NRF52 : Fix UART RTS initialization The preprocessor based macro check #if evaluates all enums as 0 and hence the code does not get compiled. Since move this to a runtime check where the pin variable can be correctly evaluated. Delete mbed_overrides.c as it has a target specific mbed_sdk_init() to resolve linking problem. This is a follow on patch to: https://github.com/ARMmbed/mbed-os/pull/8046 --- .../TARGET_DELTA_DFBM_NQ620/PinNames.h | 2 ++ .../TARGET_DELTA_DFBM_NQ620/mbed_overrides.c | 22 ------------------- .../TARGET_MTB_UBLOX_NINA_B1/PinNames.h | 2 ++ .../TARGET_RBLAB_BLENANO2/PinNames.h | 2 ++ .../TARGET_UBLOX_EVA_NINA/PinNames.h | 2 ++ .../TARGET_NRF52/reloc_vector_table.c | 13 ++++++----- 6 files changed, 15 insertions(+), 28 deletions(-) delete mode 100644 targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/mbed_overrides.c diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/PinNames.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/PinNames.h index 18d89777bf..807e2d532f 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/PinNames.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/PinNames.h @@ -141,6 +141,8 @@ typedef enum { USBRX = RX_PIN_NUMBER, STDIO_UART_TX = TX_PIN_NUMBER, STDIO_UART_RX = RX_PIN_NUMBER, + STDIO_UART_CTS = CTS_PIN_NUMBER, + STDIO_UART_RTS = RTS_PIN_NUMBER, SPI_PSELMOSI0 = p23, SPI_PSELMISO0 = p24, diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/mbed_overrides.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/mbed_overrides.c deleted file mode 100644 index fd32a74329..0000000000 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_DELTA_DFBM_NQ620/mbed_overrides.c +++ /dev/null @@ -1,22 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2016 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -void mbed_sdk_init() -{ - char* debug_date = __DATE__; - char* debug_time = __TIME__; - -} diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_MTB_UBLOX_NINA_B1/PinNames.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_MTB_UBLOX_NINA_B1/PinNames.h index 87b07172c7..eeaba6ee7c 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_MTB_UBLOX_NINA_B1/PinNames.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_MTB_UBLOX_NINA_B1/PinNames.h @@ -121,6 +121,8 @@ typedef enum { RTS_PIN_NUMBER = p31, STDIO_UART_TX = TX_PIN_NUMBER, STDIO_UART_RX = RX_PIN_NUMBER, + STDIO_UART_CTS = CTS_PIN_NUMBER, + STDIO_UART_RTS = RTS_PIN_NUMBER, I2C_SDA = p2, I2C_SCL = p3, diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_RBLAB_BLENANO2/PinNames.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_RBLAB_BLENANO2/PinNames.h index dd61f6f206..16bdafaabc 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_RBLAB_BLENANO2/PinNames.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_RBLAB_BLENANO2/PinNames.h @@ -132,6 +132,8 @@ typedef enum { RTS_PIN_NUMBER = p2, STDIO_UART_TX = TX_PIN_NUMBER, STDIO_UART_RX = RX_PIN_NUMBER, + STDIO_UART_CTS = CTS_PIN_NUMBER, + STDIO_UART_RTS = RTS_PIN_NUMBER, // mBed interface Pins USBTX = TX_PIN_NUMBER, diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_UBLOX_EVA_NINA/PinNames.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_UBLOX_EVA_NINA/PinNames.h index cfb9917ac4..26cf4384c7 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_UBLOX_EVA_NINA/PinNames.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/TARGET_UBLOX_EVA_NINA/PinNames.h @@ -86,6 +86,8 @@ typedef enum { RTS_PIN_NUMBER = p31, STDIO_UART_TX = TX_PIN_NUMBER, STDIO_UART_RX = RX_PIN_NUMBER, + STDIO_UART_CTS = CTS_PIN_NUMBER, + STDIO_UART_RTS = RTS_PIN_NUMBER, I2C_SDA0 = p2, I2C_SCL0 = p3, 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 851fa5510a..23f87ea7dd 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,12 +113,13 @@ void nrf_reloc_vector_table(void) #endif } -#if (STDIO_UART_RTS != NC) + 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); + if (STDIO_UART_RTS != NC) { + gpio_t rts; + gpio_init_out(&rts, STDIO_UART_RTS); + /* Set STDIO_UART_RTS as gpio driven low */ + gpio_write(&rts, 0); + } } -#endif