Skip to content

Commit 0417427

Browse files
committed
[NRF_5] add configuration for serial flow control
1 parent bdb4ab9 commit 0417427

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

hal/targets.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,9 @@
15381538
"macros_add": ["TARGET_NRF_32MHZ_XTAL"],
15391539
"progen": {"target": "ty51822r3"},
15401540
"device_has": ["ANALOGIN", "ERROR_PATTERN", "I2C", "I2C_ASYNCH", "INTERRUPTIN", "LOWPOWERTIMER", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SERIAL_ASYNCH", "SLEEP", "SPI", "SPI_ASYNCH", "SPISLAVE"],
1541+
"overrides": {
1542+
"serial_fc": "WITHOUT_FC"
1543+
},
15411544
"detect_code": ["1019"],
15421545
"release_versions": ["2", "5"]
15431546
},
@@ -1887,6 +1890,11 @@
18871890
"lf_clock_src": {
18881891
"value": "NRF_LF_SRC_XTAL",
18891892
"macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC"
1893+
},
1894+
"serial_fc": {
1895+
"help": "Choose serial with flow control or without",
1896+
"value": "WITH_FC",
1897+
"macro_name": "MBED_CONF_NORDIC_NRF_SERIAL_FC"
18901898
}
18911899
}
18921900
},

hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
#define UART_DEFAULT_CTS UART0_CONFIG_PSEL_CTS
6363
#define UART_DEFAULT_RTS UART0_CONFIG_PSEL_RTS
6464

65+
#ifndef MBED_CONF_NORDIC_NRF_SERIAL_FC
66+
#define MBED_CONF_NORDIC_NRF_SERIAL_FC (WITH_FC)
67+
#warning No configuration for serial flow control. Serial will be used as a default, with flow control.
68+
#endif
69+
70+
#define WITH_FC 2
71+
#define WITHOUT_FC 3
72+
73+
6574
// Required by "retarget.cpp".
6675
int stdio_uart_inited = 0;
6776
serial_t stdio_uart;
@@ -257,9 +266,16 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
257266
else {
258267
UART_CB.baudrate = UART_DEFAULT_BAUDRATE;
259268
UART_CB.parity = UART_DEFAULT_PARITY;
269+
270+
#if MBED_CONF_NORDIC_NRF_SERIAL_FC == WITH_FC
260271
UART_CB.hwfc = UART_DEFAULT_HWFC;
261272
UART_CB.pselcts = UART_DEFAULT_CTS;
262273
UART_CB.pselrts = UART_DEFAULT_RTS;
274+
#elif MBED_CONF_NORDIC_NRF_SERIAL_FC == WITHOUT_FC
275+
// Not init UART with HWFC.
276+
#else
277+
#error Bad flow control configuration. Declare proper source through mbed configuration.
278+
#endif
263279

264280
nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_RXDRDY);
265281
nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_TXDRDY);
@@ -639,4 +655,7 @@ void serial_rx_abort_asynch(serial_t *obj)
639655

640656
#endif // DEVICE_SERIAL_ASYNCH
641657

658+
#undef WITH_FC
659+
#undef WITHOUT_FC
660+
642661
#endif // DEVICE_SERIAL

0 commit comments

Comments
 (0)