Skip to content

Commit d0eed52

Browse files
committed
Removed waiting for TX completed from 'serial_putc()', moved it to 'serial_init()' to allow passing tests MBED_37/38.
1 parent 4820c87 commit d0eed52

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,15 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
258258
nrf_gpio_cfg_input(UART_CB.pselrxd, NRF_GPIO_PIN_NOPULL);
259259
}
260260

261-
// UART pins must only be configured when the peripheral is disabled.
262-
nrf_uart_disable(UART_INSTANCE);
263-
264261
if (UART_CB.initialized) {
265-
// Reconfigure RX/TX pins only.
262+
// For already initialized peripheral it is sufficient to reconfigure
263+
// RX/TX pins only.
264+
265+
// Ensure that there is no unfinished TX transfer.
266+
while (!serial_writable(obj)) {
267+
}
268+
// UART pins can be configured only when the peripheral is disabled.
269+
nrf_uart_disable(UART_INSTANCE);
266270
nrf_uart_txrx_pins_set(UART_INSTANCE, UART_CB.pseltxd, UART_CB.pselrxd);
267271
nrf_uart_enable(UART_INSTANCE);
268272
}
@@ -310,7 +314,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
310314
nrf_uart_configure(UART_INSTANCE, UART_CB.parity, UART_CB.hwfc);
311315
if (UART_CB.hwfc == NRF_UART_HWFC_ENABLED) {
312316
serial_set_flow_control(obj, FlowControlRTSCTS,
313-
UART_CB.pselrts, UART_CB.pselcts);
317+
(PinName)UART_CB.pselrts, (PinName)UART_CB.pselcts);
314318
}
315319
nrf_uart_enable(UART_INSTANCE);
316320

@@ -479,9 +483,6 @@ void serial_putc(serial_t *obj, int c)
479483

480484
nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_TXDRDY);
481485
nrf_uart_txd_set(UART_INSTANCE, (uint8_t)c);
482-
// Wait until sending is completed.
483-
while (!nrf_uart_event_check(UART_INSTANCE, NRF_UART_EVENT_TXDRDY)) {
484-
}
485486
}
486487

487488
int serial_readable(serial_t *obj)

0 commit comments

Comments
 (0)