From 90dd7a42d07ea2a912cc594cd069da8c62744855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Duda?= Date: Tue, 13 Nov 2018 00:52:20 +0100 Subject: [PATCH] [nrf52840] fix uart configuration of HWFC (#3277) --- examples/platforms/nrf52840/platform-config.h | 12 ++++-------- examples/platforms/nrf52840/uart.c | 9 +++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/examples/platforms/nrf52840/platform-config.h b/examples/platforms/nrf52840/platform-config.h index 7b6b78e0b..a8498d464 100644 --- a/examples/platforms/nrf52840/platform-config.h +++ b/examples/platforms/nrf52840/platform-config.h @@ -73,17 +73,13 @@ #endif /** - * @def UART_HWFC + * @def UART_HWFC_ENABLED * - * UART Hardware Flow Control. - * - * @brief Possible values: - * \ref NRF_UART_HWFC_ENABLED - HW Flow control enabled. - * \ref NRF_UART_HWFC_DISABLED - HW Flow control disabled. + * Enable UART Hardware Flow Control. * */ -#ifndef UART_HWFC -#define UART_HWFC NRF_UART_HWFC_ENABLED +#ifndef UART_HWFC_ENABLED +#define UART_HWFC_ENABLED 1 #endif /** diff --git a/examples/platforms/nrf52840/uart.c b/examples/platforms/nrf52840/uart.c index b95c47554..857069d01 100644 --- a/examples/platforms/nrf52840/uart.c +++ b/examples/platforms/nrf52840/uart.c @@ -175,20 +175,21 @@ otError otPlatUartEnable(void) nrf_gpio_cfg_input(UART_PIN_RX, NRF_GPIO_PIN_NOPULL); nrf_uart_txrx_pins_set(UART_INSTANCE, UART_PIN_TX, UART_PIN_RX); -#if (UART_HWFC == NRF_UART_HWFC_ENABLED) +#if (UART_HWFC_ENABLED == 1) // Set up CTS and RTS pins. nrf_gpio_cfg_input(UART_PIN_CTS, NRF_GPIO_PIN_NOPULL); nrf_gpio_pin_set(UART_PIN_RTS); nrf_gpio_cfg_output(UART_PIN_RTS); nrf_uart_hwfc_pins_set(UART_INSTANCE, UART_PIN_RTS, UART_PIN_CTS); + + nrf_uart_configure(UART_INSTANCE, UART_PARITY, NRF_UART_HWFC_ENABLED); +#else + nrf_uart_configure(UART_INSTANCE, UART_PARITY, NRF_UART_HWFC_DISABLED); #endif // Configure baudrate. nrf_uart_baudrate_set(UART_INSTANCE, UART_BAUDRATE); - // Configure parity and hardware flow control. - nrf_uart_configure(UART_INSTANCE, UART_PARITY, UART_HWFC); - // Clear UART specific events. nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_TXDRDY); nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_ERROR);