PixelKey
NeoPixel USB Key
Loading...
Searching...
No Matches
hal_npdata_transfer.c File Reference
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include "hal_data.h"
#include "hal_device.h"
#include "hal_tasks.h"
#include "pixelkey.h"
#include "neopixel.h"
#include "config.h"
#include "hal_npdata_transfer.h"

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...
 
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...
 

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.