diff options
author | Xelus22 <17491233+Xelus22@users.noreply.github.com> | 2020-06-19 22:35:32 +0000 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2020-08-08 21:17:24 -0700 |
commit | dc2c6e3a7dbcecc153cf70a574d25a38950f02b4 (patch) | |
tree | 949accb526bd4cdc678449319cae52a5a2764933 /drivers/chibios/ws2812_pwm.c | |
parent | 43dadc79ff72be3b29b55283808c6be9ce9b7efc (diff) |
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.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/chibios/ws2812_pwm.c b/drivers/chibios/ws2812_pwm.c index 1a17210298..ba45d00425 100644 --- a/drivers/chibios/ws2812_pwm.c +++ b/drivers/chibios/ws2812_pwm.c @@ -24,6 +24,22 @@ # define WS2812_DMA_CHANNEL 2 // DMA Channel for TIMx_UP #endif +// Push Pull or Open Drain Configuration +// Default Push Pull +#ifndef WS2812_EXTERNAL_PULLUP +# if defined(USE_GPIOV1) +# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL +# else +# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING +# endif +#else +# if defined(USE_GPIOV1) +# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN +# else +# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING +# endif +#endif + #ifndef WS2812_PWM_TARGET_PERIOD //# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...? # define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1 @@ -142,11 +158,7 @@ void ws2812_init(void) { for (i = 0; i < WS2812_COLOR_BIT_N; i++) ws2812_frame_buffer[i] = WS2812_DUTYCYCLE_0; // All color bits are zero duty cycle for (i = 0; i < WS2812_RESET_BIT_N; i++) ws2812_frame_buffer[i + WS2812_COLOR_BIT_N] = 0; // All reset bits are zero -#if defined(USE_GPIOV1) - palSetLineMode(RGB_DI_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL); -#else - palSetLineMode(RGB_DI_PIN, PAL_MODE_ALTERNATE(WS2812_PWM_PAL_MODE) | PAL_STM32_OSPEED_HIGHEST | PAL_STM32_PUPDR_FLOATING); -#endif + palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); // PWM Configuration //#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 |