Hi
I'm using SDK version15.2 and SD on a custom board based on nRF52840.
The board has two serial ports, and I want to use both independently. Using the Serial Port Library Example with two UARTEs example: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v13.0.0%2Fserial_example.html and modifying it to use NRF_SERIAL_MODE_IRQ and custom pin numbers (different for the two ports), I have this code:
static void serial_cb(struct nrf_serial_s const *p_serial, nrf_serial_event_t event);
static void serial1_cb(struct nrf_serial_s const *p_serial, nrf_serial_event_t event);
NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart0_drv_config,
RX_PIN_NUMBER, TX_PIN_NUMBER,
RTS_PIN_NUMBER, CTS_PIN_NUMBER,
NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
NRF_UART_BAUDRATE_115200,
UART_DEFAULT_CONFIG_IRQ_PRIORITY);
NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart1_drv_config,
RX1_PIN_NUMBER, TX1_PIN_NUMBER,
RTS1_PIN_NUMBER, CTS1_PIN_NUMBER,
NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
NRF_UART_BAUDRATE_115200,
UART_DEFAULT_CONFIG_IRQ_PRIORITY);
#define SERIAL_FIFO_TX_SIZE 100
#define SERIAL_FIFO_RX_SIZE 100
NRF_SERIAL_QUEUES_DEF(serial_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);
NRF_SERIAL_QUEUES_DEF(serial1_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);
#define SERIAL_BUFF_TX_SIZE 1
#define SERIAL_BUFF_RX_SIZE 1
NRF_SERIAL_BUFFERS_DEF(serial_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);
NRF_SERIAL_BUFFERS_DEF(serial1_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);
NRF_SERIAL_CONFIG_DEF(serial_config, NRF_SERIAL_MODE_IRQ, &serial_queues, &serial_buffs, serial_cb, NULL);
NRF_SERIAL_CONFIG_DEF(serial1_config, NRF_SERIAL_MODE_IRQ, &serial1_queues, &serial1_buffs, serial1_cb, NULL);
NRF_SERIAL_UART_DEF(serial_uart, 0);
NRF_SERIAL_UART_DEF(serial1_uart, 1);
When I'm initializing the serial ports with this code:
err_code = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config);
APP_ERROR_CHECK(err_code);
err_code = nrf_serial_init(&serial1_uart, &m_uart1_drv_config, &serial1_config);
APP_ERROR_CHECK(err_code);
... Fatal error ! ... or more specific "NRFX_ERROR_INVALID_STATE" originating from nrfx_uart_init() in nrfx_uart.c. examining the function it enters these statements:
if (p_cb->state != NRFX_DRV_STATE_UNINITIALIZED)
{
err_code = NRFX_ERROR_INVALID_STATE;
NRFX_LOG_WARNING("Function: %s, error code: %s.",
__func__,
NRFX_LOG_ERROR_STRING_GET(err_code));
return err_code;
}
So it seems that uart is already initialized? why? Any ideas what can be wrong?