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.
|
| 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...
|
| |
Contains functions required to communicate with device using SPI protocol.
- Author
- Damian Ćlusarczyk
◆ spi_free()
Frees SPI bus for specific host.
- Parameters
-
- 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
-
| miso | GPIO for MISO pin, or -1 if not used |
| mosi | GPIO for MOSI pin |
| sclk | GPIO for SCLK pin |
| wp | GPIO for WP signal, or -1 if not used |
| hd | GPIO for HD signal, or -1 if not used |
| cs | GPIO for CS pin, or -1 if not used |
| maxTransferSize | Maximum number of bytes available to send using SPI |
| queueSize | Number of data bytes in the SPI queue |
| clockSpeedHz | Desired frequency of SPI bus |
| host | SPI host to initialize |
| dma | SPI DMA channel to initialize |
| spi | Handle 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
-
| spi | Handle for the device on SPI bus |
| dcGpio | GPIO for DC (data/command) pin |
| cmd | Command 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
-
| spi | Handle for the device on SPI bus |
| dcGpio | GPIO for DC (data/command) pin |
| data | Pointer to array of data bytes to be sent |
| dataSize | Number 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
-
| spi | Handle for the device on SPI bus |
| dcGpio | GPIO for DC (data/command) pin |
| data | Data to be sent (exactly 2 bytes) |
- Returns
- spi_error_t Status code of the operation