Hello, We are sharing SPI and we found possible bug in nrf_drv_spi....
The problem was that first SPI is using blocking SPI thus does not use ISR and set it to NULL:
nrf_drv_spi_init(&spi, &spi_config, NULL)
Then I try to reuse SPI and I call
nrf_drv_spi_uninit(&g_spi);
nrf_drv_spi_init(&g_spi, &g_spi_config, spi_event_handler)
But the problem is that interrupt EVENTS_END
is pending and as soon as I init SPI I get interrupt that SPI trasfer was done. My handler is called and it reacts to end of transfer. Which breaks the protocol and everything....
I think that EVENTS_END
shall be called by driver either in function nrf_drv_spi_uninit()
or maybe in function nrf_drv_spi_init()
.
What do you think?
Can you fix it in future SDK?
So far workaround and correct init shall be:
nrf_spim_event_clear((NRF_SPIM_Type*)g_spi.p_registers, NRF_SPIM_EVENT_END);
nrf_drv_spi_init(&g_spi, &g_spi_config, spi_event_handler)