feat: Support for WS2812 RGB LEDs (#3909)

Co-authored-by: 3djc <lesitewebdejc@hotmail.com>
This commit is contained in:
Raphael Coeffic
2023-10-14 14:06:55 +10:00
committed by GitHub
co-authored by 3djc
parent f8ad3a7bda
commit b22a1b5d32
60 changed files with 788 additions and 122 deletions
@@ -28,7 +28,7 @@ static void* module_timer_init(void* hw_def, const etx_timer_config_t* cfg)
bool polarity = cfg->polarity;
uint32_t ocval = cfg->cmp_val;
uint32_t ocmode = (cfg->type == ETX_PWM) ? LL_TIM_OCMODE_FORCED_INACTIVE : LL_TIM_OCMODE_TOGGLE;
uint32_t ocmode = LL_TIM_OCMODE_FORCED_INACTIVE;
stm32_pulse_init(timer, 0);
stm32_pulse_config_output(timer, polarity, ocmode, ocval);
@@ -46,16 +46,14 @@ static void module_timer_send(void* ctx, const etx_timer_config_t* cfg,
const void* pulses, uint16_t length)
{
auto timer = (const stm32_pulse_timer_t*)ctx;
if (!stm32_pulse_if_not_running_disable(timer)) {
LL_DMA_DeInit(timer->DMAx, timer->DMA_Stream);
if (!stm32_pulse_if_not_running_disable(timer))
return;
}
// Set polarity
stm32_pulse_set_polarity(timer, cfg->polarity);
// Start DMA request and re-enable timer
uint32_t ocmode = (cfg->type == ETX_PWM) ? LL_TIM_OCMODE_PWM1 : LL_TIM_OCMODE_TOGGLE;
uint32_t ocmode = LL_TIM_OCMODE_PWM1;
uint32_t ocval = cfg->cmp_val;
stm32_pulse_start_dma_req(timer, pulses, length, ocmode, ocval);
}