FastLED 3.9.7
Loading...
Searching...
No Matches
AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > Class Template Reference

Detailed Description

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
class AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >

Software SPI (aka bit-banging) support Includes aggressive optimizations for when the clock and data pin are on the same port.

Template Parameters
DATA_PINpin number of the SPI data pin.
CLOCK_PINpin number of the SPI clock pin.
SPI_SPEEDspeed of the bus. Determines the delay times between pin writes.
Note
Although this is named with the "AVR" prefix, this will work on any platform. Theoretically.
Todo
Replace the select pin definition with a set of pins, to allow using mux hardware for routing in the future.

Definition at line 24 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 setSelect (Selectable *pSelect)
 Set the pointer for the SPI chip select.
 
void init ()
 Set the clock/data pins to output and make sure the chip select is released.
 
void select ()
 Select the SPI output (chip select)
 
void release ()
 Release the SPI chip select line.
 
void writeBytesValue (uint8_t value, int len)
 Write multiple bytes of the given value over SPI.
 
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.
 
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.
 
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 writeWord (uint16_t w)
 Write a word (two bytes) over SPI.
 
static void writeByte (uint8_t b)
 Write a single byte over SPI.
 
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 writeBytesValueRaw (uint8_t value, int len)
 Write multiple bytes of the given value over SPI, without selecting the interface.
 

Constructor & Destructor Documentation

◆ AVRSoftwareSPIOutput() [1/2]

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::AVRSoftwareSPIOutput ( )
inline

Default constructor.

Definition at line 38 of file fastspi_bitbang.h.

◆ AVRSoftwareSPIOutput() [2/2]

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::AVRSoftwareSPIOutput ( Selectable * pSelect)
inline

Constructor with selectable for SPI chip select.

Definition at line 40 of file fastspi_bitbang.h.

Member Function Documentation

◆ init()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::init ( )
inline

Set the clock/data pins to output and make sure the chip select is released.

Definition at line 47 of file fastspi_bitbang.h.

◆ release()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::release ( )
inline

Release the SPI chip select line.

Definition at line 240 of file fastspi_bitbang.h.

◆ select()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::select ( )
inline

Select the SPI output (chip select)

Todo
Research whether this really means 'hi' or 'lo'.
Todo
Move select responsibility out of the SPI classes entirely, make it up to the caller to remember to lock/select the line?

Definition at line 237 of file fastspi_bitbang.h.

◆ setSelect()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::setSelect ( Selectable * pSelect)
inline

Set the pointer for the SPI chip select.

Parameters
pSelectpointer to chip select control

Definition at line 44 of file fastspi_bitbang.h.

◆ stop()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::stop ( )
inlinestatic

Stop the SPI output.

Pretty much a NOP with software, as there's no registers to kick

Definition at line 57 of file fastspi_bitbang.h.

◆ wait()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::wait ( )
inlinestatic

Wait until the SPI subsystem is ready for more data to write.

A NOP when bitbanging.

Definition at line 61 of file fastspi_bitbang.h.

◆ waitFully()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::waitFully ( )
inlinestatic

Wait until the SPI subsystem is ready for more data to write.

A NOP when bitbanging.

Definition at line 63 of file fastspi_bitbang.h.

◆ writeBit()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
template<uint8_t BIT>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeBit ( uint8_t b)
inlinestatic

Write the BIT'th bit out via SPI, setting the data pin then strobing the clock.

Template Parameters
BITthe bit index in the byte
Parameters
bthe byte to read the bit from

Definition at line 151 of file fastspi_bitbang.h.

◆ writeByte()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeByte ( uint8_t b)
inlinestatic

Write a single byte over SPI.

Naive implelentation, simply calls writeBit() on the 8 bits in the byte.

Definition at line 75 of file fastspi_bitbang.h.

◆ writeByteNoWait()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeByteNoWait ( uint8_t b)
inlinestatic

Write a single byte over SPI without waiting.

Definition at line 66 of file fastspi_bitbang.h.

◆ writeBytePostWait()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeBytePostWait ( uint8_t b)
inlinestatic

Write a single byte over SPI and wait afterwards.

Definition at line 68 of file fastspi_bitbang.h.

◆ writeBytes() [1/2]

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
template<class D >
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeBytes ( FASTLED_REGISTER uint8_t * data,
int len )
inline

Write an array of data to the SPI interface.

Template Parameters
DPer-byte modifier class, e.g. DATA_NOP
Parameters
datapointer to data to write
lennumber of bytes to write
Todo
Need to type this better so that explicit casts into the call aren't required.

Definition at line 296 of file fastspi_bitbang.h.

◆ writeBytes() [2/2]

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeBytes ( FASTLED_REGISTER uint8_t * data,
int len )
inline

Write an array of data to the SPI interface.

Parameters
datapointer to data to write
lennumber of bytes to write

Definition at line 343 of file fastspi_bitbang.h.

◆ writeBytesValue()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeBytesValue ( uint8_t value,
int len )
inline

Write multiple bytes of the given value over SPI.

Useful for quickly flushing, say, a line of 0's down the line.

Parameters
valuethe value to write to the bus
lenhow many copies of the value to write

Definition at line 246 of file fastspi_bitbang.h.

◆ writeBytesValueRaw()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeBytesValueRaw ( uint8_t value,
int len )
inlinestatic

Write multiple bytes of the given value over SPI, without selecting the interface.

Useful for quickly flushing, say, a line of 0's down the line.

Parameters
valuethe value to write to the bus
lenhow many copies of the value to write

Definition at line 254 of file fastspi_bitbang.h.

◆ writePixels()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
template<uint8_t FLAGS, class D , EOrder RGB_ORDER>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writePixels ( PixelController< RGB_ORDER > pixels,
void * context = NULL )
inline

Write LED pixel data to the SPI interface.

Data is written in groups of three, re-ordered per the RGB_ORDER.

Template Parameters
FLAGSOption flags, such as FLAG_START_BIT
DPer-byte modifier class, e.g. DATA_NOP
RGB_ORDERthe rgb ordering for the LED data (e.g. what order red, green, and blue data is written out in)
Parameters
pixelsa PixelController with the LED data and modifier options

Definition at line 352 of file fastspi_bitbang.h.

◆ writeWord()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t SPI_SPEED>
static void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writeWord ( uint16_t w)
inlinestatic

Write a word (two bytes) over SPI.

Definition at line 71 of file fastspi_bitbang.h.


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