Hi,
I can use the SPI master functionality within nrf_drv_spi.c/.h just fine (i.e. calls from main) until I connect to my nRF52840 and utilize NUS. If I try to issue a nrf_drv_spi_transfer() call from within my NUS data handler (i.e. when handing incoming data over NUS) to read 2 registers from a SPI connected slave (I am the master), I am not getting the expected SPI event handler with event NRF_DRV_SPI_EVENT_DONE when a SPI transfer completes. In the code below, I am calling bmi160_spiReadRegs() from within my NUS data handler. This function is blocking because m_xfer_done is never set to TRUE as a result of spi_event_handler() being called.
If I issue the same SPI read on main using nrf_drv_spi_transfer(), the SPI event handler is called with event NRF_DRV_SPI_EVENT_DONE as expected. But, if I issue the nrf_drv_spi_transfer() from my NUS data handler, my SPI event handler is never called (at all).
I see other references to similar issues on DevZone. For these issues, NUS or SPI priority changes are suggested. I have tried this, but to no avail.
Specifically, I have set NRFX_SPI_DEFAULT_CONFIG_IRQ_PRIORITY to 2 to match NUS, but to no avail. See below.
I have also tried changing the priority of NUS to match SPI. I set it to 6 as below.
Neither of these addressed the issue. If I call nrf_drv_spi_transfer() within my NUS data handler, the SPI event handler is never called with event NRF_DRV_SPI_EVENT_DONE.
This confuses me as the NUS UART example calls UART reads/writes within the NUS data handler and the UART priority is the same as SPI (both 6).
Perhaps this is not priority related?
Help, clues, etc are appreciated.
Thanks,
Mark J