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

APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));

Hi All,

I am a beginner,Can you please explain me what is the role of this line?

APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));

Parents
  • In short it means that on previously initialized and enabled instance of SPI Master peripheral &spi you call full-duplex bi-directional transfer. All SPI transfers are full-duplex bi-directional by nature, but most applications use them half-duplex meaning that certain part is used only by Master->Slave and the second part for Slave->Master. However this is protocol specific (SPI is just low-level electrical protocol spec). The rest of the call means that you supply Tx and Rx buffers with lengths (these will be used by HAL driver to determine how many bytes should be clocked on SPI_CLK line). And finally whole HAL driver function call is expected to return success, otherwise you send the program to app error handler.

Reply
  • In short it means that on previously initialized and enabled instance of SPI Master peripheral &spi you call full-duplex bi-directional transfer. All SPI transfers are full-duplex bi-directional by nature, but most applications use them half-duplex meaning that certain part is used only by Master->Slave and the second part for Slave->Master. However this is protocol specific (SPI is just low-level electrical protocol spec). The rest of the call means that you supply Tx and Rx buffers with lengths (these will be used by HAL driver to determine how many bytes should be clocked on SPI_CLK line). And finally whole HAL driver function call is expected to return success, otherwise you send the program to app error handler.

Children
No Data
Related