Software-based SPI master. More...
#include <SPISoft.h>
Public Member Functions | |
| 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... | |
| void | endTransaction () override |
| 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... | |
| 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 size) override |
| Send/receive a variable-length block of data. More... | |
| void | setDelay (uint8_t delay) |
| Set delay factor for the SCK signal. Impacts SPI speed. More... | |
| bool | loopback (bool enable) override |
| For testing, tie MISO <-> MOSI internally. 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... | |
Constructors | |
| SPISoft () | |
| Default constructor uses same pins as hardware SPI. More... | |
| SPISoft (uint8_t miso, uint8_t mosi, uint8_t sck, uint8_t delay=0) | |
| Specify pins to use plus optional delay. More... | |
| SPISoft (const SpiPins &pins, uint8_t delay=0) | |
| Specify pins plus optional delay. More... | |
| SPISoft (uint8_t delay) | |
| Use default pins but provide a delay. More... | |
Public Member Functions inherited from SPIBase | |
| SPIBase (const SpiPins &pins) | |
| virtual | ~SPIBase ()=default |
| void | beginTransaction (SPISettings &settings) |
| Initialize the SPI bus using the defined SPISettings. More... | |
| void | beginTransaction (const SPISettings &settings) |
| 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... | |
| 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... | |
Protected Member Functions inherited from SPIBase | |
| void | assignDefaultPins (const SpiPins &defPins) |
| Assign any default pins. More... | |
Additional Inherited Members | |
Public Attributes inherited from SPIBase | |
| SPISettings | SPIDefaultSettings |
| Default settings used by the SPI bus until reset by beginTransaction(SPISettings) More... | |
| const SpiPins & | pins {mPins} |
Protected Attributes inherited from SPIBase | |
| SpiPins | mPins |
Detailed Description
Software-based SPI master.
Intended for ESP8266 due to limited I/O but will work on any architecture.
Constructor & Destructor Documentation
◆ SPISoft() [1/4]
| SPISoft::SPISoft | ( | ) |
Default constructor uses same pins as hardware SPI.
◆ SPISoft() [2/4]
|
inline |
Specify pins to use plus optional delay.
Delay is ignored if code is not compiled with SPISOFT_DELAY < 0.
◆ SPISoft() [3/4]
|
inline |
Specify pins plus optional delay.
◆ SPISoft() [4/4]
| SPISoft::SPISoft | ( | uint8_t | delay | ) |
Use default pins but provide a delay.
Member Function Documentation
◆ begin()
|
overridevirtual |
Initialize the SPI bus by setting SCK and MOSI to outputs, pulling SCK and MOSI low.
Implements SPIBase.
◆ end()
|
inlineoverridevirtual |
Disable the SPI bus (leaving pin modes unchanged).
Implements SPIBase.
◆ endTransaction()
|
overridevirtual |
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 from SPIBase.
◆ loopback()
|
inlineoverridevirtual |
For testing, tie MISO <-> MOSI internally.
Note: Not included in std Arduino lib
Implements SPIBase.
◆ prepare()
|
overrideprotectedvirtual |
Prepare/configure with settings.
- Parameters
-
settings include frequency, byte order and SPI mode
Implements SPIBase.
◆ setDelay()
|
inline |
Set delay factor for the SCK signal. Impacts SPI speed.
Requires code to be compiled with SPISOFT_DELAY < 0.
ESP8266 only: The delay will be automatically calculated for a requested clock speed when begin() or beginTransaction() are called. To use only the manually programmed delay, set the clock speed to zero.
◆ setup()
|
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:
Public Member Functions inherited from
1.9.1