CuVoodoo STM32F1 firmware template
|
library to drive a WS2812B LED chain (code) More...
Go to the source code of this file.
Macros | |
#define | LED_WS2812B_SPI 1 |
SPI peripheral. | |
#define | LED_WS2812B_TIMER 3 |
timer peripheral | |
#define | LED_WS2812B_CLK_CH 3 |
timer channel to output PWM (PB0), connect to SPI clock input | |
#define | LED_WS2812B_TIMER_OC TIM_OC3 |
timer output compare used to set PWM frequency | |
#define | LED_WS2812B_SPI_TEMPLATE 0x924924 |
bit template to encode one byte to be shifted out by SPI to the WS2812B LEDs More... | |
Functions | |
void | led_ws2812b_set_rgb (uint16_t led, uint8_t red, uint8_t green, uint8_t blue) |
set color of a single LED More... | |
bool | led_ws2812b_transmit (void) |
transmit color values to WS2812B LEDs More... | |
void | led_ws2812b_setup (void) |
setup WS2812B LED driver | |
void DMA_ISR_SPI_TX() | LED_WS2812B_SPI (void) |
DMA interrupt service routine to stop transmission after it finished. | |
Variables | |
uint8_t | led_ws2812b_data [LED_WS2812B_LEDS *3 *3+40 *3/8+1] = {0} |
data encoded to be shifted out by SPI for the WS2812B, plus the 50us reset (~40 data bits) | |
static volatile bool | transmit_flag = false |
flag set in software when transmission started, clear by interrupt when transmission completed | |
library to drive a WS2812B LED chain (code)
Definition in file led_ws2812b.c.
#define LED_WS2812B_SPI_TEMPLATE 0x924924 |
bit template to encode one byte to be shifted out by SPI to the WS2812B LEDs
For each WS2812B bit which needs to be transfered we require to transfer 3 SPI bits. The first SPI bit is the high start of the WS2812B bit frame. The second SPI bit determines if the WS2812B bit is a 0 or 1. The third SPI bit is the last part of the WS2812B bit frame, which is always low. The binary pattern is 0b100100100100100100100100
Definition at line 60 of file led_ws2812b.c.
void led_ws2812b_set_rgb | ( | uint16_t | led, |
uint8_t | red, | ||
uint8_t | green, | ||
uint8_t | blue | ||
) |
set color of a single LED
[in] | led | the LED number to set the color |
[in] | red | the red color value to set on the LED |
[in] | green | the green color value to set on the LED |
[in] | blue | the blue color value to set on the LED |
Definition at line 65 of file led_ws2812b.c.
bool led_ws2812b_transmit | ( | void | ) |
transmit color values to WS2812B LEDs
Definition at line 91 of file led_ws2812b.c.