aboutsummaryrefslogtreecommitdiff
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 @@
16# define WS2812_SPI_MOSI_PAL_MODE 5 16# define WS2812_SPI_MOSI_PAL_MODE 5
17#endif 17#endif
18 18
19// Push Pull or Open Drain Configuration
20// Default Push Pull
21#ifndef WS2812_EXTERNAL_PULLUP
22# if defined(USE_GPIOV1)
23# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
24# else
25# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL
26# endif
27#else
28# if defined(USE_GPIOV1)
29# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN
30# else
31# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN
32# endif
33#endif
34
19#define BYTES_FOR_LED_BYTE 4 35#define BYTES_FOR_LED_BYTE 4
20#define NB_COLORS 3 36#define NB_COLORS 3
21#define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * NB_COLORS) 37#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) {
52} 68}
53 69
54void ws2812_init(void) { 70void ws2812_init(void) {
55#if defined(USE_GPIOV1) 71 palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE);
56 palSetLineMode(RGB_DI_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
57#else
58 palSetLineMode(RGB_DI_PIN, PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL);
59#endif
60 72
61 // TODO: more dynamic baudrate 73 // TODO: more dynamic baudrate
62 static const SPIConfig spicfg = { 74 static const SPIConfig spicfg = {