This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

APP_UART_FIFO_INIT crashes

I am trying to set up fifo'ed uart. However, APP_UART_FIFO_INIT crashes with an error value 8. I traked back the reason into this nrf driver code fragment:

ret_code_t nrf_drv_uart_init(const nrf_drv_uart_t * p_instance, nrf_drv_uart_config_t const * p_config,
                             nrf_uart_event_handler_t event_handler)
{
    ASSERT(p_config);
    uart_control_block_t * p_cb = &m_cb[p_instance->drv_inst_idx];

    if (p_cb->state != NRF_DRV_STATE_UNINITIALIZED)
    {
        debugln("nrf_drv_uart_init: inv state");
        return NRF_ERROR_INVALID_STATE;
    }

However, I do not understand the reason. I have copied the APP_UART_FIFO_INIT code from sdk example, and there is no other initializations before that. So, what is wrong with this? My code is as follows:

uint32_t err_code;
const app_uart_comm_params_t comm_params =
{ rxdPin, txdPin, rtsPin, ctsPin, hardwareFlowControl, .use_parity = false, speed
};
debugln("initializing fifo");
APP_UART_FIFO_INIT(
  &comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOW, err_code);
debuglnf("ret=%d", err_code);
APP_ERROR_CHECK(err_code);

And the err_code is 8 there, as I already said.

Related