summaryrefslogtreecommitdiff
path: root/drivers/chibios/ws2812_spi.c
diff options
context:
space:
mode:
authorXelus22 <17491233+Xelus22@users.noreply.github.com>2020-06-19 22:35:32 +0000
committerDrashna Jael're <drashna@live.com>2020-08-08 21:17:24 -0700
commitdc2c6e3a7dbcecc153cf70a574d25a38950f02b4 (patch)
tree949accb526bd4cdc678449319cae52a5a2764933 /drivers/chibios/ws2812_spi.c
parent43dadc79ff72be3b29b55283808c6be9ce9b7efc (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.c22
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 = {