From d5624b6ec6e5b2cdbe6603c18128acb36ee44cfa Mon Sep 17 00:00:00 2001 From: "desmond.chen" Date: Tue, 4 Jun 2019 14:51:32 +0800 Subject: [PATCH] Fix nrf52 enabled uart count and enable uart0/1 --- .../TARGET_MCU_NRF52832/config/sdk_config.h | 4 ++-- .../TARGET_MCU_NRF52840/config/sdk_config.h | 8 ++++---- .../TARGET_NRF5x/TARGET_NRF52/serial_api.c | 15 ++++++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h index b4ff429d4c..d3fedc8023 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h @@ -4152,11 +4152,11 @@ // NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver //========================================================== #ifndef NRFX_UARTE_ENABLED -#define NRFX_UARTE_ENABLED 0 +#define NRFX_UARTE_ENABLED 1 #endif // NRFX_UARTE0_ENABLED - Enable UARTE0 instance #ifndef NRFX_UARTE0_ENABLED -#define NRFX_UARTE0_ENABLED 0 +#define NRFX_UARTE0_ENABLED 1 #endif // NRFX_UARTE1_ENABLED - Enable UARTE1 instance diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h index 57ec3c5ca0..4826baa2f5 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h @@ -4152,16 +4152,16 @@ // NRFX_UARTE_ENABLED - nrfx_uarte - UARTE peripheral driver //========================================================== #ifndef NRFX_UARTE_ENABLED -#define NRFX_UARTE_ENABLED 0 +#define NRFX_UARTE_ENABLED 1 #endif // NRFX_UARTE0_ENABLED - Enable UARTE0 instance #ifndef NRFX_UARTE0_ENABLED -#define NRFX_UARTE0_ENABLED 0 +#define NRFX_UARTE0_ENABLED 1 #endif // NRFX_UARTE1_ENABLED - Enable UARTE1 instance #ifndef NRFX_UARTE1_ENABLED -#define NRFX_UARTE1_ENABLED 0 +#define NRFX_UARTE1_ENABLED 1 #endif // NRFX_UARTE_DEFAULT_CONFIG_HWFC - Hardware Flow Control @@ -5615,7 +5615,7 @@ // UART1_ENABLED - Enable UART1 instance //========================================================== #ifndef UART1_ENABLED -#define UART1_ENABLED 0 +#define UART1_ENABLED 1 #endif // diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c index 089318ce01..3ca874f3c3 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c @@ -41,6 +41,7 @@ #include "hal/serial_api.h" #include "nrf_uarte.h" +#include "nrfx_uarte.h" #include "nrfx_uart.h" #include "nrf_atfifo.h" #include "app_util_platform.h" @@ -166,12 +167,12 @@ typedef enum { /** * UARTE state. One for each instance. */ -static nordic_uart_state_t nordic_nrf5_uart_state[NRFX_UART_ENABLED_COUNT] = { 0 }; +static nordic_uart_state_t nordic_nrf5_uart_state[NRFX_UARTE_ENABLED_COUNT] = { 0 }; /** * Array with UARTE register pointers for easy access. */ -static NRF_UARTE_Type *nordic_nrf5_uart_register[NRFX_UART_ENABLED_COUNT] = { +static NRF_UARTE_Type *nordic_nrf5_uart_register[NRFX_UARTE_ENABLED_COUNT] = { NRF_UARTE0, #if UART1_ENABLED NRF_UARTE1, @@ -193,6 +194,10 @@ NRF_ATFIFO_DEF(nordic_nrf5_uart_fifo_1, uint8_t, UART1_FIFO_BUFFER_SIZE); */ static uint8_t nordic_nrf5_uart_swi_mask_tx_0 = 0; static uint8_t nordic_nrf5_uart_swi_mask_rx_0 = 0; +#if UART1_ENABLED +static uint8_t nordic_nrf5_uart_swi_mask_tx_1 = 0; +static uint8_t nordic_nrf5_uart_swi_mask_rx_1 = 0; +#endif /** * Global variables expected by mbed_retarget.cpp for STDOUT. @@ -881,7 +886,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) nordic_nrf5_uart_state[1].owner = NULL; /* Allocate a PPI channel for flow control */ - ret = nrf_drv_ppi_channel_alloc(&nordic_nrf5_uart_state[1].ppi_rts); + ret = nrfx_ppi_channel_alloc(&nordic_nrf5_uart_state[1].ppi_rts); MBED_ASSERT(ret == NRF_SUCCESS); /* Clear RTS */ @@ -891,8 +896,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) nrf_uarte_int_disable(nordic_nrf5_uart_register[1], 0xFFFFFFFF); NVIC_SetVector(UARTE1_IRQn, (uint32_t) nordic_nrf5_uart1_handler); - NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number(UARTE1_IRQn), APP_IRQ_PRIORITY_HIGHEST); - NRFX_IRQ_ENABLE(nrfx_get_irq_number(UARTE1_IRQn)); + NRFX_IRQ_PRIORITY_SET(UARTE1_IRQn, APP_IRQ_PRIORITY_HIGHEST); + NRFX_IRQ_ENABLE(UARTE1_IRQn); #endif }