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).

pull/12160/head
aglass0fmilk 2020-01-09 15:57:23 -05:00 committed by George Beckstein
parent b6befee4cf
commit dc19460fa3
5 changed files with 47 additions and 52 deletions

View File

@ -3804,20 +3804,20 @@
// <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver // <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_TWIM_ENABLED #ifndef NRFX_TWIM_ENABLED
#define NRFX_TWIM_ENABLED 1 #define NRFX_TWIM_ENABLED 0
#endif #endif
// <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance // <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance
#ifndef NRFX_TWIM0_ENABLED #ifndef NRFX_TWIM0_ENABLED
#define NRFX_TWIM0_ENABLED 1 #define NRFX_TWIM0_ENABLED 0
#endif #endif
// <q> NRFX_TWIM1_ENABLED - Enable TWIM1 instance // <q> NRFX_TWIM1_ENABLED - Enable TWIM1 instance
#ifndef NRFX_TWIM1_ENABLED #ifndef NRFX_TWIM1_ENABLED
#define NRFX_TWIM1_ENABLED 1 #define NRFX_TWIM1_ENABLED 0
#endif #endif
// <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency // <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency
@ -4314,11 +4314,11 @@
// <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver // <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_UART_ENABLED #ifndef NRFX_UART_ENABLED
#define NRFX_UART_ENABLED 1 #define NRFX_UART_ENABLED 0
#endif #endif
// <o> NRFX_UART0_ENABLED - Enable UART0 instance // <o> NRFX_UART0_ENABLED - Enable UART0 instance
#ifndef NRFX_UART0_ENABLED #ifndef NRFX_UART0_ENABLED
#define NRFX_UART0_ENABLED 1 #define NRFX_UART0_ENABLED 0
#endif #endif
// <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control // <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control
@ -5631,13 +5631,13 @@
#ifndef UART_LEGACY_SUPPORT #ifndef UART_LEGACY_SUPPORT
#define UART_LEGACY_SUPPORT 1 #define UART_LEGACY_SUPPORT 0
#endif #endif
// <e> UART0_ENABLED - Enable UART0 instance // <e> UART0_ENABLED - Enable UART0 instance
//========================================================== //==========================================================
#ifndef UART0_ENABLED #ifndef UART0_ENABLED
#define UART0_ENABLED 1 #define UART0_ENABLED 0
#endif #endif
// <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA // <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA

View File

@ -3804,20 +3804,20 @@
// <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver // <e> NRFX_TWIM_ENABLED - nrfx_twim - TWIM peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_TWIM_ENABLED #ifndef NRFX_TWIM_ENABLED
#define NRFX_TWIM_ENABLED 1 #define NRFX_TWIM_ENABLED 0
#endif #endif
// <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance // <q> NRFX_TWIM0_ENABLED - Enable TWIM0 instance
#ifndef NRFX_TWIM0_ENABLED #ifndef NRFX_TWIM0_ENABLED
#define NRFX_TWIM0_ENABLED 1 #define NRFX_TWIM0_ENABLED 0
#endif #endif
// <q> NRFX_TWIM1_ENABLED - Enable TWIM1 instance // <q> NRFX_TWIM1_ENABLED - Enable TWIM1 instance
#ifndef NRFX_TWIM1_ENABLED #ifndef NRFX_TWIM1_ENABLED
#define NRFX_TWIM1_ENABLED 1 #define NRFX_TWIM1_ENABLED 0
#endif #endif
// <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency // <o> NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY - Frequency
@ -4316,11 +4316,11 @@
// <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver // <e> NRFX_UART_ENABLED - nrfx_uart - UART peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_UART_ENABLED #ifndef NRFX_UART_ENABLED
#define NRFX_UART_ENABLED 1 #define NRFX_UART_ENABLED 0
#endif #endif
// <o> NRFX_UART0_ENABLED - Enable UART0 instance // <o> NRFX_UART0_ENABLED - Enable UART0 instance
#ifndef NRFX_UART0_ENABLED #ifndef NRFX_UART0_ENABLED
#define NRFX_UART0_ENABLED 1 #define NRFX_UART0_ENABLED 0
#endif #endif
// <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control // <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control
@ -5645,13 +5645,13 @@
#ifndef UART_LEGACY_SUPPORT #ifndef UART_LEGACY_SUPPORT
#define UART_LEGACY_SUPPORT 1 #define UART_LEGACY_SUPPORT 0
#endif #endif
// <e> UART0_ENABLED - Enable UART0 instance // <e> UART0_ENABLED - Enable UART0 instance
//========================================================== //==========================================================
#ifndef UART0_ENABLED #ifndef UART0_ENABLED
#define UART0_ENABLED 1 #define UART0_ENABLED 0
#endif #endif
// <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA // <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA

View File

@ -52,7 +52,7 @@
extern "C" { extern "C" {
#endif #endif
#include "nrf_uart.h" #include "nrf_uarte.h"
#if defined(FEATURE_CRYPTOCELL310) #if defined(FEATURE_CRYPTOCELL310)
#include "objects_cryptocell.h" #include "objects_cryptocell.h"
@ -68,9 +68,9 @@ struct serial_s {
uint32_t rx; uint32_t rx;
uint32_t cts; uint32_t cts;
uint32_t rts; uint32_t rts;
nrf_uart_hwfc_t hwfc; nrf_uarte_hwfc_t hwfc;
nrf_uart_parity_t parity; nrf_uarte_parity_t parity;
nrf_uart_baudrate_t baudrate; nrf_uarte_baudrate_t baudrate;
uint32_t context; uint32_t context;
uint32_t handler; uint32_t handler;
uint32_t mask; uint32_t mask;

View File

@ -42,7 +42,6 @@
#include "nrf_uarte.h" #include "nrf_uarte.h"
#include "nrfx_uarte.h" #include "nrfx_uarte.h"
#include "nrfx_uart.h"
#include "nrf_atfifo.h" #include "nrf_atfifo.h"
#include "app_util_platform.h" #include "app_util_platform.h"
#include "pinmap_ex.h" #include "pinmap_ex.h"
@ -53,8 +52,8 @@
#include "platform/mbed_atomic.h" #include "platform/mbed_atomic.h"
#include "platform/mbed_critical.h" #include "platform/mbed_critical.h"
#if UART0_ENABLED == 0 #if !NRFX_CHECK(NRFX_UARTE_ENABLED) || !(NRFX_CHECK(NRFX_UARTE0_ENABLED) || NRFX_CHECK(NRFX_UARTE1_ENABLED))
#error UART0 is disabled. DEVICE_SERIAL must also be disabled to continue. #error No enabled UARTE instances, DEVICE_SERIAL must also be disabled to continue.
#endif #endif
@ -456,7 +455,7 @@ static void nordic_nrf5_uart_event_handler_rxstarted(int instance)
uint8_t next_bank = nordic_nrf5_uart_state[instance].active_bank ^ 0x01; uint8_t next_bank = nordic_nrf5_uart_state[instance].active_bank ^ 0x01;
nrf_uarte_rx_buffer_set(nordic_nrf5_uart_register[instance], nordic_nrf5_uart_state[instance].buffer[next_bank], DMA_BUFFER_SIZE); nrf_uarte_rx_buffer_set(nordic_nrf5_uart_register[instance], nordic_nrf5_uart_state[instance].buffer[next_bank], DMA_BUFFER_SIZE);
if (nordic_nrf5_uart_state[instance].rts != NRF_UART_PSEL_DISCONNECTED) { if (nordic_nrf5_uart_state[instance].rts != NRF_UARTE_PSEL_DISCONNECTED) {
if (nordic_nrf5_uart_state[instance].fifo_free_count > FIFO_MIN) { if (nordic_nrf5_uart_state[instance].fifo_free_count > FIFO_MIN) {
/* Clear rts since we are ready to receive the next byte */ /* Clear rts since we are ready to receive the next byte */
nrfx_gpiote_clr_task_trigger(nordic_nrf5_uart_state[instance].rts); 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)
#endif #endif
/* Configure Tx and Rx pins. */ /* Configure Tx and Rx pins. */
if (uart_object->tx != NRF_UART_PSEL_DISCONNECTED) { if (uart_object->tx != NRF_UARTE_PSEL_DISCONNECTED) {
nrf_gpio_pin_set(uart_object->tx); nrf_gpio_pin_set(uart_object->tx);
nrf_gpio_cfg_output(uart_object->tx); nrf_gpio_cfg_output(uart_object->tx);
} }
if (uart_object->rx != NRF_UART_PSEL_DISCONNECTED) { if (uart_object->rx != NRF_UARTE_PSEL_DISCONNECTED) {
nrf_gpio_cfg_input(uart_object->rx, NRF_GPIO_PIN_NOPULL); nrf_gpio_cfg_input(uart_object->rx, NRF_GPIO_PIN_NOPULL);
} }
@ -612,17 +611,17 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
uart_object->rx); uart_object->rx);
/* Set hardware flow control pins. */ /* Set hardware flow control pins. */
if (uart_object->hwfc == NRF_UART_HWFC_ENABLED) { if (uart_object->hwfc == NRF_UARTE_HWFC_ENABLED) {
/* Check if pin is set before configuring it. */ /* Check if pin is set before configuring it. */
if (uart_object->cts != NRF_UART_PSEL_DISCONNECTED) { if (uart_object->cts != NRF_UARTE_PSEL_DISCONNECTED) {
nrf_gpio_cfg_input(uart_object->cts, NRF_GPIO_PIN_NOPULL); nrf_gpio_cfg_input(uart_object->cts, NRF_GPIO_PIN_NOPULL);
} }
/* Only let UARTE module handle CTS, RTS is handled manually due to buggy UARTE logic. */ /* Only let UARTE module handle CTS, RTS is handled manually due to buggy UARTE logic. */
nrf_uarte_hwfc_pins_set(nordic_nrf5_uart_register[uart_object->instance], nrf_uarte_hwfc_pins_set(nordic_nrf5_uart_register[uart_object->instance],
NRF_UART_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED,
uart_object->cts); uart_object->cts);
} }
@ -635,12 +634,12 @@ static void nordic_nrf5_uart_configure_object(serial_t *obj)
MBED_ASSERT(ret == NRF_SUCCESS); MBED_ASSERT(ret == NRF_SUCCESS);
/* Free flow control gpiote pin if it was previously set */ /* Free flow control gpiote pin if it was previously set */
if (nordic_nrf5_uart_state[uart_object->instance].rts != NRF_UART_PSEL_DISCONNECTED) { if (nordic_nrf5_uart_state[uart_object->instance].rts != NRF_UARTE_PSEL_DISCONNECTED) {
nrfx_gpiote_out_uninit((nrfx_gpiote_pin_t)uart_object->rts); nrfx_gpiote_out_uninit((nrfx_gpiote_pin_t)uart_object->rts);
} }
/* Allocate and enable flow control gpiote pin if it is being used */ /* Allocate and enable flow control gpiote pin if it is being used */
if (uart_object->rts != NRF_UART_PSEL_DISCONNECTED) { if (uart_object->rts != NRF_UARTE_PSEL_DISCONNECTED) {
static const nrfx_gpiote_out_config_t config = { static const nrfx_gpiote_out_config_t config = {
.init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH, .init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH,
@ -868,7 +867,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
MBED_ASSERT(ret == NRF_SUCCESS); MBED_ASSERT(ret == NRF_SUCCESS);
/* Clear RTS */ /* Clear RTS */
nordic_nrf5_uart_state[0].rts = NRF_UART_PSEL_DISCONNECTED; nordic_nrf5_uart_state[0].rts = NRF_UARTE_PSEL_DISCONNECTED;
/* Clear any old events and enable interrupts for UARTE0. */ /* Clear any old events and enable interrupts for UARTE0. */
nrf_uarte_int_disable(nordic_nrf5_uart_register[0], 0xFFFFFFFF); nrf_uarte_int_disable(nordic_nrf5_uart_register[0], 0xFFFFFFFF);
@ -890,7 +889,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
MBED_ASSERT(ret == NRF_SUCCESS); MBED_ASSERT(ret == NRF_SUCCESS);
/* Clear RTS */ /* Clear RTS */
nordic_nrf5_uart_state[1].rts = NRF_UART_PSEL_DISCONNECTED; nordic_nrf5_uart_state[1].rts = NRF_UARTE_PSEL_DISCONNECTED;
/* Clear any old events and enable interrupts for UARTE1. */ /* Clear any old events and enable interrupts for UARTE1. */
nrf_uarte_int_disable(nordic_nrf5_uart_register[1], 0xFFFFFFFF); nrf_uarte_int_disable(nordic_nrf5_uart_register[1], 0xFFFFFFFF);
@ -925,8 +924,8 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
/* Ensure pins are disconnected. */ /* Ensure pins are disconnected. */
nrf_uarte_txrx_pins_set(nordic_nrf5_uart_register[instance], nrf_uarte_txrx_pins_set(nordic_nrf5_uart_register[instance],
NRF_UART_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED,
NRF_UART_PSEL_DISCONNECTED); NRF_UARTE_PSEL_DISCONNECTED);
/* Set maximum baud rate to minimize waiting. */ /* Set maximum baud rate to minimize waiting. */
nrf_uarte_baudrate_set(nordic_nrf5_uart_register[instance], nrf_uarte_baudrate_set(nordic_nrf5_uart_register[instance],
@ -950,7 +949,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
/* Store pins in serial object. */ /* Store pins in serial object. */
if (tx == NC) { if (tx == NC) {
uart_object->tx = NRF_UART_PSEL_DISCONNECTED; uart_object->tx = NRF_UARTE_PSEL_DISCONNECTED;
} else { } else {
uart_object->tx = tx; uart_object->tx = tx;
@ -958,18 +957,18 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
if (rx == NC) { if (rx == NC) {
uart_object->rx = NRF_UART_PSEL_DISCONNECTED; uart_object->rx = NRF_UARTE_PSEL_DISCONNECTED;
} else { } else {
uart_object->rx = rx; uart_object->rx = rx;
} }
/* Set default parity, baud rate, and callback handler. */ /* Set default parity, baud rate, and callback handler. */
uart_object->parity = NRF_UART_PARITY_EXCLUDED; uart_object->parity = NRF_UARTE_PARITY_EXCLUDED;
uart_object->baudrate = NRF_UART_BAUDRATE_9600; uart_object->baudrate = NRF_UARTE_BAUDRATE_9600;
uart_object->cts = NRF_UART_PSEL_DISCONNECTED; uart_object->cts = NRF_UARTE_PSEL_DISCONNECTED;
uart_object->rts = NRF_UART_PSEL_DISCONNECTED; uart_object->rts = NRF_UARTE_PSEL_DISCONNECTED;
uart_object->hwfc = NRF_UART_HWFC_DISABLED; uart_object->hwfc = NRF_UARTE_HWFC_DISABLED;
uart_object->handler = 0; uart_object->handler = 0;
/* The STDIO object is stored in this file. Set the flag once initialized. */ /* 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)
struct serial_s *uart_object = obj; struct serial_s *uart_object = obj;
#endif #endif
nrf_uarte_baudrate_t new_rate = NRF_UART_BAUDRATE_9600; nrf_uarte_baudrate_t new_rate = NRF_UARTE_BAUDRATE_9600;
/* Round down to nearest supported baud rate. */ /* Round down to nearest supported baud rate. */
if (baudrate < 2400) { if (baudrate < 2400) {
@ -1115,14 +1114,14 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
/** /**
* Only force change if parity has changed. * Only force change if parity has changed.
*/ */
if ((uart_object->parity != NRF_UART_PARITY_EXCLUDED) && (parity == ParityNone)) { if ((uart_object->parity != NRF_UARTE_PARITY_EXCLUDED) && (parity == ParityNone)) {
uart_object->parity = NRF_UART_PARITY_EXCLUDED; uart_object->parity = NRF_UARTE_PARITY_EXCLUDED;
uart_object->update = true; uart_object->update = true;
} else if ((uart_object->parity != NRF_UART_PARITY_INCLUDED) && (parity == ParityEven)) { } else if ((uart_object->parity != NRF_UARTE_PARITY_INCLUDED) && (parity == ParityEven)) {
uart_object->parity = NRF_UART_PARITY_INCLUDED; uart_object->parity = NRF_UARTE_PARITY_INCLUDED;
uart_object->update = true; uart_object->update = true;
} }
} }
@ -1148,9 +1147,9 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
/** /**
* Convert Mbed pin names to Nordic pin names. * Convert Mbed pin names to Nordic pin names.
*/ */
uart_object->cts = ((txflow == NC) || (type == FlowControlRTS)) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t) txflow; uart_object->cts = ((txflow == NC) || (type == FlowControlRTS)) ? NRF_UARTE_PSEL_DISCONNECTED : (uint32_t) txflow;
uart_object->rts = ((rxflow == NC) || (type == FlowControlCTS)) ? NRF_UART_PSEL_DISCONNECTED : (uint32_t) rxflow; uart_object->rts = ((rxflow == NC) || (type == FlowControlCTS)) ? NRF_UARTE_PSEL_DISCONNECTED : (uint32_t) rxflow;
uart_object->hwfc = (type == FlowControlNone) ? NRF_UART_HWFC_DISABLED : NRF_UART_HWFC_ENABLED; uart_object->hwfc = (type == FlowControlNone) ? NRF_UARTE_HWFC_DISABLED : NRF_UARTE_HWFC_ENABLED;
/* Force reconfiguration next time object is owner. */ /* Force reconfiguration next time object is owner. */
uart_object->update = true; uart_object->update = true;

View File

@ -647,22 +647,18 @@ static void twim_irq_handler(NRF_TWIM_Type * p_twim, twim_control_block_t * p_cb
p_cb->handler(&event, p_cb->p_context); p_cb->handler(&event, p_cb->p_context);
} }
#if 0
#if NRFX_CHECK(NRFX_TWIM0_ENABLED) #if NRFX_CHECK(NRFX_TWIM0_ENABLED)
void nrfx_twim_0_irq_handler(void) void nrfx_twim_0_irq_handler(void)
{ {
twim_irq_handler(NRF_TWIM0, &m_cb[NRFX_TWIM0_INST_IDX]); twim_irq_handler(NRF_TWIM0, &m_cb[NRFX_TWIM0_INST_IDX]);
} }
#endif #endif
#endif
#if 0
#if NRFX_CHECK(NRFX_TWIM1_ENABLED) #if NRFX_CHECK(NRFX_TWIM1_ENABLED)
void nrfx_twim_1_irq_handler(void) void nrfx_twim_1_irq_handler(void)
{ {
twim_irq_handler(NRF_TWIM1, &m_cb[NRFX_TWIM1_INST_IDX]); twim_irq_handler(NRF_TWIM1, &m_cb[NRFX_TWIM1_INST_IDX]);
} }
#endif #endif
#endif
#endif // NRFX_CHECK(NRFX_TWIM_ENABLED) #endif // NRFX_CHECK(NRFX_TWIM_ENABLED)