#include <SPIBase.h>
Public Member Functions | |
SPIBase (const SpiPins &pins) | |
virtual | ~SPIBase () |
virtual bool | begin ()=0 |
Initialize the SPI bus by setting SCK and MOSI to outputs, pulling SCK and MOSI low. 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... | |
void | write (uint8_t data) |
void | write16 (uint16_t data) |
void | write32 (uint32_t data) |
virtual uint8_t | read8 () |
Read one byte from SPI without setting up registers. More... | |
virtual bool | loopback (bool enable)=0 |
For testing, tie MISO <-> MOSI internally. 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 byte 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... | |
const SpiPins & | pins {mPins} |
Protected Member Functions | |
virtual void | prepare (SPISettings &settings)=0 |
Prepare/configure with settings. More... | |
void | assignDefaultPins (const SpiPins &defPins) |
Assign any default pins. More... | |
Protected Attributes | |
SpiPins | mPins |
Constructor & Destructor Documentation
◆ SPIBase()
|
inline |
◆ ~SPIBase()
|
inlinevirtual |
Member Function Documentation
◆ assignDefaultPins()
|
inlineprotected |
Assign any default pins.
◆ begin()
|
pure virtual |
◆ beginTransaction() [1/2]
|
inline |
◆ beginTransaction() [2/2]
|
inline |
Initialize the SPI bus using the defined SPISettings.
◆ end()
|
pure virtual |
◆ 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.
Reimplemented in SPISoft.
◆ loopback()
◆ prepare()
|
protectedpure virtual |
◆ read8()
|
inlinevirtual |
Read one byte from SPI without setting up registers.
- Parameters
-
none
- Return values
-
byte received
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.
◆ transfer() [1/2]
◆ transfer() [2/2]
Send/receive one byte of data.
- Parameters
-
val The byte to send
- Return values
-
uint8_t The received byte
◆ transfer16()
Send/receive one 16-bit word of data.
- Parameters
-
val The word to send
- Return values
-
uint16_t The received word
Word is transferred either MSB first (bit 15) or LSB first (bit 0) depending on the currently applied bitOrder setting.
◆ transfer32()
|
inlinevirtual |
◆ write()
|
inline |
◆ write16()
|
inline |
◆ write32()
|
inline |
Member Data Documentation
◆ mPins
|
protected |
◆ pins
◆ 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: