AceSegment
0.7.0
A framework for rendering seven segment LED displays using the TM1637, MAX7219, HT16K33, or 74HC595 controller chips
|
Hardware SPI interface to talk to one or two 74HC595 Shift Register chip(s), using the predefined SPI
global instance.
More...
#include <HardSpiFastInterface.h>
Public Member Functions | |
HardSpiFastInterface (T_SPI &spi) | |
void | begin () const |
Initialize the HardSpiInterface. More... | |
void | end () const |
void | send8 (uint8_t value) const |
Send 8 bits, including latching LOW and HIGH. | |
void | send16 (uint16_t value) const |
Send 16 bits, including latching LOW and HIGH. | |
void | send16 (uint8_t msb, uint8_t lsb) const |
Hardware SPI interface to talk to one or two 74HC595 Shift Register chip(s), using the predefined SPI
global instance.
This is currently not meant to be general-purpose SPI interface. 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 SPI speed to 8MHz. It's not clear if the SPI speed is worth making into a configurable parameter. Such a change needs to done a bit carefully, because it should be a template parameter so that SPISettings
is a compile-time constant which allows compile-time optimizations to happen.
This class is functionally identical to HardSpiInterface except that the GPIO pins are controlled by digitalWriteFast() and pinModeFast() methods. This decreases flash memory consumption by 70 bytes (HybridModule) to 250 (Max7219Module, Hc595Module) bytes. However, if multiple LED modules are used, using different LatchPins, the HardSpiInterface might ultimately consume less flash memory because it avoids generating different template instantiations of the HybridModule, Max7219Module, or Hc595Module classes. Users are advised to try both and compare the difference.
T_SPI | the class of the hardware SPI instance, usually SPIClass |
T_LATCH_PIN | the CS/SS pin that controls the SPI peripheral |
Definition at line 60 of file HardSpiFastInterface.h.
|
inline |
Initialize the HardSpiInterface.
The hardware SPI object must be initialized using SPI.begin()
as well.
Definition at line 86 of file HardSpiFastInterface.h.