My Project
 All Classes Functions Variables Pages
Public Member Functions | Static Public Attributes | List of all members
SPI Class Reference

Handle SPI protocol. More...

#include <SPI.h>

Public Member Functions

 SPI ()
 Construct an instance of the class. More...
 
virtual ~SPI ()
 Class instance destructor.
 
void init (int mosiPin=DEFAULT_MOSI_PIN, int misoPin=DEFAULT_MISO_PIN, int clkPin=DEFAULT_CLK_PIN, int csPin=DEFAULT_CS_PIN)
 Initialize SPI. More...
 
void setHost (spi_host_device_t host)
 Set the SPI host to use. Call this prior to init(). More...
 
void transfer (uint8_t *data, size_t dataLen)
 Send and receive data through SPI. This is a blocking call. More...
 
uint8_t transferByte (uint8_t value)
 Send and receive a single byte. More...
 

Static Public Attributes

static const int DEFAULT_MOSI_PIN = GPIO_NUM_13
 The default MOSI pin.
 
static const int DEFAULT_MISO_PIN = GPIO_NUM_12
 The default MISO pin.
 
static const int DEFAULT_CLK_PIN = GPIO_NUM_14
 The default CLK pin.
 
static const int DEFAULT_CS_PIN = GPIO_NUM_15
 The default CS pin.
 
static const int PIN_NOT_SET = -1
 Value of unset pin.
 

Detailed Description

Handle SPI protocol.

Constructor & Destructor Documentation

SPI::SPI ( )

Construct an instance of the class.

Returns
N/A.

Member Function Documentation

void SPI::init ( int  mosiPin = DEFAULT_MOSI_PIN,
int  misoPin = DEFAULT_MISO_PIN,
int  clkPin = DEFAULT_CLK_PIN,
int  csPin = DEFAULT_CS_PIN 
)

Initialize SPI.

Parameters
[in]mosiPinPin to use for MOSI SPI function.
[in]misoPinPin to use for MISO SPI function.
[in]clkPinPin to use for CLK SPI function.
[in]csPinPin to use for CS SPI function.
Returns
N/A.
void SPI::setHost ( spi_host_device_t  host)

Set the SPI host to use. Call this prior to init().

Parameters
[in]hostThe SPI host to use. Either HSPI_HOST (default) or VSPI_HOST.
void SPI::transfer ( uint8_t *  data,
size_t  dataLen 
)

Send and receive data through SPI. This is a blocking call.

Parameters
[in]dataA data buffer used to send and receive.
[in]dataLenThe number of bytes to transmit and receive.
uint8_t SPI::transferByte ( uint8_t  value)

Send and receive a single byte.

Parameters
[in]valueThe byte to send.
Returns
The byte value received.

The documentation for this class was generated from the following files: