I have two NRF52840 dev kits that are running what are essentially the spi master and spi slave examples. They both work and I've altered them slightly. I'm just kind of confused by this block of code in the spi slave example:
while (1) { if (spis_xfer_done) { NRF_LOG_FLUSH(); bsp_board_led_invert(BSP_BOARD_LED_1); memset(spi_rx_buf, 0, spi_length); spis_xfer_done = false; APP_ERROR_CHECK(nrf_drv_spis_buffers_set(&spis, spi_tx_buf, spi_length, spi_rx_buf, spi_length)); } }
Why do I need to reset the rx_buf after each transaction? Why can't I have the master keep shifting in data without the slave running memset() and nrf_driv_spis_buffers_set()?
Also just to confirm my understanding of how this works, when a spi transaction comes in, CS goes low, data gets shifted into some buffer in memory. Then CS goes high and an interrupt is triggered (in the slave). When this interrupt is triggered, a handler will read out the data and do whatever I tell it to do with it. Is this using the easyDMA?
Sorry if these are dumb questions, I appreciate all/any help someone can give me.