PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
NeoPixel Data Transfer Internals

Macros

#define NPDATA_FRAME_IDX_DEFAULT   (0U)
 Default value for npdata_frame_idx.
 
#define NPDATA_COLOR_BIT_DEFAULT   (NPDATA_SHIFT_REG_MASK)
 Default value for npdata_color_bit.
 
#define NPDATA_SHIFT_REG_MASK   (UINT32_C(1) << (NEOPIXEL_COLOR_BITS - 1))
 Mask for selecting the current data bit when converting color bytes to timing data.
 

Functions

static void push_data_to_buffer (uint32_t *const p_block)
 Push new data to the secondary (or primary) buffer. More...
 
static volatile uint32_t npdata_gpt_buffer[2][(8U)] __attribute__ ((aligned(4)))
 GPT compare ping-pong buffer for generating NeoPixel timing waveforms.
 
volatile color_rgb_tnpdata_frame_buffer_get (void)
 Gets a pointer to the frame buffer. More...
 
void npdata_frame_send (void)
 Kicks off a frame transmission to the attached NeoPixels.
 
void npdata_open (void)
 Opens the peripherals needed for data transmission to the NeoPixels.
 
void npdata_color_set (uint32_t index, color_rgb_t const *const p_color)
 Copies a color to the specified index of the frame buffer. More...
 
transfer_status_t npdata_status_get (void)
 Gets the current status of the NeoPixel data transfer. More...
 

Variables

volatile color_rgb_t g_npdata_frame [(4U)] = {0}
 NeoPixel frame buffer.
 
static uint32_t npdata_frame_cnt = 0
 
static uint32_t npdata_frame_idx = (0U)
 Current NeoPixel index to write to the buffers.
 
static uint32_t npdata_color_bit = ( (UINT32_C(1) << (NEOPIXEL_COLOR_BITS - 1)) )
 Current bit to write to the buffers.
 
static uint32_t npdata_color_word = 0U
 Current full shift-register word for the color being written.
 
static uint32_t npdata_b0_counts = 0
 Timer counts for the high period of a 0-bit.
 
static uint32_t npdata_b1_counts = 0
 Timer counts for the high period of a 1-bit.
 

ISR functions and callbacks

void dmac0_repeat_isr (void)
 DMAC_INT ISR handler. More...
 
void npdata_transfer_callback (dmac_callback_args_t *p_args)
 DMAC interrupt callback; unused. More...
 

Detailed Description

Operation

A pulse-code waveform is transmitted at 800 kHz. To achieve this, the Capture Compare B channel is utilized. The DMAC is configured to ping-pong between two buffers and set the timing data to the capture compare of the GPT. Using ping-pong buffering allows an overall smaller buffer footprint since the timing data can be calculated on the fly for each NeoPixel. Otherwise a buffer would be needed that is 24 uint32 words for each NeoPixel.

Function Documentation

◆ dmac0_repeat_isr()

void dmac0_repeat_isr ( void  )

DMAC_INT ISR handler.

Note
This overrides the built-in FSP DMAC ISR.

This is setup to trigger on each repeat size completion.

◆ npdata_color_set()

void npdata_color_set ( uint32_t  index,
color_rgb_t const *const  p_color 
)

Copies a color to the specified index of the frame buffer.

Parameters
indexThe index to write.
[in]p_colorPointer to the color to copy.

◆ npdata_frame_buffer_get()

volatile color_rgb_t * npdata_frame_buffer_get ( void  )

Gets a pointer to the frame buffer.

Warning
Do not write to the frame buffer while npdata_status_get() returns TRANSFER_STATUS_WORKING.

◆ npdata_status_get()

transfer_status_t npdata_status_get ( void  )

Gets the current status of the NeoPixel data transfer.

Return values
TRANSFER_STATUS_IDLENo transfers are active.
TRANSFER_STATUS_WORKINGData is currently being transferred.

◆ npdata_transfer_callback()

void npdata_transfer_callback ( dmac_callback_args_t *  p_args)

DMAC interrupt callback; unused.

Parameters
p_argsPointer to callback arguments.
Note
This is unused and is present as a formality to enable the FSP driver to configure the interrupt; see dmac_repeat_isr.

◆ push_data_to_buffer()

static void push_data_to_buffer ( uint32_t *const  p_block)
inlinestatic

Push new data to the secondary (or primary) buffer.

Parameters
[in]p_blockPointer to the block to write the data to.