From 04174272cb3d70a1a338de87b6547be3f5d6d54c Mon Sep 17 00:00:00 2001 From: Yoshihiro TSUBOI Date: Thu, 18 Aug 2016 12:13:46 +0900 Subject: [PATCH 1/2] [NRF_5] add configuration for serial flow control --- hal/targets.json | 8 ++++++++ .../TARGET_NORDIC/TARGET_NRF5/serial_api.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/hal/targets.json b/hal/targets.json index 5b4796eea41..a0adfb8d098 100644 --- a/hal/targets.json +++ b/hal/targets.json @@ -1538,6 +1538,9 @@ "macros_add": ["TARGET_NRF_32MHZ_XTAL"], "progen": {"target": "ty51822r3"}, "device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], + "overrides": { + "serial_fc": "WITHOUT_FC" + }, "detect_code": ["1019"], "release_versions": ["2", "5"] }, @@ -1887,6 +1890,11 @@ "lf_clock_src": { "value": "NRF_LF_SRC_XTAL", "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC" + }, + "serial_fc": { + "help": "Choose serial with flow control or without", + "value": "WITH_FC", + "macro_name": "MBED_CONF_NORDIC_NRF_SERIAL_FC" } } }, diff --git a/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c b/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c index 58a8754b76d..013fdc3c655 100644 --- a/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c +++ b/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c @@ -62,6 +62,15 @@ #define UART_DEFAULT_CTS UART0_CONFIG_PSEL_CTS #define UART_DEFAULT_RTS UART0_CONFIG_PSEL_RTS +#ifndef MBED_CONF_NORDIC_NRF_SERIAL_FC + #define MBED_CONF_NORDIC_NRF_SERIAL_FC (WITH_FC) + #warning No configuration for serial flow control. Serial will be used as a default, with flow control. +#endif + +#define WITH_FC 2 +#define WITHOUT_FC 3 + + // Required by "retarget.cpp". int stdio_uart_inited = 0; serial_t stdio_uart; @@ -257,9 +266,16 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { else { UART_CB.baudrate = UART_DEFAULT_BAUDRATE; UART_CB.parity = UART_DEFAULT_PARITY; + + #if MBED_CONF_NORDIC_NRF_SERIAL_FC == WITH_FC UART_CB.hwfc = UART_DEFAULT_HWFC; UART_CB.pselcts = UART_DEFAULT_CTS; UART_CB.pselrts = UART_DEFAULT_RTS; + #elif MBED_CONF_NORDIC_NRF_SERIAL_FC == WITHOUT_FC + // Not init UART with HWFC. + #else + #error Bad flow control configuration. Declare proper source through mbed configuration. + #endif nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_RXDRDY); nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_TXDRDY); @@ -639,4 +655,7 @@ void serial_rx_abort_asynch(serial_t *obj) #endif // DEVICE_SERIAL_ASYNCH +#undef WITH_FC +#undef WITHOUT_FC + #endif // DEVICE_SERIAL From 9680a4319dda85afa97c76507374629872c244e4 Mon Sep 17 00:00:00 2001 From: Yoshihiro TSUBOI Date: Fri, 19 Aug 2016 23:32:12 +0900 Subject: [PATCH 2/2] Revert "[NRF_5] add configuration for serial flow control" This reverts commit 04174272cb3d70a1a338de87b6547be3f5d6d54c. --- hal/targets.json | 8 -------- .../TARGET_NORDIC/TARGET_NRF5/serial_api.c | 19 ------------------- 2 files changed, 27 deletions(-) diff --git a/hal/targets.json b/hal/targets.json index a0adfb8d098..5b4796eea41 100644 --- a/hal/targets.json +++ b/hal/targets.json @@ -1538,9 +1538,6 @@ "macros_add": ["TARGET_NRF_32MHZ_XTAL"], "progen": {"target": "ty51822r3"}, "device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"], - "overrides": { - "serial_fc": "WITHOUT_FC" - }, "detect_code": ["1019"], "release_versions": ["2", "5"] }, @@ -1890,11 +1887,6 @@ "lf_clock_src": { "value": "NRF_LF_SRC_XTAL", "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC" - }, - "serial_fc": { - "help": "Choose serial with flow control or without", - "value": "WITH_FC", - "macro_name": "MBED_CONF_NORDIC_NRF_SERIAL_FC" } } }, diff --git a/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c b/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c index 013fdc3c655..58a8754b76d 100644 --- a/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c +++ b/hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c @@ -62,15 +62,6 @@ #define UART_DEFAULT_CTS UART0_CONFIG_PSEL_CTS #define UART_DEFAULT_RTS UART0_CONFIG_PSEL_RTS -#ifndef MBED_CONF_NORDIC_NRF_SERIAL_FC - #define MBED_CONF_NORDIC_NRF_SERIAL_FC (WITH_FC) - #warning No configuration for serial flow control. Serial will be used as a default, with flow control. -#endif - -#define WITH_FC 2 -#define WITHOUT_FC 3 - - // Required by "retarget.cpp". int stdio_uart_inited = 0; serial_t stdio_uart; @@ -266,16 +257,9 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) { else { UART_CB.baudrate = UART_DEFAULT_BAUDRATE; UART_CB.parity = UART_DEFAULT_PARITY; - - #if MBED_CONF_NORDIC_NRF_SERIAL_FC == WITH_FC UART_CB.hwfc = UART_DEFAULT_HWFC; UART_CB.pselcts = UART_DEFAULT_CTS; UART_CB.pselrts = UART_DEFAULT_RTS; - #elif MBED_CONF_NORDIC_NRF_SERIAL_FC == WITHOUT_FC - // Not init UART with HWFC. - #else - #error Bad flow control configuration. Declare proper source through mbed configuration. - #endif nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_RXDRDY); nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_TXDRDY); @@ -655,7 +639,4 @@ void serial_rx_abort_asynch(serial_t *obj) #endif // DEVICE_SERIAL_ASYNCH -#undef WITH_FC -#undef WITHOUT_FC - #endif // DEVICE_SERIAL