![]() |
Serial Wombat 18AB Firmware
|
Classes | |
struct | ws2812 |
Macros | |
#define | ws2812 ((ws2812_t*) CurrentPinRegister) |
#define | dmaBuffer ((uint16_t*)&UserBuffer[ws2812->userBufferIndex]) |
#define | RESET_SIGNAL_LENGTH 2 |
#define | WAIT_UNTIL_SPI_NOT_FULL() { while( SPI1STATLbits.SPITBF == 1 );} |
#define | SPI_1_BIT 0xFC00 |
#define | SPI_0_BIT 0xE000 |
#define | NUMBER_OF_COLORS 6 |
Typedefs | |
typedef struct ws2812 | ws2812_t |
Enumerations | |
enum | ws2812_mode_t { WS2812_MODE_BUFFERED = 0, WS2812_MODE_ANIMATION = 1, WS2812_MODE_CHASE = 2, WS2812_MODE_BARGRAPH = 3 } |
Functions | |
void | ws2812_SPI1_Initialize (void) |
void | ws2812ConfigHardware () |
void | queue1Bit () |
void | queue0Bit () |
void | QueueRGB (uint32_t RGB) |
void | SendResetSignal () |
void | StartDMA () |
void | StopDMA () |
void | initWS2812 (void) |
void | updateWS2812 () |
update the WS2812 pin state machine More... | |
Variables | |
ws2812_t * | debugWS2812 |
uint32_t | ColorTable [] |
#define dmaBuffer ((uint16_t*)&UserBuffer[ws2812->userBufferIndex]) |
#define NUMBER_OF_COLORS 6 |
#define RESET_SIGNAL_LENGTH 2 |
#define SPI_0_BIT 0xE000 |
#define SPI_1_BIT 0xFC00 |
#define WAIT_UNTIL_SPI_NOT_FULL | ( | ) | { while( SPI1STATLbits.SPITBF == 1 );} |
#define ws2812 ((ws2812_t*) CurrentPinRegister) |
enum ws2812_mode_t |
void initWS2812 | ( | void | ) |
\brief Initialization routine for WS2812B driver
Initialize WS2812 Output
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC0 | Pin To Set | 0x0C | userBufferIndex LSB | userBufferIndex MSB | Number of LEDS | Unused 0x55* | Unused 0x55* |
*0x55 is recommended, but any byte is acceptable
Response:
Command is echoed back.
Examples:
Set pin 19 to WS2812, user buffer index of 0x180, 16 LEDS
0xC0 0x13 0x0B 0x80 0x01 0x10 0x55 0x55
Set an LED RGB Value. Index 0 also sets off mode for Bargraph, Index 1 also sets on Mode for bargraph.
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC1 | Pin To Set | 0x0B | LED index (0 to (Num LEDs - 1)) | Blue (0-255) | Green(0-255) | Red (0-255) | Unused 0x55* |
*0x55 is recommended, but any byte is acceptable
Response:
Command is echoed back.
Examples:
Set Pin 16, LED 7 to RGB value 0x002532BF
0xC1 0x13 0x0B 0x07 0xBF 0x32 0x25 0x55
Respond with number of bytes needed in User Buffer to store a support a specified number of LEDS
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC2 | Pin To Set | 0x0B | Number of LEDS | Unused/0x55* | Unused/0x55* | Unused/0x55* | Unused/0x55* |
*0x55 is recommended, but any byte is acceptable
Response:
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC2 | Pin To Set | 0x0B | Number of Bytes MSB | Number of Bytes LSB | Unused/0x55* | Unused/0x55* | Unused/0x55* |
Examples:
Set Pin 16, Request byte count for 15 LEDS
0xC2 0x13 0x0B 0x0F 0x55 0x55 0x55 0x55
Response (assume answer is 725 bytes (0x2D5):
0xC2 0x13 0x0B 0xD5 0x02 0x55 0x55 0x55
Set an LED RGB Value in an animation frame. This command cannot be called until the Animation buffer index is set with command 0xC4
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC3 | Pin To Set | 0x0B | Frame Index | LED index (0 to (Num LEDs - 1)) | Blue (0-255) | Green(0-255) | Red (0-255) |
Response:
Command is echoed back.
Examples:
Set Pin 16, Frame 3 LED 7 to RGB value 0x002532BF
0xC1 0x13 0x0B 0x03 0x07 0xBF 0x32 0x25
Set the index of the animation frames area and the number of frames. The animation frames area is separate from the buffer defined in command 0xC0 and cannot overlap. The length of this area is (2 + 3 * NumLeds)* NumFrames.
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC4 | Pin To Set | 0x0B | Animation Buffer Index LSB | Animation Buffer Index MSB | Number of Animation Frames | Unused 0x55* | Unused 0x55* |
*0x55 is recommended, but any byte is acceptable
Response:
Command is echoed back.
Examples:
Set the animation buffer index to 0x0440 and the number of frames to 10
0xC0 0x13 0x0B 0x40 0x04 0x0A 0x55 0x05
Set the delay for an animation frame in mS. This command must not be called before the animation buffer index is set with command 0xC4.
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC5 | Pin To Set | 0x0B | Frame Index | delay LSB | delay MSB | Unused/0x55* | Unused/0x55* |
*0x55 is recommended, but any byte is acceptable
Response:
Command is echoed back.
Examples:
Set pin 19 Animation frame 2 to a delay of 8000 ms (0x1F40)
0xC5 0x13 0x0B 0x02 0x40 0x1F 0x55 0x55
Set the bargraph mode min and max values
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC6 | Pin To Set | 0x0B | bargraph min lsb | bargraph min msb | bargraph max lsb | bargraph max msb | Unused/0x55* |
*0x55 is recommended, but any byte is acceptable
Response:
Command is echoed back.
Examples:
Set pin 19 bargraph min 1000, max 64000
`0xC7 0x13 0x0B 0x0E8 0x03 0x00 0xFA 0x55
|
inline |
|
inline |
|
inline |
|
inline |
void StartDMA | ( | ) |
void StopDMA | ( | ) |
void updateWS2812 | ( | ) |
update the WS2812 pin state machine
void ws2812_SPI1_Initialize | ( | void | ) |
void ws2812ConfigHardware | ( | ) |
uint32_t ColorTable[] |
ws2812_t* debugWS2812 |