1
0
Fork 0

STM32 WS2812 Open Drain Configuration (#9414)

* update docs stm32 only and applies  to all 3 driver
* cformat
This commit is contained in:
Xelus22 2020-06-19 22:35:32 +00:00 committed by GitHub
parent b43bdc1c69
commit c785148445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 11 deletions

View file

@ -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 = {