45 #define DATA_PORT_BASE GPIOD_BaseAddress
46 #define DATA_PINS {GPIO_PIN_4}
48 #define COLOR_ORDER grb
50 #define WAIT_LOOPS 1000000
62 CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);
63 CLK_SYSCLKConfig(CLK_PRESCALER_HSIDIV1);
64 CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);
88 for (
unsigned int i = 0; i <
N_LEDS; i++) {
100 for (
unsigned long i = 0; i < WAIT_LOOPS; i++) {
105 for (
unsigned int i = 0; i <
N_LEDS; i++) {
112 for (
unsigned long i = 0; i < WAIT_LOOPS; i++) {
119 #ifdef USE_FULL_ASSERT
120 void assert_failed(uint8_t* file, uint32_t line)
ws2812_rgb leds[N_LEDS]
RGB array which represents the LEDs.
ws2812 ws2812_dev
Device struct.
#define COLOR_ORDER
Color order of the strip.
#define DATA_PORT_BASE
Port base address of the data pin.
#define DATA_PINS
Data pin(s) of the strip.
#define RESET_TIME
Reset time in µs.
#define N_LEDS
Number of LEDs in the strip.
ALL PLATFORMS: Data structure to configure a WS2812 device struct.
uint8_t n_dev
Number of WS2812 device to drive.
uint8_t rst_time_us
Time required for the WS2812 device(s) to reset in us.
uint16_t port_baseaddr
Base address of the port used to drive WS2812 devices (ex. GPIOA_BASE, GPIOB_BASE,...
ws2812_order order
CoColor order of the WS2812 device(s) (ex. rgb, grb, bgr...)
uint8_t * pins
Array of pins used to program WS2812 devices (Must share the same PORT! (ex. PB0, PB1,...
Data structure to hold RGB color values.
ALL PLATFORMS: WS2812 device struct to drive one or more WS2812 devices.
Exposes the Tiny-WS2812 library interface.
void ws2812_close_tx(ws2812 *dev)
Closes a WS2812 transmission.
uint8_t ws2812_config(ws2812 *dev, ws2812_cfg *cfg)
Configures a WS2812 device struct.
void ws2812_prep_tx(ws2812 *dev)
Prepares the host device for data transmission.
void ws2812_tx(ws2812 *dev, ws2812_rgb *leds, size_t n_leds)
Transmits RGB values to the provided WS2812 device.