This is a simple library to control the WS2812-style adresable LEDs (with Data line) using STM32 DMA. It itself is written in plain C but references some HAL functions.
- Configure the desired timer channel with the following settings:
- Output Type: PWM generation
- Choose Prescaler (PSC) and Auto-Reload Register (ARR) values so that the resulting PWM frequency corresponds to the LED timing specified in the datasheet (usually 800 kHz)
- Create the project and add the library by either copying it manually or importing as Git submodule. The included
CMakeListsshould help with that - Open
include/addrled_config.hand configure the defines there. - In your initialization code, call
ADDRLED_Initonce to init the required variables - Add
ADDRLED_CallbacktoHAL_TIM_PWM_PulseFinishedCallbackfor the respective timer - Use the included functionality to set the colors and call
ADDRLED_Updateto send the data to the LEDs - Let your project light up :)