#include <SPIBase.h>

Inheritance diagram for SPIBase:
[legend]
Collaboration diagram for SPIBase:
[legend]

Public Member Functions

virtual ~SPIBase ()
 
virtual bool begin ()=0
 Initialize the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high. More...
 
virtual void end ()=0
 Disable the SPI bus (leaving pin modes unchanged). More...
 
void beginTransaction (SPISettings &settings)
 Initialize the SPI bus using the defined SPISettings. More...
 
void beginTransaction (const SPISettings &settings)
 
virtual void endTransaction ()
 Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus. More...
 
virtual uint8_t read8 ()
 Read one byte from SPI without setting up registers. More...
 
Send/receive some data

SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16). In case of buffer transfers the received data is stored in the buffer in-place (the old data is replaced with the data received).

    receivedVal = SPI.transfer(val)
    receivedVal16 = SPI.transfer16(val16)
    SPI.transfer(buffer, size)
uint8_t transfer (uint8_t val)
 Send/receive one bytes of data. More...
 
uint16_t transfer16 (uint16_t val)
 Send/receive one 16-bit word of data. More...
 
virtual uint32_t transfer32 (uint32_t val, uint8_t bits=32)
 Send/receive a word of variable size. More...
 
virtual void transfer (uint8_t *buffer, size_t size)=0
 Send/receive a variable-length block of data. More...
 

Public Attributes

SPISettings SPIDefaultSettings
 Default settings used by the SPI bus until reset by beginTransaction(SPISettings) More...
 

Protected Member Functions

virtual void prepare (SPISettings &settings)=0
 Prepare/configure with settings. More...
 

Constructor & Destructor Documentation

◆ ~SPIBase()

virtual SPIBase::~SPIBase ( )
inlinevirtual

Member Function Documentation

◆ begin()

virtual bool SPIBase::begin ( )
pure virtual

Initialize the SPI bus by setting SCK, MOSI, and SS to outputs, pulling SCK and MOSI low, and SS high.

Implemented in SPIClass, SPIClass, SPIClass, and SPISoft.

◆ beginTransaction() [1/2]

void SPIBase::beginTransaction ( SPISettings settings)
inline

Initialize the SPI bus using the defined SPISettings.

◆ beginTransaction() [2/2]

void SPIBase::beginTransaction ( const SPISettings settings)
inline

◆ end()

virtual void SPIBase::end ( )
pure virtual

Disable the SPI bus (leaving pin modes unchanged).

Implemented in SPIClass, SPIClass, SPIClass, and SPISoft.

◆ endTransaction()

virtual void SPIBase::endTransaction ( )
inlinevirtual

Stop using the SPI bus. Normally this is called after de-asserting the chip select, to allow other libraries to use the SPI bus.

◆ prepare()

virtual void SPIBase::prepare ( SPISettings settings)
protectedpure virtual

Prepare/configure with settings.

Parameters
settingsinclude frequency, byte order and SPI mode

Implemented in SPIClass, SPIClass, SPIClass, and SPISoft.

◆ read8()

virtual uint8_t SPIBase::read8 ( )
inlinevirtual

Read one byte from SPI without setting up registers.

Parameters
none
Return values
bytereceived

used for performance tuning when doing continuous reads this method does not reset the registers , so make sure that a regular transfer(data) call was performed

Note: this method is not found on the Arduino API

USE WITH CARE !!

Reimplemented in SPIClass, and SPIClass.

◆ transfer() [1/2]

uint8_t SPIBase::transfer ( uint8_t  val)
inline

Send/receive one bytes of data.

Parameters
valThe byte to send
Return values
uint8_tThe received byte

◆ transfer() [2/2]

virtual void SPIBase::transfer ( uint8_t *  buffer,
size_t  size 
)
pure virtual

Send/receive a variable-length block of data.

Parameters
bufferIN: The data to send; OUT: The received data
sizeNumber of bytes to transfer

Implemented in SPIClass, SPIClass, SPIClass, and SPISoft.

◆ transfer16()

uint16_t SPIBase::transfer16 ( uint16_t  val)
inline

Send/receive one 16-bit word of data.

Parameters
valThe word to send
Return values
uint8_tThe received word

◆ transfer32()

virtual uint32_t SPIBase::transfer32 ( uint32_t  val,
uint8_t  bits = 32 
)
inlinevirtual

Send/receive a word of variable size.

Parameters
valWord to send
bitsNumber of bits to send

SPI transfer is based on a simultaneous send and receive: the received data is returned in receivedVal (or receivedVal16).

    receivedVal = SPI.transfer(val)         : single byte
    receivedVal16 = SPI.transfer16(val16)   : single short

Reimplemented in SPIClass, and SPIClass.

Member Data Documentation

◆ SPIDefaultSettings

SPISettings SPIBase::SPIDefaultSettings

Default settings used by the SPI bus until reset by beginTransaction(SPISettings)

Note: not included in std Arduino lib


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