Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
SpiPixelStrip Class Reference

Public Member Functions

 SpiPixelStrip (SPI_Regs *spi, unsigned num_pixels, uint8_t *backing_data)
 Initializes the SPI peripheral.
 
void hw_init ()
 Opens and initializes the SPI hardware.
 
void update_sync ()
 Updates the hardware from the backing data.
 

Private Member Functions

void clear_iteration ()
 Starts a new iteration over the strip.
 
bool next_bit ()
 
bool eof ()
 

Private Attributes

SPI_Regs * spi_
 SPI peripheral pointer.
 
unsigned numPixels_
 Number of pixels to drive.
 
uint8_t * data_
 Backing framebuffer to use.
 
unsigned currentByte_
 Controls iteration over the data sequence when producing the output.
 
uint8_t nextBit_
 Controls iteration over the data sequence when producing the output.
 

Detailed Description

Definition at line 42 of file MSPM0SpiPixelStrip.hxx.

Constructor & Destructor Documentation

◆ SpiPixelStrip()

SpiPixelStrip::SpiPixelStrip ( SPI_Regs *  spi,
unsigned  num_pixels,
uint8_t *  backing_data 
)
inline

Initializes the SPI peripheral.

Parameters
spithe SPI peripheral instance, e.g. SPI0.
num_pixelsthe number of RGB pixels to drive.
backing_dataarray of 3*num_pixels which stores the RGB data to be sent to the devices. Note that the byte order is G R B in the storage.

Definition at line 51 of file MSPM0SpiPixelStrip.hxx.

Member Function Documentation

◆ clear_iteration()

void SpiPixelStrip::clear_iteration ( )
inlineprivate

Starts a new iteration over the strip.

Call next_bit() repeatedly to get the bits in transmission order.

Definition at line 96 of file MSPM0SpiPixelStrip.hxx.

◆ eof()

bool SpiPixelStrip::eof ( )
inlineprivate
Returns
true when the iteration is at eof of the string.

Definition at line 114 of file MSPM0SpiPixelStrip.hxx.

◆ next_bit()

bool SpiPixelStrip::next_bit ( )
inlineprivate
Returns
true if the next bit in the iteration should be 1.

Definition at line 102 of file MSPM0SpiPixelStrip.hxx.

◆ update_sync()

void SpiPixelStrip::update_sync ( )
inline

Updates the hardware from the backing data.

The update is synchronous, this call returns when all bytes are sent, or at least enqueued in the SPI peripheral's TX FIFO.

Definition at line 63 of file MSPM0SpiPixelStrip.hxx.

Member Data Documentation

◆ currentByte_

unsigned SpiPixelStrip::currentByte_
private

Controls iteration over the data sequence when producing the output.

This is the index of the current byte.

Definition at line 128 of file MSPM0SpiPixelStrip.hxx.

◆ data_

uint8_t* SpiPixelStrip::data_
private

Backing framebuffer to use.

Definition at line 124 of file MSPM0SpiPixelStrip.hxx.

◆ nextBit_

uint8_t SpiPixelStrip::nextBit_
private

Controls iteration over the data sequence when producing the output.

This is the mask of the next bit to use.

Definition at line 131 of file MSPM0SpiPixelStrip.hxx.

◆ numPixels_

unsigned SpiPixelStrip::numPixels_
private

Number of pixels to drive.

Definition at line 122 of file MSPM0SpiPixelStrip.hxx.

◆ spi_

SPI_Regs* SpiPixelStrip::spi_
private

SPI peripheral pointer.

Definition at line 120 of file MSPM0SpiPixelStrip.hxx.


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