Skip to content

Commit 819b9f9

Browse files
authored
Merge pull request #13043 from hugueskamba/hk_nrf_serial_warning
NRF serial: Use nrf_uarte_event_t enum to avoid implicit conversion
2 parents 35a0e5d + f6d6d44 commit 819b9f9

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@
102102
* |___/|_|
103103
*/
104104

105-
/**
106-
* Missing event typedefs.
107-
*/
108-
typedef enum {
109-
NRF_UARTE_EVENT_TXDRDY = offsetof(NRF_UARTE_Type, EVENTS_TXDRDY),
110-
} nrf_uarte_event_extra_t;
111-
112105

113106
/**
114107
* Internal struct for storing each UARTE instance's state:
@@ -910,12 +903,12 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
910903
nrf_uarte_enable(nordic_nrf5_uart_register[instance]);
911904

912905
/* In order to support printing with interrupts disabled serial_putc
913-
* must busy wait on NRF_UARTE_EVENT_TXDRDY. This event cannot be set
906+
* must busy wait on NRF_UARTE_EVENT_TXDDY. This event cannot be set
914907
* manually but must be set by the UARTE module after a character has
915908
* been sent.
916909
*
917910
* The following code sends a dummy character into the void so that
918-
* NRF_UARTE_EVENT_TXDRDY is correctly set.
911+
* NRF_UARTE_EVENT_TXDDY is correctly set.
919912
*/
920913

921914
/* Ensure pins are disconnected. */
@@ -934,11 +927,11 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
934927
nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDTX);
935928
nrf_uarte_task_trigger(nordic_nrf5_uart_register[instance], NRF_UARTE_TASK_STARTTX);
936929

937-
/* Wait until NRF_UARTE_EVENT_TXDRDY is set before proceeding. */
930+
/* Wait until NRF_UARTE_EVENT_TXDDY is set before proceeding. */
938931
bool done = false;
939932
do {
940933
done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance],
941-
(nrf_uarte_event_t) NRF_UARTE_EVENT_TXDRDY);
934+
NRF_UARTE_EVENT_TXDDY);
942935
} while (done == false);
943936
}
944937

@@ -1284,7 +1277,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
12841277
Driver uses DMA to perform uart transfer and TxIrq is generated after the transfer is finished.
12851278
Trigger TxIrq interrupt manually on enabling the TxIrq. */
12861279
if (irq == TxIrq) {
1287-
if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY)) {
1280+
if (nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY)) {
12881281
nordic_swi_tx_trigger(instance);
12891282
}
12901283
}
@@ -1365,10 +1358,10 @@ void serial_putc(serial_t *obj, int character)
13651358

13661359
/* Wait until UART is ready to send next character. */
13671360
do {
1368-
done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY);
1361+
done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY);
13691362
} while (done == false);
13701363

1371-
nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY);
1364+
nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY);
13721365

13731366
/* Arm Tx DMA buffer. */
13741367
nordic_nrf5_uart_state[instance].tx_data = character;
@@ -1431,7 +1424,7 @@ int serial_writable(serial_t *obj)
14311424
int instance = uart_object->instance;
14321425

14331426
return (!core_util_atomic_load_bool(&nordic_nrf5_uart_state[instance].tx_in_progress) &&
1434-
(nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDRDY)));
1427+
(nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXDDY)));
14351428
}
14361429

14371430
const PinMap *serial_tx_pinmap()

0 commit comments

Comments
 (0)