Skip to content

Commit

Permalink
Merge pull request ARMmbed#2822 from anangl/master
Browse files Browse the repository at this point in the history
TARGET_NRF5: Removed waiting for TX completed from 'serial_putc()'.
  • Loading branch information
sg- committed Sep 28, 2016
2 parents fbce4e1 + 86005da commit 2564a83
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions hal/targets/hal/TARGET_NORDIC/TARGET_NRF5/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,15 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
nrf_gpio_cfg_input(UART_CB.pselrxd, NRF_GPIO_PIN_NOPULL);
}

// UART pins must only be configured when the peripheral is disabled.
nrf_uart_disable(UART_INSTANCE);

if (UART_CB.initialized) {
// Reconfigure RX/TX pins only.
// For already initialized peripheral it is sufficient to reconfigure
// RX/TX pins only.

// Ensure that there is no unfinished TX transfer.
while (!serial_writable(obj)) {
}
// UART pins can be configured only when the peripheral is disabled.
nrf_uart_disable(UART_INSTANCE);
nrf_uart_txrx_pins_set(UART_INSTANCE, UART_CB.pseltxd, UART_CB.pselrxd);
nrf_uart_enable(UART_INSTANCE);
}
Expand Down Expand Up @@ -479,9 +483,6 @@ void serial_putc(serial_t *obj, int c)

nrf_uart_event_clear(UART_INSTANCE, NRF_UART_EVENT_TXDRDY);
nrf_uart_txd_set(UART_INSTANCE, (uint8_t)c);
// Wait until sending is completed.
while (!nrf_uart_event_check(UART_INSTANCE, NRF_UART_EVENT_TXDRDY)) {
}
}

int serial_readable(serial_t *obj)
Expand Down

0 comments on commit 2564a83

Please sign in to comment.