Skip to content

Commit 2564a83

Browse files
authored
Merge pull request #2822 from anangl/master
TARGET_NRF5: Removed waiting for TX completed from 'serial_putc()'.
2 parents fbce4e1 + 86005da commit 2564a83

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 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
}
@@ -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)