summaryrefslogtreecommitdiff
path: root/drivers/chibios
diff options
context:
space:
mode:
authorSergey Vlasov <sigprof@gmail.com>2021-03-03 07:26:06 +0300
committerGitHub <noreply@github.com>2021-03-02 20:26:06 -0800
commit18a333ec6bc9051ae7ec63a809d725c5c5f77046 (patch)
treef2f34dfe316a4c5c6d1ad065c7512a32d46e5820 /drivers/chibios
parent8f5d2e546e69e09edd28ff68f3d3a894f96087a7 (diff)
downloadqmk_firmware-18a333ec6bc9051ae7ec63a809d725c5c5f77046.tar.gz
qmk_firmware-18a333ec6bc9051ae7ec63a809d725c5c5f77046.zip
Add support for complementary outputs to the WS2812 PWM driver (#11988)
Diffstat (limited to 'drivers/chibios')
-rw-r--r--drivers/chibios/ws2812_pwm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c
index 140120d488..e6af55b6b3 100644
--- a/drivers/chibios/ws2812_pwm.c
+++ b/drivers/chibios/ws2812_pwm.c
@@ -27,6 +27,15 @@
# error "please consult your MCU's datasheet and specify in your config.h: #define WS2812_DMAMUX_ID STM32_DMAMUX1_TIM?_UP"
#endif
+#ifndef WS2812_PWM_COMPLEMENTARY_OUTPUT
+# define WS2812_PWM_OUTPUT_MODE PWM_OUTPUT_ACTIVE_HIGH
+#else
+# if !STM32_PWM_USE_ADVANCED
+# error "WS2812_PWM_COMPLEMENTARY_OUTPUT requires STM32_PWM_USE_ADVANCED == TRUE"
+# endif
+# define WS2812_PWM_OUTPUT_MODE PWM_COMPLEMENTARY_OUTPUT_ACTIVE_HIGH
+#endif
+
// Push Pull or Open Drain Configuration
// Default Push Pull
#ifndef WS2812_EXTERNAL_PULLUP
@@ -247,7 +256,7 @@ void ws2812_init(void) {
.channels =
{
[0 ... 3] = {.mode = PWM_OUTPUT_DISABLED, .callback = NULL}, // Channels default to disabled
- [WS2812_PWM_CHANNEL - 1] = {.mode = PWM_OUTPUT_ACTIVE_HIGH, .callback = NULL}, // Turn on the channel we care about
+ [WS2812_PWM_CHANNEL - 1] = {.mode = WS2812_PWM_OUTPUT_MODE, .callback = NULL}, // Turn on the channel we care about
},
.cr2 = 0,
.dier = TIM_DIER_UDE, // DMA on update event for next period