aboutsummaryrefslogtreecommitdiff
path: root/drivers/chibios/ws2812_pwm.c
diff options
context:
space:
mode:
authorXelus22 <17491233+Xelus22@users.noreply.github.com>2020-06-19 22:35:32 +0000
committerGitHub <noreply@github.com>2020-06-20 08:35:32 +1000
commitc7851484457e5ab604962ae7c914b863b8de0cb2 (patch)
treef2fbfc27c8adf8de4a242392ca979561287dc62a /drivers/chibios/ws2812_pwm.c
parentb43bdc1c69bb5a57976a159bfc00c4ac1c7c7f8f (diff)
downloadqmk_firmware-c7851484457e5ab604962ae7c914b863b8de0cb2.tar.gz
qmk_firmware-c7851484457e5ab604962ae7c914b863b8de0cb2.zip
STM32 WS2812 Open Drain Configuration (#9414)
* update docs stm32 only and applies to all 3 driver * cformat
Diffstat (limited to 'drivers/chibios/ws2812_pwm.c')
-rw-r--r--drivers/chibios/ws2812_pwm.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c
index 1a1721029..ba45d0042 100644
--- a/drivers/chibios/ws2812_pwm.c
+++ b/drivers/chibios/ws2812_pwm.c
@@ -24,6 +24,22 @@
24# define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP 24# define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP
25#endif 25#endif
26 26
27// Push Pull or Open Drain Configuration
28// Default Push Pull
29#ifndef WS2812_EXTERNAL_PULLUP
30# if defined(USE_GPIOV1)
31# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
32# else
33# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING
34# endif
35#else
36# if defined(USE_GPIOV1)
37# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN
38# else
39# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING
40# endif
41#endif
42
27#ifndef WS2812_PWM_TARGET_PERIOD 43#ifndef WS2812_PWM_TARGET_PERIOD
28//# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...? 44//# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...?
29# define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1 45# define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1
@@ -142,11 +158,7 @@ void ws2812_init(void) {
142 for (i = 0; i < WS2812_COLOR_BIT_N; i++) ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle 158 for (i = 0; i < WS2812_COLOR_BIT_N; i++) ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle
143 for (i = 0; i < WS2812_RESET_BIT_N; i++) ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero 159 for (i = 0; i < WS2812_RESET_BIT_N; i++) ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero
144 160
145#if defined(USE_GPIOV1) 161 palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE);
146 palSetLineMode(RGB_DI_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
147#else
148 palSetLineMode(RGB_DI_PIN, PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING);
149#endif
150 162
151 // PWM Configuration 163 // PWM Configuration
152 //#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config 164 //#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config