4242
4343#include "nrf_uarte.h"
4444#include "nrfx_uarte.h"
45- #include "nrfx_uart.h"
4645#include "nrf_atfifo.h"
4746#include "app_util_platform.h"
4847#include "pinmap_ex.h"
5352#include "platform/mbed_atomic.h"
5453#include "platform/mbed_critical.h"
5554
56- #if UART0_ENABLED == 0
57- #error UART0 is disabled. DEVICE_SERIAL must also be disabled to continue.
55+ #if ! NRFX_CHECK ( NRFX_UARTE_ENABLED ) || !( NRFX_CHECK ( NRFX_UARTE0_ENABLED ) || NRFX_CHECK ( NRFX_UARTE1_ENABLED ))
56+ #error No enabled UARTE instances, DEVICE_SERIAL must also be disabled to continue.
5857#endif
5958
6059
@@ -456,7 +455,7 @@ static void nordic_nrf5_uart_event_handler_rxstarted(int instance)
456455 uint8_t next_bank = nordic_nrf5_uart_state [instance ].active_bank ^ 0x01 ;
457456
458457 nrf_uarte_rx_buffer_set (nordic_nrf5_uart_register [instance ], nordic_nrf5_uart_state [instance ].buffer [next_bank ], DMA_BUFFER_SIZE );
459- if (nordic_nrf5_uart_state [instance ].rts != NRF_UART_PSEL_DISCONNECTED ) {
458+ if (nordic_nrf5_uart_state [instance ].rts != NRF_UARTE_PSEL_DISCONNECTED ) {
460459 if (nordic_nrf5_uart_state [instance ].fifo_free_count > FIFO_MIN ) {
461460 /* Clear rts since we are ready to receive the next byte */
462461 nrfx_gpiote_clr_task_trigger (nordic_nrf5_uart_state [instance ].rts );
@@ -596,13 +595,13 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
596595#endif
597596
598597 /* Configure Tx and Rx pins. */
599- if (uart_object -> tx != NRF_UART_PSEL_DISCONNECTED ) {
598+ if (uart_object -> tx != NRF_UARTE_PSEL_DISCONNECTED ) {
600599
601600 nrf_gpio_pin_set (uart_object -> tx );
602601 nrf_gpio_cfg_output (uart_object -> tx );
603602 }
604603
605- if (uart_object -> rx != NRF_UART_PSEL_DISCONNECTED ) {
604+ if (uart_object -> rx != NRF_UARTE_PSEL_DISCONNECTED ) {
606605
607606 nrf_gpio_cfg_input (uart_object -> rx , NRF_GPIO_PIN_NOPULL );
608607 }
@@ -612,17 +611,17 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
612611 uart_object -> rx );
613612
614613 /* Set hardware flow control pins. */
615- if (uart_object -> hwfc == NRF_UART_HWFC_ENABLED ) {
614+ if (uart_object -> hwfc == NRF_UARTE_HWFC_ENABLED ) {
616615
617616 /* Check if pin is set before configuring it. */
618- if (uart_object -> cts != NRF_UART_PSEL_DISCONNECTED ) {
617+ if (uart_object -> cts != NRF_UARTE_PSEL_DISCONNECTED ) {
619618
620619 nrf_gpio_cfg_input (uart_object -> cts , NRF_GPIO_PIN_NOPULL );
621620 }
622621
623622 /* Only let UARTE module handle CTS, RTS is handled manually due to buggy UARTE logic. */
624623 nrf_uarte_hwfc_pins_set (nordic_nrf5_uart_register [uart_object -> instance ],
625- NRF_UART_PSEL_DISCONNECTED ,
624+ NRF_UARTE_PSEL_DISCONNECTED ,
626625 uart_object -> cts );
627626 }
628627
@@ -635,12 +634,12 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
635634 MBED_ASSERT (ret == NRF_SUCCESS );
636635
637636 /* Free flow control gpiote pin if it was previously set */
638- if (nordic_nrf5_uart_state [uart_object -> instance ].rts != NRF_UART_PSEL_DISCONNECTED ) {
637+ if (nordic_nrf5_uart_state [uart_object -> instance ].rts != NRF_UARTE_PSEL_DISCONNECTED ) {
639638 nrfx_gpiote_out_uninit ((nrfx_gpiote_pin_t )uart_object -> rts );
640639 }
641640
642641 /* Allocate and enable flow control gpiote pin if it is being used */
643- if (uart_object -> rts != NRF_UART_PSEL_DISCONNECTED ) {
642+ if (uart_object -> rts != NRF_UARTE_PSEL_DISCONNECTED ) {
644643
645644 static const nrfx_gpiote_out_config_t config = {
646645 .init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH ,
@@ -868,7 +867,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
868867 MBED_ASSERT (ret == NRF_SUCCESS );
869868
870869 /* Clear RTS */
871- nordic_nrf5_uart_state [0 ].rts = NRF_UART_PSEL_DISCONNECTED ;
870+ nordic_nrf5_uart_state [0 ].rts = NRF_UARTE_PSEL_DISCONNECTED ;
872871
873872 /* Clear any old events and enable interrupts for UARTE0. */
874873 nrf_uarte_int_disable (nordic_nrf5_uart_register [0 ], 0xFFFFFFFF );
@@ -890,7 +889,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
890889 MBED_ASSERT (ret == NRF_SUCCESS );
891890
892891 /* Clear RTS */
893- nordic_nrf5_uart_state [1 ].rts = NRF_UART_PSEL_DISCONNECTED ;
892+ nordic_nrf5_uart_state [1 ].rts = NRF_UARTE_PSEL_DISCONNECTED ;
894893
895894 /* Clear any old events and enable interrupts for UARTE1. */
896895 nrf_uarte_int_disable (nordic_nrf5_uart_register [1 ], 0xFFFFFFFF );
@@ -925,8 +924,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
925924
926925 /* Ensure pins are disconnected. */
927926 nrf_uarte_txrx_pins_set (nordic_nrf5_uart_register [instance ],
928- NRF_UART_PSEL_DISCONNECTED ,
929- NRF_UART_PSEL_DISCONNECTED );
927+ NRF_UARTE_PSEL_DISCONNECTED ,
928+ NRF_UARTE_PSEL_DISCONNECTED );
930929
931930 /* Set maximum baud rate to minimize waiting. */
932931 nrf_uarte_baudrate_set (nordic_nrf5_uart_register [instance ],
@@ -950,26 +949,26 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
950949 /* Store pins in serial object. */
951950 if (tx == NC ) {
952951
953- uart_object -> tx = NRF_UART_PSEL_DISCONNECTED ;
952+ uart_object -> tx = NRF_UARTE_PSEL_DISCONNECTED ;
954953 } else {
955954
956955 uart_object -> tx = tx ;
957956 }
958957
959958 if (rx == NC ) {
960959
961- uart_object -> rx = NRF_UART_PSEL_DISCONNECTED ;
960+ uart_object -> rx = NRF_UARTE_PSEL_DISCONNECTED ;
962961 } else {
963962
964963 uart_object -> rx = rx ;
965964 }
966965
967966 /* Set default parity, baud rate, and callback handler. */
968- uart_object -> parity = NRF_UART_PARITY_EXCLUDED ;
969- uart_object -> baudrate = NRF_UART_BAUDRATE_9600 ;
970- uart_object -> cts = NRF_UART_PSEL_DISCONNECTED ;
971- uart_object -> rts = NRF_UART_PSEL_DISCONNECTED ;
972- uart_object -> hwfc = NRF_UART_HWFC_DISABLED ;
967+ uart_object -> parity = NRF_UARTE_PARITY_EXCLUDED ;
968+ uart_object -> baudrate = NRF_UARTE_BAUDRATE_9600 ;
969+ uart_object -> cts = NRF_UARTE_PSEL_DISCONNECTED ;
970+ uart_object -> rts = NRF_UARTE_PSEL_DISCONNECTED ;
971+ uart_object -> hwfc = NRF_UARTE_HWFC_DISABLED ;
973972 uart_object -> handler = 0 ;
974973
975974 /* The STDIO object is stored in this file. Set the flag once initialized. */
@@ -1043,7 +1042,7 @@ void serial_baud(serial_t *obj, int baudrate)
10431042 struct serial_s * uart_object = obj ;
10441043#endif
10451044
1046- nrf_uarte_baudrate_t new_rate = NRF_UART_BAUDRATE_9600 ;
1045+ nrf_uarte_baudrate_t new_rate = NRF_UARTE_BAUDRATE_9600 ;
10471046
10481047 /* Round down to nearest supported baud rate. */
10491048 if (baudrate < 2400 ) {
@@ -1115,14 +1114,14 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
11151114 /**
11161115 * Only force change if parity has changed.
11171116 */
1118- if ((uart_object -> parity != NRF_UART_PARITY_EXCLUDED ) && (parity == ParityNone )) {
1117+ if ((uart_object -> parity != NRF_UARTE_PARITY_EXCLUDED ) && (parity == ParityNone )) {
11191118
1120- uart_object -> parity = NRF_UART_PARITY_EXCLUDED ;
1119+ uart_object -> parity = NRF_UARTE_PARITY_EXCLUDED ;
11211120 uart_object -> update = true;
11221121
1123- } else if ((uart_object -> parity != NRF_UART_PARITY_INCLUDED ) && (parity == ParityEven )) {
1122+ } else if ((uart_object -> parity != NRF_UARTE_PARITY_INCLUDED ) && (parity == ParityEven )) {
11241123
1125- uart_object -> parity = NRF_UART_PARITY_INCLUDED ;
1124+ uart_object -> parity = NRF_UARTE_PARITY_INCLUDED ;
11261125 uart_object -> update = true;
11271126 }
11281127}
@@ -1148,9 +1147,9 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
11481147 /**
11491148 * Convert Mbed pin names to Nordic pin names.
11501149 */
1151- uart_object -> cts = ((txflow == NC ) || (type == FlowControlRTS )) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t ) txflow ;
1152- uart_object -> rts = ((rxflow == NC ) || (type == FlowControlCTS )) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t ) rxflow ;
1153- uart_object -> hwfc = (type == FlowControlNone ) ? NRF_UART_HWFC_DISABLED : NRF_UART_HWFC_ENABLED ;
1150+ uart_object -> cts = ((txflow == NC ) || (type == FlowControlRTS )) ? NRF_UARTE_PSEL_DISCONNECTED : (uint32_t ) txflow ;
1151+ uart_object -> rts = ((rxflow == NC ) || (type == FlowControlCTS )) ? NRF_UARTE_PSEL_DISCONNECTED : (uint32_t ) rxflow ;
1152+ uart_object -> hwfc = (type == FlowControlNone ) ? NRF_UARTE_HWFC_DISABLED : NRF_UARTE_HWFC_ENABLED ;
11541153
11551154 /* Force reconfiguration next time object is owner. */
11561155 uart_object -> update = true;
0 commit comments