42
42
43
43
#include "nrf_uarte.h"
44
44
#include "nrfx_uarte.h"
45
- #include "nrfx_uart.h"
46
45
#include "nrf_atfifo.h"
47
46
#include "app_util_platform.h"
48
47
#include "pinmap_ex.h"
53
52
#include "platform/mbed_atomic.h"
54
53
#include "platform/mbed_critical.h"
55
54
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.
58
57
#endif
59
58
60
59
@@ -456,7 +455,7 @@ static void nordic_nrf5_uart_event_handler_rxstarted(int instance)
456
455
uint8_t next_bank = nordic_nrf5_uart_state [instance ].active_bank ^ 0x01 ;
457
456
458
457
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 ) {
460
459
if (nordic_nrf5_uart_state [instance ].fifo_free_count > FIFO_MIN ) {
461
460
/* Clear rts since we are ready to receive the next byte */
462
461
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)
596
595
#endif
597
596
598
597
/* Configure Tx and Rx pins. */
599
- if (uart_object -> tx != NRF_UART_PSEL_DISCONNECTED ) {
598
+ if (uart_object -> tx != NRF_UARTE_PSEL_DISCONNECTED ) {
600
599
601
600
nrf_gpio_pin_set (uart_object -> tx );
602
601
nrf_gpio_cfg_output (uart_object -> tx );
603
602
}
604
603
605
- if (uart_object -> rx != NRF_UART_PSEL_DISCONNECTED ) {
604
+ if (uart_object -> rx != NRF_UARTE_PSEL_DISCONNECTED ) {
606
605
607
606
nrf_gpio_cfg_input (uart_object -> rx , NRF_GPIO_PIN_NOPULL );
608
607
}
@@ -612,17 +611,17 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
612
611
uart_object -> rx );
613
612
614
613
/* Set hardware flow control pins. */
615
- if (uart_object -> hwfc == NRF_UART_HWFC_ENABLED ) {
614
+ if (uart_object -> hwfc == NRF_UARTE_HWFC_ENABLED ) {
616
615
617
616
/* 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 ) {
619
618
620
619
nrf_gpio_cfg_input (uart_object -> cts , NRF_GPIO_PIN_NOPULL );
621
620
}
622
621
623
622
/* Only let UARTE module handle CTS, RTS is handled manually due to buggy UARTE logic. */
624
623
nrf_uarte_hwfc_pins_set (nordic_nrf5_uart_register [uart_object -> instance ],
625
- NRF_UART_PSEL_DISCONNECTED ,
624
+ NRF_UARTE_PSEL_DISCONNECTED ,
626
625
uart_object -> cts );
627
626
}
628
627
@@ -635,12 +634,12 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
635
634
MBED_ASSERT (ret == NRF_SUCCESS );
636
635
637
636
/* 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 ) {
639
638
nrfx_gpiote_out_uninit ((nrfx_gpiote_pin_t )uart_object -> rts );
640
639
}
641
640
642
641
/* 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 ) {
644
643
645
644
static const nrfx_gpiote_out_config_t config = {
646
645
.init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH ,
@@ -868,7 +867,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
868
867
MBED_ASSERT (ret == NRF_SUCCESS );
869
868
870
869
/* Clear RTS */
871
- nordic_nrf5_uart_state [0 ].rts = NRF_UART_PSEL_DISCONNECTED ;
870
+ nordic_nrf5_uart_state [0 ].rts = NRF_UARTE_PSEL_DISCONNECTED ;
872
871
873
872
/* Clear any old events and enable interrupts for UARTE0. */
874
873
nrf_uarte_int_disable (nordic_nrf5_uart_register [0 ], 0xFFFFFFFF );
@@ -890,7 +889,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
890
889
MBED_ASSERT (ret == NRF_SUCCESS );
891
890
892
891
/* Clear RTS */
893
- nordic_nrf5_uart_state [1 ].rts = NRF_UART_PSEL_DISCONNECTED ;
892
+ nordic_nrf5_uart_state [1 ].rts = NRF_UARTE_PSEL_DISCONNECTED ;
894
893
895
894
/* Clear any old events and enable interrupts for UARTE1. */
896
895
nrf_uarte_int_disable (nordic_nrf5_uart_register [1 ], 0xFFFFFFFF );
@@ -925,8 +924,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
925
924
926
925
/* Ensure pins are disconnected. */
927
926
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 );
930
929
931
930
/* Set maximum baud rate to minimize waiting. */
932
931
nrf_uarte_baudrate_set (nordic_nrf5_uart_register [instance ],
@@ -950,26 +949,26 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
950
949
/* Store pins in serial object. */
951
950
if (tx == NC ) {
952
951
953
- uart_object -> tx = NRF_UART_PSEL_DISCONNECTED ;
952
+ uart_object -> tx = NRF_UARTE_PSEL_DISCONNECTED ;
954
953
} else {
955
954
956
955
uart_object -> tx = tx ;
957
956
}
958
957
959
958
if (rx == NC ) {
960
959
961
- uart_object -> rx = NRF_UART_PSEL_DISCONNECTED ;
960
+ uart_object -> rx = NRF_UARTE_PSEL_DISCONNECTED ;
962
961
} else {
963
962
964
963
uart_object -> rx = rx ;
965
964
}
966
965
967
966
/* 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 ;
973
972
uart_object -> handler = 0 ;
974
973
975
974
/* 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)
1043
1042
struct serial_s * uart_object = obj ;
1044
1043
#endif
1045
1044
1046
- nrf_uarte_baudrate_t new_rate = NRF_UART_BAUDRATE_9600 ;
1045
+ nrf_uarte_baudrate_t new_rate = NRF_UARTE_BAUDRATE_9600 ;
1047
1046
1048
1047
/* Round down to nearest supported baud rate. */
1049
1048
if (baudrate < 2400 ) {
@@ -1115,14 +1114,14 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
1115
1114
/**
1116
1115
* Only force change if parity has changed.
1117
1116
*/
1118
- if ((uart_object -> parity != NRF_UART_PARITY_EXCLUDED ) && (parity == ParityNone )) {
1117
+ if ((uart_object -> parity != NRF_UARTE_PARITY_EXCLUDED ) && (parity == ParityNone )) {
1119
1118
1120
- uart_object -> parity = NRF_UART_PARITY_EXCLUDED ;
1119
+ uart_object -> parity = NRF_UARTE_PARITY_EXCLUDED ;
1121
1120
uart_object -> update = true;
1122
1121
1123
- } else if ((uart_object -> parity != NRF_UART_PARITY_INCLUDED ) && (parity == ParityEven )) {
1122
+ } else if ((uart_object -> parity != NRF_UARTE_PARITY_INCLUDED ) && (parity == ParityEven )) {
1124
1123
1125
- uart_object -> parity = NRF_UART_PARITY_INCLUDED ;
1124
+ uart_object -> parity = NRF_UARTE_PARITY_INCLUDED ;
1126
1125
uart_object -> update = true;
1127
1126
}
1128
1127
}
@@ -1148,9 +1147,9 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
1148
1147
/**
1149
1148
* Convert Mbed pin names to Nordic pin names.
1150
1149
*/
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 ;
1154
1153
1155
1154
/* Force reconfiguration next time object is owner. */
1156
1155
uart_object -> update = true;
0 commit comments