LCD-ESP32-Driver 1.0
Project includes component for controlling LCD displays. Currently supports only one LCD controller - SSD1283A but it may change in the future.
Loading...
Searching...
No Matches
spi.h File Reference

Contains functions required to communicate with device using SPI protocol. More...

#include "spi_error_codes.h"
#include "driver/spi_master.h"

Go to the source code of this file.

Functions

spi_error_t spi_init (const int miso, const int mosi, const int sclk, const int wp, const int hd, const int cs, const int maxTransferSize, const int queueSize, const int clockSpeedHz, const spi_host_device_t host, const spi_dma_chan_t dma, spi_device_handle_t *const spi)
 Initializes SPI bus and registers the single device on it. More...
 
spi_error_t spi_free (spi_host_device_t host)
 Frees SPI bus for specific host. More...
 
spi_error_t spi_send_cmd (spi_device_handle_t spi, const int dcGpio, const uint8_t cmd)
 Sends command address to the specific device available on the SPI bus. More...
 
spi_error_t spi_send_single_bytes (spi_device_handle_t spi, const int dcGpio, const uint8_t *data, const size_t dataSize)
 Sends data bytes to the specific device available on the SPI bus. More...
 
spi_error_t spi_send_two_bytes (spi_device_handle_t spi, const int dcGpio, uint16_t data)
 Sends exactly two bytes of data to the specific device available on the SPI bus. More...
 

Detailed Description

Contains functions required to communicate with device using SPI protocol.

Author
Damian Úlusarczyk

Function Documentation

◆ spi_free()

spi_error_t spi_free ( spi_host_device_t  host)

Frees SPI bus for specific host.

Parameters
hostSPI host to free
Returns
spi_error_t Status code of the operation

◆ spi_init()

spi_error_t spi_init ( const int  miso,
const int  mosi,
const int  sclk,
const int  wp,
const int  hd,
const int  cs,
const int  maxTransferSize,
const int  queueSize,
const int  clockSpeedHz,
const spi_host_device_t  host,
const spi_dma_chan_t  dma,
spi_device_handle_t *const  spi 
)

Initializes SPI bus and registers the single device on it.

Parameters
misoGPIO for MISO pin, or -1 if not used
mosiGPIO for MOSI pin
sclkGPIO for SCLK pin
wpGPIO for WP signal, or -1 if not used
hdGPIO for HD signal, or -1 if not used
csGPIO for CS pin, or -1 if not used
maxTransferSizeMaximum number of bytes available to send using SPI
queueSizeNumber of data bytes in the SPI queue
clockSpeedHzDesired frequency of SPI bus
hostSPI host to initialize
dmaSPI DMA channel to initialize
spiHandle for the device on SPI bus
Returns
spi_error_t Status code of the operation

◆ spi_send_cmd()

spi_error_t spi_send_cmd ( spi_device_handle_t  spi,
const int  dcGpio,
const uint8_t  cmd 
)

Sends command address to the specific device available on the SPI bus.

Parameters
spiHandle for the device on SPI bus
dcGpioGPIO for DC (data/command) pin
cmdCommand address to be sent
Returns
spi_error_t Status code of the operation

◆ spi_send_single_bytes()

spi_error_t spi_send_single_bytes ( spi_device_handle_t  spi,
const int  dcGpio,
const uint8_t *  data,
const size_t  dataSize 
)

Sends data bytes to the specific device available on the SPI bus.

Parameters
spiHandle for the device on SPI bus
dcGpioGPIO for DC (data/command) pin
dataPointer to array of data bytes to be sent
dataSizeNumber of data bytes included in the array
Returns
spi_error_t Status code of the operation

◆ spi_send_two_bytes()

spi_error_t spi_send_two_bytes ( spi_device_handle_t  spi,
const int  dcGpio,
uint16_t  data 
)

Sends exactly two bytes of data to the specific device available on the SPI bus.

Parameters
spiHandle for the device on SPI bus
dcGpioGPIO for DC (data/command) pin
dataData to be sent (exactly 2 bytes)
Returns
spi_error_t Status code of the operation