Software SPI (aka bit-banging) support Includes aggressive optimizations for when the clock and data pin are on the same port.
DATA_PIN | pin number of the SPI data pin. |
CLOCK_PIN | pin number of the SPI clock pin. |
SPI_SPEED | speed of the bus. Determines the delay times between pin writes. |
Definition at line 26 of file fastspi_bitbang.h.
#include <fastspi_bitbang.h>
Public Member Functions | |
AVRSoftwareSPIOutput () | |
Default constructor. | |
AVRSoftwareSPIOutput (Selectable *pSelect) | |
Constructor with selectable for SPI chip select. | |
void | init () |
Set the clock/data pins to output and make sure the chip select is released. | |
void | release () |
Release the SPI chip select line. | |
void | select () |
Select the SPI output (chip select) | |
void | setSelect (Selectable *pSelect) |
Set the pointer for the SPI chip select. | |
template<class D> | |
void | writeBytes (FASTLED_REGISTER uint8_t *data, int len) |
Write an array of data to the SPI interface. | |
void | writeBytes (FASTLED_REGISTER uint8_t *data, int len) |
Write an array of data to the SPI interface. | |
void | writeBytesValue (uint8_t value, int len) |
Write multiple bytes of the given value over SPI. | |
template<uint8_t FLAGS, class D, EOrder RGB_ORDER> | |
void | writePixels (PixelController< RGB_ORDER > pixels, void *context=NULL) |
Write LED pixel data to the SPI interface. | |
Static Public Member Functions | |
static void | stop () |
Stop the SPI output. | |
static void | wait () |
Wait until the SPI subsystem is ready for more data to write. | |
static void | waitFully () |
Wait until the SPI subsystem is ready for more data to write. | |
template<uint8_t BIT> | |
static void | writeBit (uint8_t b) |
Write the BIT'th bit out via SPI, setting the data pin then strobing the clock. | |
static void | writeByte (uint8_t b) |
Write a single byte over SPI. | |
static void | writeByteNoWait (uint8_t b) |
Write a single byte over SPI without waiting. | |
static void | writeBytePostWait (uint8_t b) |
Write a single byte over SPI and wait afterwards. | |
static void | writeBytesValueRaw (uint8_t value, int len) |
Write multiple bytes of the given value over SPI, without selecting the interface. | |
static void | writeWord (uint16_t w) |
Write a word (two bytes) over SPI. | |
Private Types | |
typedef FastPin< CLOCK_PIN >::port_ptr_t | clock_ptr_t |
typedef FastPin< CLOCK_PIN >::port_t | clock_t |
typedef FastPin< DATA_PIN >::port_ptr_t | data_ptr_t |
typedef FastPin< DATA_PIN >::port_t | data_t |
Static Private Member Functions | |
template<uint8_t BIT> | |
static FASTLED_FORCE_INLINE void | writeBit (uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin) |
Write the BIT'th bit out via SPI, setting the data pin then strobing the clock, using the passed in pin registers to accelerate access if needed. | |
template<uint8_t BIT> | |
static FASTLED_FORCE_INLINE void | writeBit (uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin, data_t hival, data_t loval, clock_t hiclock, clock_t loclock) |
The version of writeBit() to use when clock and data are on separate pins with precomputed values for setting the clock and data pins. | |
template<uint8_t BIT> | |
static FASTLED_FORCE_INLINE void | writeBit (uint8_t b, data_ptr_t clockdatapin, data_t datahiclockhi, data_t dataloclockhi, data_t datahiclocklo, data_t dataloclocklo) |
The version of writeBit() to use when clock and data are on the same port with precomputed values for the various combinations. | |
static void | writeByte (uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin) |
writeByte() implementation with data/clock registers passed in. | |
static void | writeByte (uint8_t b, clock_ptr_t clockpin, data_ptr_t datapin, data_t hival, data_t loval, clock_t hiclock, clock_t loclock) |
writeByte() implementation with not just registers passed in, but pre-baked values for said registers for data hi/lo and clock hi/lo values. | |
static void | writeByte (uint8_t b, data_ptr_t datapin, data_t hival, data_t loval, clock_t hiclock, clock_t loclock) |
writeByte() implementation with the data register passed in and prebaked values for data hi w/clock hi and low and data lo w/clock hi and lo. | |
Private Attributes | |
Selectable * | m_pSelect |
SPI chip select. | |