SPI Device Drivers

  • include/nuttx/spi/spi.h. All structures and APIs needed to work with SPI drivers are provided in this header file.

  • struct spi_ops_s. Each SPI device driver must implement an instance of struct spi_ops_s. That structure defines a call table with the following methods:

  • Binding SPI Drivers. SPI drivers are not normally directly accessed by user code, but are usually bound to another, higher level device driver. See for example, int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi) in drivers/mmcsd/mmcsd_spi.c. In general, the binding sequence is:

    1. Get an instance of struct spi_dev_s from the hardware-specific SPI device driver, and

    2. Provide that instance to the initialization method of the higher level device driver.

  • Examples: drivers/loop.c, drivers/mmcsd/mmcsd_spi.c, drivers/ramdisk.c, etc.