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

SPI master driver bugs

I found two bugs in the SPI master driver and I'm posting the solution here to benefit anyone else that may run into these bugs. I apologize if these bugs are old news. I'm using a nRF52832 and SDK v11.0.0.

The changes are in nrf_drv_spi.c. Frist, the ASSERTs on lines 519 and 520 in nrf_drv_spi_xfer() fail to compile. I corrected them as follows:

ASSERT((p_xfer_desc->p_tx_buffer != NULL) || (p_xfer_desc->tx_length == 0));
ASSERT((p_xfer_desc->p_rx_buffer != NULL) || (p_xfer_desc->rx_length == 0));

Second, the SPI transfer call blocks if no callback is provided even if the NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER flag is given. My understanding of the flag is that it indicates that no transfer event handler should be called when the transfer is complete. This should not necessarily make the function block, especially when used with the NRF_DRV_SPI_FLAG_HOLD_XFER flag. I corrected this by adding the following if statement at line 489:

if (!(flags & NRF_DRV_SPI_FLAG_NO_XFER_EVT_HANDLER))
{
     /* code from line 489 to 508 */
}

Austin

Related