Skip to content

Commit dc19460

Browse files
committed
Remove use of deprecated UART driver (as opposed to UARTE). Disable unused TWIM peripheral (deprecated TWI peripheral is currently used for I2C master mode operation).
1 parent b6befee commit dc19460

File tree

5 files changed

+47
-52
lines changed

5 files changed

+47
-52
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52832/config/sdk_config.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,20 +3804,20 @@
38043804
// <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver
38053805
//==========================================================
38063806
#ifndef NRFX_TWIM_ENABLED
3807-
#define NRFX_TWIM_ENABLED 1
3807+
#define NRFX_TWIM_ENABLED 0
38083808
#endif
38093809
// <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance
38103810

38113811

38123812
#ifndef NRFX_TWIM0_ENABLED
3813-
#define NRFX_TWIM0_ENABLED 1
3813+
#define NRFX_TWIM0_ENABLED 0
38143814
#endif
38153815

38163816
// <q> NRFX_TWIM1_ENABLED - Enable TWIM1 instance
38173817

38183818

38193819
#ifndef NRFX_TWIM1_ENABLED
3820-
#define NRFX_TWIM1_ENABLED 1
3820+
#define NRFX_TWIM1_ENABLED 0
38213821
#endif
38223822

38233823
// <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency
@@ -4314,11 +4314,11 @@
43144314
// <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver
43154315
//==========================================================
43164316
#ifndef NRFX_UART_ENABLED
4317-
#define NRFX_UART_ENABLED 1
4317+
#define NRFX_UART_ENABLED 0
43184318
#endif
43194319
// <o> NRFX_UART0_ENABLED - Enable UART0 instance
43204320
#ifndef NRFX_UART0_ENABLED
4321-
#define NRFX_UART0_ENABLED 1
4321+
#define NRFX_UART0_ENABLED 0
43224322
#endif
43234323

43244324
// <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control
@@ -5631,13 +5631,13 @@
56315631

56325632

56335633
#ifndef UART_LEGACY_SUPPORT
5634-
#define UART_LEGACY_SUPPORT 1
5634+
#define UART_LEGACY_SUPPORT 0
56355635
#endif
56365636

56375637
// <e> UART0_ENABLED - Enable UART0 instance
56385638
//==========================================================
56395639
#ifndef UART0_ENABLED
5640-
#define UART0_ENABLED 1
5640+
#define UART0_ENABLED 0
56415641
#endif
56425642
// <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA
56435643

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/config/sdk_config.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,20 +3804,20 @@
38043804
// <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver
38053805
//==========================================================
38063806
#ifndef NRFX_TWIM_ENABLED
3807-
#define NRFX_TWIM_ENABLED 1
3807+
#define NRFX_TWIM_ENABLED 0
38083808
#endif
38093809
// <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance
38103810

38113811

38123812
#ifndef NRFX_TWIM0_ENABLED
3813-
#define NRFX_TWIM0_ENABLED 1
3813+
#define NRFX_TWIM0_ENABLED 0
38143814
#endif
38153815

38163816
// <q> NRFX_TWIM1_ENABLED - Enable TWIM1 instance
38173817

38183818

38193819
#ifndef NRFX_TWIM1_ENABLED
3820-
#define NRFX_TWIM1_ENABLED 1
3820+
#define NRFX_TWIM1_ENABLED 0
38213821
#endif
38223822

38233823
// <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency
@@ -4316,11 +4316,11 @@
43164316
// <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver
43174317
//==========================================================
43184318
#ifndef NRFX_UART_ENABLED
4319-
#define NRFX_UART_ENABLED 1
4319+
#define NRFX_UART_ENABLED 0
43204320
#endif
43214321
// <o> NRFX_UART0_ENABLED - Enable UART0 instance
43224322
#ifndef NRFX_UART0_ENABLED
4323-
#define NRFX_UART0_ENABLED 1
4323+
#define NRFX_UART0_ENABLED 0
43244324
#endif
43254325

43264326
// <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control
@@ -5645,13 +5645,13 @@
56455645

56465646

56475647
#ifndef UART_LEGACY_SUPPORT
5648-
#define UART_LEGACY_SUPPORT 1
5648+
#define UART_LEGACY_SUPPORT 0
56495649
#endif
56505650

56515651
// <e> UART0_ENABLED - Enable UART0 instance
56525652
//==========================================================
56535653
#ifndef UART0_ENABLED
5654-
#define UART0_ENABLED 1
5654+
#define UART0_ENABLED 0
56555655
#endif
56565656
// <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA
56575657

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/objects.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
extern "C" {
5353
#endif
5454

55-
#include "nrf_uart.h"
55+
#include "nrf_uarte.h"
5656

5757
#if defined(FEATURE_CRYPTOCELL310)
5858
#include "objects_cryptocell.h"
@@ -68,9 +68,9 @@ struct serial_s {
6868
uint32_t rx;
6969
uint32_t cts;
7070
uint32_t rts;
71-
nrf_uart_hwfc_t hwfc;
72-
nrf_uart_parity_t parity;
73-
nrf_uart_baudrate_t baudrate;
71+
nrf_uarte_hwfc_t hwfc;
72+
nrf_uarte_parity_t parity;
73+
nrf_uarte_baudrate_t baudrate;
7474
uint32_t context;
7575
uint32_t handler;
7676
uint32_t mask;

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/serial_api.c

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
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"
@@ -53,8 +52,8 @@
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;

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_SDK_15_0/modules/nrfx/drivers/src/nrfx_twim.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,22 +647,18 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
647647
p_cb->handler(&event, p_cb->p_context);
648648
}
649649

650-
#if 0
651650
#if NRFX_CHECK(NRFX_TWIM0_ENABLED)
652651
void nrfx_twim_0_irq_handler(void)
653652
{
654653
twim_irq_handler(NRF_TWIM0, &m_cb[NRFX_TWIM0_INST_IDX]);
655654
}
656655
#endif
657-
#endif
658656

659-
#if 0
660657
#if NRFX_CHECK(NRFX_TWIM1_ENABLED)
661658
void nrfx_twim_1_irq_handler(void)
662659
{
663660
twim_irq_handler(NRF_TWIM1, &m_cb[NRFX_TWIM1_INST_IDX]);
664661
}
665662
#endif
666-
#endif
667663

668664
#endif // NRFX_CHECK(NRFX_TWIM_ENABLED)

0 commit comments

Comments
 (0)