AceSPI
0.4
Unified interface for selecting hardware or software SPI implementations on Arduino platforms
|
Hardware SPI interface to talk to SPI peripherals. More...
#include <HardSpiInterface.h>
Public Member Functions | |
HardSpiInterface (T_SPI &spi, uint8_t latchPin) | |
Constructor. More... | |
void | begin () const |
Initialize the HardSpiInterface. More... | |
void | end () const |
Clean up the object. | |
void | beginTransaction () const |
Begin SPI transaction. More... | |
void | endTransaction () const |
End SPI transaction. More... | |
void | transfer (uint8_t value) const |
Transfer 8 bits. | |
void | transfer16 (uint16_t value) const |
Transfer 16 bits. | |
void | send8 (uint8_t value) const |
Convenience method to send 8 bits a single transaction. | |
void | send16 (uint16_t value) const |
Convenience method to send 16 bits a single transaction. | |
void | send16 (uint8_t msb, uint8_t lsb) const |
Convenience method to send 16 bits a single transaction. | |
HardSpiInterface (const HardSpiInterface &)=default | |
HardSpiInterface & | operator= (const HardSpiInterface &)=default |
Hardware SPI interface to talk to SPI peripherals.
It was initially created to communicate with the 74HC595 Shift Register chip, then verified to work with the MAX7219 LED controller chip. This is currently not meant to be general-purpose SPI interface. In particular, it supports only SPI MODE0, and MSBFIRST configurations.
For different SPI configurations, it is probably easiest to just copy this file, make the necessary changes, then substitute the new class in places where this class is used. The maximum speed of MAX7219 is 16MHz so this class sets the default SPI speed to 8MHz.
The ESP32 has 2 user-accessible SPI buses (HSPI and VSPI), and so does the STM32F1 (SPI1 and SPI2). Usually, the predefined SPI instance is used, but a user-defined secondary SPI instance can be passed into the constructor.
T_SPI | the class of the hardware SPI instance, usually SPIClass |
T_CLOCK_SPEED | the SPI clock speed, default 8000000 (8 MHz) |
Definition at line 57 of file HardSpiInterface.h.
|
inlineexplicit |
Constructor.
spi | instance of the T_SPI class. If the pre-installed <SPI.h> is used, T_SPI is SPIClass and spi will be the pre-defined SPI object. |
latchPin | the pin that controls the CS/SS pin of the slave device |
Definition at line 82 of file HardSpiInterface.h.
|
inline |
Initialize the HardSpiInterface.
The hardware SPI object must be initialized using SPI.begin()
as well.
Definition at line 91 of file HardSpiInterface.h.
|
inline |
|
inline |