diff options
author | Xelus22 <17491233+Xelus22@users.noreply.github.com> | 2020-06-19 22:35:32 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-20 08:35:32 +1000 |
commit | c7851484457e5ab604962ae7c914b863b8de0cb2 (patch) | |
tree | f2fbfc27c8adf8de4a242392ca979561287dc62a /drivers/chibios/ws2812_spi.c | |
parent | b43bdc1c69bb5a57976a159bfc00c4ac1c7c7f8f (diff) |
STM32 WS2812 Open Drain Configuration (#9414)
* update docs stm32 only and applies to all 3 driver
* cformat
Diffstat (limited to 'drivers/chibios/ws2812_spi.c')
-rw-r--r-- | drivers/chibios/ws2812_spi.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/chibios/ws2812_spi.c b/drivers/chibios/ws2812_spi.c index 36e08e39ed..3bbada7fef 100644 --- a/drivers/chibios/ws2812_spi.c +++ b/drivers/chibios/ws2812_spi.c @@ -16,6 +16,22 @@ # define WS2812_SPI_MOSI_PAL_MODE 5 #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_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL +# endif +#else +# if defined(USE_GPIOV1) +# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN +# else +# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN +# endif +#endif + #define BYTES_FOR_LED_BYTE 4 #define NB_COLORS 3 #define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * NB_COLORS) @@ -52,11 +68,7 @@ static void set_led_color_rgb(LED_TYPE color, int pos) { } void ws2812_init(void) { -#if defined(USE_GPIOV1) - palSetLineMode(RGB_DI_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL); -#else - palSetLineMode(RGB_DI_PIN, PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL); -#endif + palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); // TODO: more dynamic baudrate static const SPIConfig spicfg = { |