From 70abd66a1225a89312a8e6775c09d18873ff0579 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Wed, 27 Sep 2023 14:18:05 +0200 Subject: [PATCH] platform: nordic_nrf: Set UART pins using pinctrl method Use the pinctrl method to define the UART pins for the nordic platform UART driver. This makes it easier to assign the UART pins from devicetree information which is used in out-of-tree board support. Change-Id: I8f18b730d705214670438b85c58032c6f32fff1c Signed-off-by: Joakim Andersson --- .../bl5340_dvk_cpuapp/RTE_Device.h | 77 +++--------- .../common/core/cmsis_drivers/Driver_USART.c | 72 +++++++++--- .../common/core/common/nrf-pinctrl.h | 111 ++++++++++++++++++ .../nrf5340dk_nrf5340_cpuapp/RTE_Device.h | 86 +++----------- .../nordic_nrf/nrf9160dk_nrf9160/RTE_Device.h | 85 +++----------- .../nordic_nrf/nrf9161dk_nrf9161/RTE_Device.h | 82 ++++--------- 6 files changed, 240 insertions(+), 273 deletions(-) create mode 100644 platform/ext/target/nordic_nrf/common/core/common/nrf-pinctrl.h diff --git a/platform/ext/target/lairdconnectivity/bl5340_dvk_cpuapp/RTE_Device.h b/platform/ext/target/lairdconnectivity/bl5340_dvk_cpuapp/RTE_Device.h index 1b2b8b904..329572bf0 100644 --- a/platform/ext/target/lairdconnectivity/bl5340_dvk_cpuapp/RTE_Device.h +++ b/platform/ext/target/lairdconnectivity/bl5340_dvk_cpuapp/RTE_Device.h @@ -16,70 +16,31 @@ * limitations under the License. */ -//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- - #ifndef __RTE_DEVICE_H #define __RTE_DEVICE_H -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] -// Configuration settings for Driver_USART0 in component ::Drivers:USART -#define RTE_USART0 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART0_TXD_PIN 20 -// RXD -#define RTE_USART0_RXD_PIN 22 -// RTS -#define RTE_USART0_RTS_PIN 19 -// CTS -#define RTE_USART0_CTS_PIN 21 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] +#include -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] -// Configuration settings for Driver_USART1 in component ::Drivers:USART -#define RTE_USART1 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART1_TXD_PIN 40 -// RXD -#define RTE_USART1_RXD_PIN 42 -// RTS -#define RTE_USART1_RTS_PIN 39 -// CTS -#define RTE_USART1_CTS_PIN 41 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] +#define RTE_USART0 1 -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] -// Configuration settings for Driver_USART2 in component ::Drivers:USART -#define RTE_USART2 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART2_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART2_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART2_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART2_CTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] +#define RTE_USART0_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 20), \ + NRF_PSEL(UART_RX, 0, 22), \ + NRF_PSEL(UART_RTS, 0, 19), \ + NRF_PSEL(UART_CTS, 0, 21), \ +} -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] -// Configuration settings for Driver_USART3 in component ::Drivers:USART -#define RTE_USART3 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART3_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART3_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] + +#define RTE_USART1 1 + +#define RTE_USART1_PINS \ +{ \ + NRF_PSEL(UART_TX, 1, 8), \ + NRF_PSEL(UART_RX, 1, 10), \ + NRF_PSEL(UART_RTS, 1, 7), \ + NRF_PSEL(UART_CTS, 1, 9), \ +} // TWIM (Two-wire interface master) [Driver_TWIM2] // Configuration settings for Driver_TWIM2 in component ::Drivers:TWIM diff --git a/platform/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_USART.c b/platform/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_USART.c index 4fdd02ae2..172d490ab 100644 --- a/platform/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_USART.c +++ b/platform/ext/target/nordic_nrf/common/core/cmsis_drivers/Driver_USART.c @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #ifndef ARG_UNUSED #define ARG_UNUSED(arg) (void)arg @@ -30,6 +33,43 @@ #if RTE_USART0 || RTE_USART1 || RTE_USART2 || RTE_USART3 +#define PSEL_DISCONNECTED 0xFFFFFFFFUL + +#define UART_CONFIG_INITIALIZER() \ +{ \ + .txd_pin = PSEL_DISCONNECTED, \ + .rxd_pin = PSEL_DISCONNECTED, \ + .rts_pin = PSEL_DISCONNECTED, \ + .cts_pin = PSEL_DISCONNECTED, \ + .baudrate = NRF_UARTE_BAUDRATE_115200, \ + .interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \ + .config = { \ + .hwfc = NRF_UARTE_HWFC_DISABLED, \ + .parity = NRF_UARTE_PARITY_EXCLUDED, \ + .stop = NRF_UARTE_STOP_ONE, \ + }, \ +} + +void uart_config_set_uart_pins(nrfx_uarte_config_t *uart_config, + const uint32_t uart_pins[], + size_t uart_pins_count) +{ + for (size_t i = 0; i < uart_pins_count; i++) { + uint32_t psel = NRF_GET_PIN(uart_pins[i]); + + if (psel == NRF_PIN_DISCONNECTED) { + psel = PSEL_DISCONNECTED; + } + + switch (NRF_GET_FUN(uart_pins[i])) { + case NRF_FUN_UART_TX: uart_config->txd_pin = psel; break; + case NRF_FUN_UART_RX: uart_config->rxd_pin = psel; break; + case NRF_FUN_UART_RTS: uart_config->rts_pin = psel; break; + case NRF_FUN_UART_CTS: uart_config->cts_pin = psel; break; + } + } +} + static const ARM_DRIVER_VERSION DriverVersion = { ARM_USART_API_VERSION, ARM_USART_DRV_VERSION @@ -41,7 +81,8 @@ static const ARM_USART_CAPABILITIES DriverCapabilities = { typedef struct { const nrfx_uarte_t uarte; - const nrfx_uarte_config_t *initial_config; + const uint32_t *uart_pins; + size_t uart_pins_count; size_t tx_count; size_t rx_count; nrf_uarte_config_t hal_cfg; @@ -64,8 +105,14 @@ static int32_t ARM_USARTx_Initialize(ARM_USART_SignalEvent_t cb_event, { ARG_UNUSED(cb_event); + nrfx_uarte_config_t uart_config = UART_CONFIG_INITIALIZER(); + + uart_config_set_uart_pins(&uart_config, + uart_resources->uart_pins, + uart_resources->uart_pins_count); + nrfx_err_t err_code = nrfx_uarte_init(&uart_resources->uarte, - uart_resources->initial_config, + &uart_config, NULL); if (err_code != NRFX_SUCCESS) { return ARM_DRIVER_ERROR_BUSY; @@ -73,8 +120,8 @@ static int32_t ARM_USARTx_Initialize(ARM_USART_SignalEvent_t cb_event, uart_resources->tx_count = 0; uart_resources->rx_count = 0; - uart_resources->hal_cfg = uart_resources->initial_config->config; - uart_resources->baudrate = uart_resources->initial_config->baudrate; + uart_resources->hal_cfg = uart_config.config; + uart_resources->baudrate = uart_config.baudrate; uart_resources->initialized = true; return ARM_DRIVER_OK; @@ -299,22 +346,11 @@ static ARM_USART_MODEM_STATUS ARM_USART_GetModemStatus(void) } #define DRIVER_USART(idx) \ - static nrfx_uarte_config_t UART##idx##_initial_config = { \ - .txd_pin = RTE_USART##idx##_TXD_PIN, \ - .rxd_pin = RTE_USART##idx##_RXD_PIN, \ - .rts_pin = RTE_USART##idx##_RTS_PIN, \ - .cts_pin = RTE_USART##idx##_CTS_PIN, \ - .baudrate = NRF_UARTE_BAUDRATE_115200, \ - .interrupt_priority = NRFX_UARTE_DEFAULT_CONFIG_IRQ_PRIORITY, \ - .config = { \ - .hwfc = RTE_USART##idx##_HWFC, \ - .parity = NRF_UARTE_PARITY_EXCLUDED, \ - .stop = NRF_UARTE_STOP_ONE, \ - }, \ - }; \ + static const uint32_t UART##idx##_pins[] = RTE_USART##idx##_PINS; \ static UARTx_Resources UART##idx##_Resources = { \ .uarte = NRFX_UARTE_INSTANCE(idx), \ - .initial_config = &UART##idx##_initial_config, \ + .uart_pins = UART##idx##_pins, \ + .uart_pins_count = ARRAY_SIZE(UART##idx##_pins) \ }; \ static int32_t ARM_USART##idx##_Initialize( \ ARM_USART_SignalEvent_t cb_event) \ diff --git a/platform/ext/target/nordic_nrf/common/core/common/nrf-pinctrl.h b/platform/ext/target/nordic_nrf/common/core/common/nrf-pinctrl.h new file mode 100644 index 000000000..5d2b1da19 --- /dev/null +++ b/platform/ext/target/nordic_nrf/common/core/common/nrf-pinctrl.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef NRF_INCLUDE_NRF_PINCTRL_H +#define NRF_INCLUDE_NRF_PINCTRL_H + +/* + * The whole nRF pin configuration information is encoded in a 32-bit bitfield + * organized as follows: + * + * - 31..16: Pin function. + * - 15: Reserved. + * - 14: Pin inversion mode. + * - 13: Pin low power mode. + * - 12..9: Pin output drive configuration. + * - 8..7: Pin pull configuration. + * - 6..0: Pin number (combination of port and pin). + */ + +/** + * @name nRF pin configuration bit field positions and masks. + * @{ + */ + +/** Position of the function field. */ +#define NRF_FUN_POS 16U +/** Mask for the function field. */ +#define NRF_FUN_MSK 0xFFFFU +/** Position of the invert field. */ +#define NRF_INVERT_POS 14U +/** Mask for the invert field. */ +#define NRF_INVERT_MSK 0x1U +/** Position of the low power field. */ +#define NRF_LP_POS 13U +/** Mask for the low power field. */ +#define NRF_LP_MSK 0x1U +/** Position of the drive configuration field. */ +#define NRF_DRIVE_POS 9U +/** Mask for the drive configuration field. */ +#define NRF_DRIVE_MSK 0xFU +/** Position of the pull configuration field. */ +#define NRF_PULL_POS 7U +/** Mask for the pull configuration field. */ +#define NRF_PULL_MSK 0x3U +/** Position of the pin field. */ +#define NRF_PIN_POS 0U +/** Mask for the pin field. */ +#define NRF_PIN_MSK 0x7FU + +/** @} */ + +/** + * @name nRF pinctrl pin functions. + * @{ + */ + +/** UART TX */ +#define NRF_FUN_UART_TX 0U +/** UART RX */ +#define NRF_FUN_UART_RX 1U +/** UART RTS */ +#define NRF_FUN_UART_RTS 2U +/** UART CTS */ +#define NRF_FUN_UART_CTS 3U + +/** Indicates that a pin is disconnected */ +#define NRF_PIN_DISCONNECTED NRF_PIN_MSK + +/** @} */ + +/** + * @brief Utility macro to build nRF psels property entry. + * + * @param fun Pin function configuration (see NRF_FUNC_{name} macros). + * @param port Port (0 or 1). + * @param pin Pin (0..31). + */ +#define NRF_PSEL(fun, port, pin) \ + ((((((port) * 32U) + (pin)) & NRF_PIN_MSK) << NRF_PIN_POS) | \ + ((NRF_FUN_ ## fun & NRF_FUN_MSK) << NRF_FUN_POS)) + +/** + * @brief Utility macro to build nRF psels property entry when a pin is disconnected. + * + * This can be useful in situations where code running before Zephyr, e.g. a bootloader + * configures pins that later needs to be disconnected. + * + * @param fun Pin function configuration (see NRF_FUN_{name} macros). + */ +#define NRF_PSEL_DISCONNECTED(fun) \ + (NRF_PIN_DISCONNECTED | \ + ((NRF_FUN_ ## fun & NRF_FUN_MSK) << NRF_FUN_POS)) + +/** + * @brief Utility macro to obtain pin function. + * + * @param pincfg Pin configuration bit field. + */ +#define NRF_GET_FUN(pincfg) (((pincfg) >> NRF_FUN_POS) & NRF_FUN_MSK) + + +/** + * @brief Utility macro to obtain port and pin combination. + * + * @param pincfg Pin configuration bit field. + */ +#define NRF_GET_PIN(pincfg) (((pincfg) >> NRF_PIN_POS) & NRF_PIN_MSK) + +#endif /* NRF_INCLUDE_NRF_PINCTRL_H */ diff --git a/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/RTE_Device.h b/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/RTE_Device.h index f8e9313d4..c38273699 100644 --- a/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/RTE_Device.h +++ b/platform/ext/target/nordic_nrf/nrf5340dk_nrf5340_cpuapp/RTE_Device.h @@ -15,82 +15,32 @@ * limitations under the License. */ -//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- - #ifndef __RTE_DEVICE_H #define __RTE_DEVICE_H -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] -// Configuration settings for Driver_USART0 in component ::Drivers:USART -#define RTE_USART0 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART0_TXD_PIN 20 -// RXD -#define RTE_USART0_RXD_PIN 22 -// RTS -#define RTE_USART0_RTS_PIN 19 -// CTS -#define RTE_USART0_CTS_PIN 21 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] - -#define RTE_USART0_HWFC NRF_UARTE_HWFC_DISABLED - -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] -// Configuration settings for Driver_USART1 in component ::Drivers:USART -#define RTE_USART1 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART1_TXD_PIN 25 -// RXD -#define RTE_USART1_RXD_PIN 26 -// RTS -#define RTE_USART1_RTS_PIN 5 -// CTS -#define RTE_USART1_CTS_PIN 6 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] +#include -#define RTE_USART1_HWFC NRF_UARTE_HWFC_DISABLED +#define RTE_USART0 1 -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] -// Configuration settings for Driver_USART2 in component ::Drivers:USART -#define RTE_USART2 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART2_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART2_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART2_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART2_CTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] +#define RTE_USART0_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 20), \ + NRF_PSEL(UART_RX, 0, 22), \ + NRF_PSEL(UART_RTS, 0, 19), \ + NRF_PSEL(UART_CTS, 0, 21), \ +} -#define RTE_USART2_HWFC NRF_UARTE_HWFC_DISABLED -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] -// Configuration settings for Driver_USART3 in component ::Drivers:USART -#define RTE_USART3 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART3_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART3_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] +#define RTE_USART1 1 -#define RTE_USART3_HWFC NRF_UARTE_HWFC_DISABLED +#define RTE_USART1_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 25), \ + NRF_PSEL(UART_RX, 0, 26), \ + NRF_PSEL(UART_RTS, 0, 5), \ + NRF_PSEL(UART_CTS, 0, 6), \ +} -// FLASH (Flash Memory) [Driver_FLASH0] -// Configuration settings for Driver_FLASH0 in component ::Drivers:FLASH -#define RTE_FLASH0 1 -// FLASH (Flash Memory) [Driver_FLASH0] +#define RTE_FLASH0 1 #endif /* __RTE_DEVICE_H */ diff --git a/platform/ext/target/nordic_nrf/nrf9160dk_nrf9160/RTE_Device.h b/platform/ext/target/nordic_nrf/nrf9160dk_nrf9160/RTE_Device.h index eef8e3305..fe3beef77 100644 --- a/platform/ext/target/nordic_nrf/nrf9160dk_nrf9160/RTE_Device.h +++ b/platform/ext/target/nordic_nrf/nrf9160dk_nrf9160/RTE_Device.h @@ -15,81 +15,32 @@ * limitations under the License. */ -//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- - #ifndef __RTE_DEVICE_H #define __RTE_DEVICE_H -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] -// Configuration settings for Driver_USART0 in component ::Drivers:USART -#define RTE_USART0 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART0_TXD_PIN 29 -// RXD -#define RTE_USART0_RXD_PIN 28 -// RTS -#define RTE_USART0_RTS_PIN 27 -// CTS -#define RTE_USART0_CTS_PIN 26 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] - -#define RTE_USART0_HWFC NRF_UARTE_HWFC_DISABLED +#include -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] -// Configuration settings for Driver_USART1 in component ::Drivers:USART -#define RTE_USART1 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART1_TXD_PIN 1 -// RXD -#define RTE_USART1_RXD_PIN 0 -// RTS -#define RTE_USART1_RTS_PIN 14 -// CTS -#define RTE_USART1_CTS_PIN 15 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] +#define RTE_USART0 1 -#define RTE_USART1_HWFC NRF_UARTE_HWFC_DISABLED +#define RTE_USART0_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 29), \ + NRF_PSEL(UART_RX, 0, 28), \ + NRF_PSEL(UART_RTS, 0, 27), \ + NRF_PSEL(UART_CTS, 0, 26), \ +} -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] -// Configuration settings for Driver_USART2 in component ::Drivers:USART -#define RTE_USART2 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART2_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART2_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART2_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART2_CTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] -#define RTE_USART2_HWFC NRF_UARTE_HWFC_DISABLED +#define RTE_USART1 1 -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] -// Configuration settings for Driver_USART3 in component ::Drivers:USART -#define RTE_USART3 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART3_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART3_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] +#define RTE_USART1_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 1), \ + NRF_PSEL(UART_RX, 0, 0), \ + NRF_PSEL(UART_RTS, 0, 14), \ + NRF_PSEL(UART_CTS, 0, 15), \ +} -#define RTE_USART3_HWFC NRF_UARTE_HWFC_DISABLED -// FLASH (Flash Memory) [Driver_FLASH0] -// Configuration settings for Driver_FLASH0 in component ::Drivers:FLASH -#define RTE_FLASH0 1 -// FLASH (Flash Memory) [Driver_FLASH0] +#define RTE_FLASH0 1 #endif /* __RTE_DEVICE_H */ diff --git a/platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/RTE_Device.h b/platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/RTE_Device.h index 98c368ac5..7c1c94919 100644 --- a/platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/RTE_Device.h +++ b/platform/ext/target/nordic_nrf/nrf9161dk_nrf9161/RTE_Device.h @@ -4,74 +4,32 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -//-------- <<< Use Configuration Wizard in Context Menu >>> -------------------- - #ifndef __RTE_DEVICE_H #define __RTE_DEVICE_H -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] -// Configuration settings for Driver_USART0 in component ::Drivers:USART -#define RTE_USART0 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART0_TXD_PIN 27 -// RXD -#define RTE_USART0_RXD_PIN 26 -// RTS -#define RTE_USART0_RTS_PIN 14 -// CTS -#define RTE_USART0_CTS_PIN 15 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART0] +#include + +#define RTE_USART0 1 + +#define RTE_USART0_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 27), \ + NRF_PSEL(UART_RX, 0, 26), \ + NRF_PSEL(UART_RTS, 0, 14), \ + NRF_PSEL(UART_CTS, 0, 15), \ +} -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] -// Configuration settings for Driver_USART1 in component ::Drivers:USART -#define RTE_USART1 1 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART1_TXD_PIN 29 -// RXD -#define RTE_USART1_RXD_PIN 28 -// RTS -#define RTE_USART1_RTS_PIN 16 -// CTS -#define RTE_USART1_CTS_PIN 17 -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART1] -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] -// Configuration settings for Driver_USART2 in component ::Drivers:USART -#define RTE_USART2 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART2_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART2_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART2_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART2_CTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART2] +#define RTE_USART1 1 -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] -// Configuration settings for Driver_USART3 in component ::Drivers:USART -#define RTE_USART3 0 -// Pin Selection (0xFFFFFFFF means Disconnected) -// TXD -#define RTE_USART3_TXD_PIN 0xFFFFFFFF -// RXD -#define RTE_USART3_RXD_PIN 0xFFFFFFFF -// RTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// CTS -#define RTE_USART3_RTS_PIN 0xFFFFFFFF -// Pin Configuration -// USART (Universal synchronous - asynchronous receiver transmitter) [Driver_USART3] +#define RTE_USART1_PINS \ +{ \ + NRF_PSEL(UART_TX, 0, 29), \ + NRF_PSEL(UART_RX, 0, 28), \ + NRF_PSEL(UART_RTS, 0, 16), \ + NRF_PSEL(UART_CTS, 0, 17), \ +} -// FLASH (Flash Memory) [Driver_FLASH0] -// Configuration settings for Driver_FLASH0 in component ::Drivers:FLASH -#define RTE_FLASH0 1 -// FLASH (Flash Memory) [Driver_FLASH0] +#define RTE_FLASH0 1 #endif /* __RTE_DEVICE_H */