AceSPI  0.1.0
Unified interface for selecting hardware or software SPI implementations on Arduino platforms
Public Member Functions | List of all members
ace_spi::HardSpiInterface< T_SPI > Class Template Reference

Hardware SPI interface to talk to one or two 74HC595 Shift Register chip(s), using the predefined SPI global instance. More...

#include <HardSpiInterface.h>

Public Member Functions

 HardSpiInterface (T_SPI &spi, uint8_t latchPin)
 
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
 Send two 8-bit bytes as a single 16-bit stream, including latching LOW and HIGH.
 

Detailed Description

template<typename T_SPI>
class ace_spi::HardSpiInterface< T_SPI >

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.

The ESP32 has 2 user-accessible SPI buses (HSPI and VSPI), and so does the STM32F1 (SPI1 and SPI2). By default, the predefined SPI instance is used, but a user-defined secondary SPI instance can be passed into the constructor.

Template Parameters
T_SPIthe class of the hardware SPI instance, usually SPIClass

Definition at line 54 of file HardSpiInterface.h.

Member Function Documentation

◆ begin()

template<typename T_SPI >
void ace_spi::HardSpiInterface< T_SPI >::begin ( ) const
inline

Initialize the HardSpiInterface.

The hardware SPI object must be initialized using SPI.begin() as well.

Definition at line 83 of file HardSpiInterface.h.


The documentation for this class was generated from the following file: