nrfx spis driver initialize using ncs 1.7.1

when ntfx_spis_init() is done , NRFX_ERROR_INVALID_STATE errer  occured.

pcb_state is NRF_DRV_STATE_INITIALIZED.

my code is

int cc3235_spi_init(void)
{
    nrfx_spis_config_t spis_config = NRFX_SPIS_DEFAULT_CONFIG(8,2,3,4) ;
    dev_spis = device_get_binding(DT_LABEL(DT_NODELABEL(spi2))); // dev_spis is device , dev is composed by device and data

 
    k_sem_init( &spis_sem, 1,1) ;

    struct spi_nrfx_data *dev_data = get_dev_data(dev_spis);

    nrfx_err_t result = nrfx_spis_init( &get_dev_config(dev_spis)->spis_inst,
                                         &spis_config, event_handler, dev_data);
}
static void  event_handler(const nrfx_spis_evt_t *p_event, void *p_context)
{
    struct spi_context *ctx = p_context;
    if (p_event->evt_type == NRFX_SPIS_XFER_DONE) {
        //spi_context_complete(&dev_data->ctx, dev_data->dev, p_event->rx_amount);  this function is need?
        ctx->current_rx_cnt = ctx->current_rx_cnt + (p_event->rx_amount );
        ctx->current_tx_cnt = ctx->current_tx_cnt + (p_event->tx_amount );
 
    }
}

Please show me wrong point. 

  • Hello,

    Can you show which sample code you are using as reference if any?

    nrfx_err_t result = nrfx_spis_init( &get_dev_config(dev_spis)->spis_inst,
                                             &spis_config, event_handler, dev_data);

    What is the first argument here? I see that it should be a pointer to the driver instance structure.

Related