PL::SpiController class
-
class SpiController : public PL::Lockable
SPI controller class.
Public Functions
Creates an SPI controller.
- Parameters:
spi – SPI interface
mode – SPI mode (0, 1, 2 or 3)
sclkFrequency – SCLK frequency in Hz
csPin – CS pin
-
virtual esp_err_t Lock(TickType_t timeout = portMAX_DELAY) override
Locks the object.
- Parameters:
timeout – timeout in FreeRTOS ticks
- Returns:
error code
-
virtual esp_err_t Unlock() override
Unlocks the object.
- Returns:
error code
-
esp_err_t Initialize()
Initializes the controller.
- Returns:
error code
-
esp_err_t Transaction(uint16_t command, uint64_t address, const void *writeData, void *readData, size_t dataSize)
Executes SPI controller transaction. Uses polling transmission, which blocks for the full duration of the transaction instead of yielding to other tasks, so it is best suited to short transactions.
- Parameters:
command – command bits
address – address bits
writeData – data bits to write to the target (can be NULL)
readData – data bits read from the target (can be NULL)
dataSize – data size in bits
- Returns:
error code
-
esp_err_t SetNumberOfCommandBits(int numberOfCommandBits)
Sets the number of command bits (first written bits before read, may be called only before Initialize)
- Parameters:
numberOfCommandBits – number of command bits (0..maxNumberOfCommandBits)
- Returns:
error code
-
esp_err_t SetNumberOfAddressBits(int numberOfAddressBits)
Sets the number of address bits (bits written after command bits before read, may be called only before Initialize)
- Parameters:
numberOfAddressBits – number of address bits (0..maxNumberOfAddressBits)
- Returns:
error code
-
esp_err_t SetMaxSclkMisoDelay(int delay)
Sets the max delay between the SCLK edge and the valid MISO level (may be called only before Initialize)
- Parameters:
delay – delay in ns
- Returns:
error code