aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/chibios/ws2812_spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/chibios/ws2812_spi.c')
-rw-r--r--drivers/chibios/ws2812_spi.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/chibios/ws2812_spi.c b/drivers/chibios/ws2812_spi.c
index 36e08e39e..3bbada7fe 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 = {