mirror of https://github.com/ARMmbed/mbed-os.git
NRF serial: Use nrf_uarte_event_t enum to avoid implicit conversion
parent
c7759fe505
commit
f6d6d44346
|
@ -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:
|
* 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]);
|
nrf_uarte_enable(nordic_nrf5_uart_register[instance]);
|
||||||
|
|
||||||
/* In order to support printing with interrupts disabled serial_putc
|
/* 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
|
* manually but must be set by the UARTE module after a character has
|
||||||
* been sent.
|
* been sent.
|
||||||
*
|
*
|
||||||
* The following code sends a dummy character into the void so that
|
* 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. */
|
/* 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_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_ENDTX);
|
||||||
nrf_uarte_task_trigger(nordic_nrf5_uart_register[instance], NRF_UARTE_TASK_STARTTX);
|
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;
|
bool done = false;
|
||||||
do {
|
do {
|
||||||
done = nrf_uarte_event_check(nordic_nrf5_uart_register[instance],
|
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);
|
} 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.
|
Driver uses DMA to perform uart transfer and TxIrq is generated after the transfer is finished.
|
||||||
Trigger TxIrq interrupt manually on enabling the TxIrq. */
|
Trigger TxIrq interrupt manually on enabling the TxIrq. */
|
||||||
if (irq == 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);
|
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. */
|
/* Wait until UART is ready to send next character. */
|
||||||
do {
|
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);
|
} 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. */
|
/* Arm Tx DMA buffer. */
|
||||||
nordic_nrf5_uart_state[instance].tx_data = character;
|
nordic_nrf5_uart_state[instance].tx_data = character;
|
||||||
|
@ -1431,7 +1424,7 @@ int serial_writable(serial_t *obj)
|
||||||
int instance = uart_object->instance;
|
int instance = uart_object->instance;
|
||||||
|
|
||||||
return (!core_util_atomic_load_bool(&nordic_nrf5_uart_state[instance].tx_in_progress) &&
|
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()
|
const PinMap *serial_tx_pinmap()
|
||||||
|
|
Loading…
Reference in New Issue