Skip to content

Commit

Permalink
Add support for DMAMUX-capable MCU configuration with WS2812 PWM driv…
Browse files Browse the repository at this point in the history
…er. (qmk#9471)
  • Loading branch information
tzarc authored and drashna committed Sep 30, 2020
1 parent 8c38482 commit 6a5700b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/chibios/ws2812_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#ifndef WS2812_DMA_CHANNEL
# define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP
#endif
#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE) && !defined(WS2812_DMAMUX_ID)
# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
#endif

// Push Pull or Open Drain Configuration
// Default Push Pull
Expand Down Expand Up @@ -184,6 +187,11 @@ void ws2812_init(void) {
dmaStreamSetMode(WS2812_DMA_STREAM, STM32_DMA_CR_CHSEL(WS2812_DMA_CHANNEL) | STM32_DMA_CR_DIR_M2P | STM32_DMA_CR_PSIZE_WORD | STM32_DMA_CR_MSIZE_WORD | STM32_DMA_CR_MINC | STM32_DMA_CR_CIRC | STM32_DMA_CR_PL(3));
// M2P: Memory 2 Periph; PL: Priority Level

#if (STM32_DMA_SUPPORTS_DMAMUX == TRUE)
// If the MCU has a DMAMUX we need to assign the correct resource
dmaSetRequestSource(WS2812_DMA_STREAM, WS2812_DMAMUX_ID);
#endif

// Start DMA
dmaStreamEnable(WS2812_DMA_STREAM);

Expand Down

0 comments on commit 6a5700b

Please sign in to comment.