SPI Component

Installation

The component requires ESP-IDF 5.3 and higher and is installed using IDF Component Manager.

Add this to the idf_component.yml in the project main directory or in the component directory:

dependencies:
  plasmapper/pl_spi: "^1.0.2"

Add this to the source code:

#include "pl_spi.h"

Add extern "C" to the app_main function:

extern "C" void app_main(void) {...}

Add this to the sdkconfig.defaults in the project directory or configure the values using Project Configuration:

CONFIG_COMPILER_CXX_RTTI=y

Features

  1. PL::Spi - an SPI interface class that is used for several SPI controllers that use the same interface. PL::Spi::Initialize() initializes the SPI interface. A number of Set methods can be used to set the SPI interface parameters before its initialization.

  2. PL::SpiController - an SPI controller class that is used for communication with a single SPI target. PL::SpiController::Initialize() initializes the SPI interface and the SPI controller. A number of Set methods can be used to set the SPI controller parameters before its initialization. PL::SpiController::Transaction() executes an SPI transaction.

SPI target and DMA transactions are not implemented yet.

Thread safety

Class method thread safety is implemented by having the PL::Lockable as a base class and creating the class object lock guard at the beginning of the methods.

PL::SpiController::Initialize() and :PL::SpiController::Transaction() lock both the PL::SpiController and the PL::Spi objects for the duration of the method.

Examples

API reference