I'm trying to get a third party demo application working and I seem to be having an issue with the nrfx_spi_xfer function getting stuck waiting for the NRF_SPI_EVENT_READY flag.
I'm not using a callback so my init function looks like this
nrfx_spi_init(&spi0, &spi_config, NULL, NULL);
Since I'm not using a callback, it seems that nrfx_spi_xfer will basically just call the spi_xfer function. This function clears the NRF_SPI_EVENT_READY flag upon entry. Then starts the transfer and waits for the flag to be set. I suspect that there is a slight race condition here.
The third party application code has an interrupt that writes a byte over SPI. This interrupt happened to trigger while it was currently in the nrf_spi_event_check function. I've stepped through and found that just before the call to nrfx_spi_xfer from the interrupt, the NRF_SPI_EVENT_READY flag appears as though it would've been set (I'm not 100% sure of that). Then the spi_xfer function clears it for the new transfer, yet the old transfer is still "using" the spi bus. The code is then stuck waiting for the NRF_SPI_EVENT_READY flag again. Once in the original nrfx_spi_xfer call and another time in the interrupt's nrfx_spi_xfer call.
I know an option is to just pass in a callback so that the code can be thread safe. However, as I mentioned, this is a third party application I'm trying to integrate and I would like to get it working as is. I was thinking the NRFX SPI interface shouldn't behave this way, but this is the first time using it so my expectations might be different.