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

SPI blocking or nonblocking?

Just to make sure: Will The spi_master_send_recv return when it is done writing and reading, or do you have to have some event wait functionality listening to SPI_MASTER_EVT_TRANSFER_COMPLETED ? I guess it is blocking because you have an output buffer as well...

I am going to do large burst reads having <= 24576 bytes. Is it even possible to read that much in one go memory wise?

Thanks!

Parents
  • The spi_master_send_recv function will only transmit first bytes to start the transaction and then return. This is non blocking.

    After the bytes are received for the transmitted first bytes then the rest of the transaction happens in the interrupt context. When the interrupt context has started for the first time you get a SPI_MASTER_EVT_TRANSFER_STARTED event and when the whole transaction is finished then you get SPI_MASTER_EVT_TRANSFER_COMPLETED event.

  • In the event callback function that you register using spi_master_evt_handler_reg you can enable a flag (bool) when you get SPI_MASTER_EVT_TRANSFER_COMPLETED. You can wait for this flag to be set in your main context. You can even sleep as the event handler callback is called in interrupt context so the chip will wake up after completion. Make sure you use WFE instead of WFI

Reply Children
No Data
Related