From f6d6d44346de591756a88a5f803c0fbe8f542d9f Mon Sep 17 00:00:00 2001 From: Hugues Kamba Date: Fri, 29 May 2020 20:13:13 +0100 Subject: [PATCH] NRF serial: Use nrf_uarte_event_t enum to avoid implicit conversion --- .../TARGET_NRF5x/TARGET_NRF52/serial_api.c | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c index 59a7873209..6be6948dc1 100644 --- a/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c +++ b/targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c @@ -102,13 +102,6 @@ * |___/|_| */ -/** - * Missing event typedefs. - */ -typedef enum { - NRF_UARTE_EVENT_TXDRDY = offsetof(NRF_UARTE_Type, EVENTS_TXDRDY), -} nrf_uarte_event_extra_t; - /** * Internal struct for storing each UARTE instance's state: @@ -910,12 +903,12 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) nrf_uarte_enable(nordic_nrf5_uart_register[instance]); /* In order to support printing with interrupts disabled serial_putc - * must busy wait on NRF_UARTE_EVENT_TXDRDY. This event cannot be set + * must busy wait on NRF_UARTE_EVENT_TXDDY. This event cannot be set * manually but must be set by the UARTE module after a character has * been sent. * * The following code sends a dummy character into the void so that - * NRF_UARTE_EVENT_TXDRDY is correctly set. + * NRF_UARTE_EVENT_TXDDY is correctly set. */ /* Ensure pins are disconnected. */ @@ -934,11 +927,11 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDTX); nrf_uarte_task_trigger(nordic_nrf5_uart_register[instance], NRF_UARTE_TASK_STARTTX); - /* Wait until NRF_UARTE_EVENT_TXDRDY is set before proceeding. */ + /* Wait until NRF_UARTE_EVENT_TXDDY is set before proceeding. */ bool done = false; do { done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance], - (nrf_uarte_event_t) NRF_UARTE_EVENT_TXDRDY); + NRF_UARTE_EVENT_TXDDY); } while (done == false); } @@ -1284,7 +1277,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) Driver uses DMA to perform uart transfer and TxIrq is generated after the transfer is finished. Trigger TxIrq interrupt manually on enabling the TxIrq. */ if (irq == TxIrq) { - if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY)) { + if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY)) { nordic_swi_tx_trigger(instance); } } @@ -1365,10 +1358,10 @@ void serial_putc(serial_t *obj, int character) /* Wait until UART is ready to send next character. */ do { - done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY); + done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY); } while (done == false); - nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY); + nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY); /* Arm Tx DMA buffer. */ nordic_nrf5_uart_state[instance].tx_data = character; @@ -1431,7 +1424,7 @@ int serial_writable(serial_t *obj) int instance = uart_object->instance; return (!core_util_atomic_load_bool(&nordic_nrf5_uart_state[instance].tx_in_progress) && - (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY))); + (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY))); } const PinMap *serial_tx_pinmap()