Hardware SPI class. More...
#include <SPI.h>
Public Types | |
using | IoCallback = void(*)(uint16_t c, uint8_t bits, bool read) |
Used for testing purposes only. More... | |
Public Member Functions | |
SPIClass () | |
SPIClass (const SPIClass &)=delete | |
SPIClass & | operator= (const SPIClass &)=delete |
bool | setup (SpiBus id, SpiPins pins={}) |
Alternative to defining bus and pin set in constructor. Use this method to change global SPI instance setup. More... | |
bool | setup (SpiPins pins) |
bool | begin () override |
Initialize the SPI bus by setting SCK and MOSI to outputs, pulling SCK and MOSI low. More... | |
void | end () override |
Disable the SPI bus (leaving pin modes unchanged). More... | |
uint8_t | read8 () override |
Read one byte from SPI without setting up registers. More... | |
uint32_t | transfer32 (uint32_t val, uint8_t bits=32) override |
Send/receive a word of variable size. More... | |
void | transfer (uint8_t *buffer, size_t numberBytes) override |
Send/receive a variable-length block of data. More... | |
bool | loopback (bool enable) override |
For testing, tie MISO <-> MOSI internally. More... | |
void | setDebugIoCallback (IoCallback callback) |
Used for testing purposes only Must be called after begin(). More... | |
uint8_t | transfer (uint8_t val) |
Send/receive one byte of data. More... | |
virtual void | transfer (uint8_t *buffer, size_t size)=0 |
Send/receive a variable-length block of data. More... | |
![]() | |
SPIBase (const SpiPins &pins) | |
virtual | ~SPIBase () |
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) |
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... | |
Protected Member Functions | |
void | prepare (SPISettings &settings) override |
Prepare/configure with settings. More... | |
![]() | |
void | assignDefaultPins (const SpiPins &defPins) |
Assign any default pins. More... | |
Additional Inherited Members | |
![]() | |
SPISettings | SPIDefaultSettings |
Default settings used by the SPI bus until reset by beginTransaction(SPISettings) More... | |
const SpiPins & | pins {mPins} |
![]() | |
SpiPins | mPins |
Detailed Description
Hardware SPI class.
Member Typedef Documentation
◆ IoCallback
using SPIClass::IoCallback = void (*)(uint16_t c, uint8_t bits, bool read) |
Used for testing purposes only.
- Parameters
-
c Value being read/written bits Size of value in bits read true for incoming value, false for outgoing
Constructor & Destructor Documentation
◆ SPIClass() [1/2]
SPIClass::SPIClass | ( | ) |
◆ SPIClass() [2/2]
|
delete |
Member Function Documentation
◆ begin()
|
overridevirtual |
Initialize the SPI bus by setting SCK and MOSI to outputs, pulling SCK and MOSI low.
Implements SPIBase.
◆ end()
|
overridevirtual |
Disable the SPI bus (leaving pin modes unchanged).
Implements SPIBase.
◆ loopback()
|
overridevirtual |
For testing, tie MISO <-> MOSI internally.
Note: Not included in std Arduino lib
Implements SPIBase.
◆ operator=()
◆ prepare()
|
overrideprotectedvirtual |
Prepare/configure with settings.
- Parameters
-
settings include frequency, byte order and SPI mode
Implements SPIBase.
◆ read8()
|
overridevirtual |
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 from SPIBase.
◆ setDebugIoCallback()
void SPIClass::setDebugIoCallback | ( | IoCallback | callback | ) |
Used for testing purposes only Must be called after begin().
Used to verify serialisation/de-searialisation bit ordering
◆ setup() [1/2]
Alternative to defining bus and pin set in constructor. Use this method to change global SPI
instance setup.
IMPORTANT: Must be called before begin().
◆ setup() [2/2]
|
inline |
◆ transfer() [1/3]
|
overridevirtual |
Send/receive a variable-length block of data.
- Parameters
-
buffer IN: The data to send; OUT: The received data size Number of bytes to transfer
Implements SPIBase.
◆ transfer() [2/3]
virtual void SPIBase::transfer |
Send/receive a variable-length block of data.
- Parameters
-
buffer IN: The data to send; OUT: The received data size Number of bytes to transfer
◆ transfer() [3/3]
|
inline |
Send/receive one byte of data.
- Parameters
-
val The byte to send
- Return values
-
uint8_t The received byte
◆ transfer32()
|
overridevirtual |
Send/receive a word of variable size.
- Parameters
-
val Word to send bits Size of word
Word is transferred either MSB first (bits-1) or LSB first (bit 0) depending on the currently applied bitOrder setting.
Reimplemented from SPIBase.
The documentation for this class was generated from the following file: