Using SPI driver with nRF52840 DK and nRF Connect SDK

I'm currently using nRF Connect SDK 1.9.1 and I would like to learn how to use the spi peripheral to talk between another processor acting as the master and my nRF52840 DK as a slave. I have not been able to really find a relevant example anywhere showing me how to accomplish this.

I'm starting with a zephyr/samples/hello_world template for my application. 

In my prj.conf I have:

CONFIG_GPIO=y

CONFIG_SPI=y
CONFIG_SPI_SLAVE=y

I have looked through some of the driver files, but I'm not really sure how to use them, or which ones specifically that I should be using since there are multiple spi files. I'm still pretty new to nRF Connect and was hoping that someone could point me in the right direction to get me started.

Parents
  • I've only had experience with the nordic acting as the master, but if you want an example of the SPI api then take a look at the sensor drivers for some SPI-based sensors like the ICM42605. Most of your communication will take place via the spi_transceive function or the higher-level functions based on spi_transceive from spi.h

    As far as the devicetree goes, just make sure the compatible property on your spi bus is nordic,nrf-spis  for the slave.

    I found an example on github that has a single nrf chip acting as a slave and a master and talking to itself. It uses a newer version of the SDK (2.1.1) so the device tree will handle pins differently with the new pinctrl stuff so that will be different. The SPI driver is the same though, so everything not related to defining the pins should work the same. github.com/.../ncs-spi-master-slave-example

Reply
  • I've only had experience with the nordic acting as the master, but if you want an example of the SPI api then take a look at the sensor drivers for some SPI-based sensors like the ICM42605. Most of your communication will take place via the spi_transceive function or the higher-level functions based on spi_transceive from spi.h

    As far as the devicetree goes, just make sure the compatible property on your spi bus is nordic,nrf-spis  for the slave.

    I found an example on github that has a single nrf chip acting as a slave and a master and talking to itself. It uses a newer version of the SDK (2.1.1) so the device tree will handle pins differently with the new pinctrl stuff so that will be different. The SPI driver is the same though, so everything not related to defining the pins should work the same. github.com/.../ncs-spi-master-slave-example

Children
Related