aboutsummaryrefslogtreecommitdiff
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
committerGitHub <noreply@github.com>2020-06-20 08:35:32 +1000
commitc7851484457e5ab604962ae7c914b863b8de0cb2 (patch)
treef2fbfc27c8adf8de4a242392ca979561287dc62a /drivers/chibios/ws2812_spi.c
parentb43bdc1c69bb5a57976a159bfc00c4ac1c7c7f8f (diff)
downloadqmk_firmware-c7851484457e5ab604962ae7c914b863b8de0cb2.tar.gz
qmk_firmware-c7851484457e5ab604962ae7c914b863b8de0cb2.zip
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 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 = {