Added ws2812_spi support for WB32 MCU (#17143)

Co-authored-by: Joy <chang.li@westberrytech.com>
This commit is contained in:
Joy Lee 2022-08-14 09:09:57 +08:00 committed by GitHub
parent 5c805e4cc5
commit 6b1c7d20aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -6,7 +6,7 @@
/* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */
#ifndef NOP_FUDGE #ifndef NOP_FUDGE
# if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) # if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(WB32F3G71xx) || defined(WB32FQ95xx)
# define NOP_FUDGE 0.4 # define NOP_FUDGE 0.4
# else # else
# error("NOP_FUDGE configuration required") # error("NOP_FUDGE configuration required")

View file

@ -5,8 +5,12 @@
// Define the spi your LEDs are plugged to here // Define the spi your LEDs are plugged to here
#ifndef WS2812_SPI #ifndef WS2812_SPI
# if defined(WB32F3G71xx) || defined(WB32FQ95xx)
# define WS2812_SPI SPIDQ
# else
# define WS2812_SPI SPID1 # define WS2812_SPI SPID1
# endif # endif
#endif
#ifndef WS2812_SPI_MOSI_PAL_MODE #ifndef WS2812_SPI_MOSI_PAL_MODE
# define WS2812_SPI_MOSI_PAL_MODE 5 # define WS2812_SPI_MOSI_PAL_MODE 5
@ -54,6 +58,7 @@
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0)
#else #else
# define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) // default # define WS2812_SPI_DIVISOR_CR1_BR_X (SPI_CR1_BR_1 | SPI_CR1_BR_0) // default
# define WS2812_SPI_DIVISOR 16
#endif #endif
// Use SPI circular buffer // Use SPI circular buffer
@ -148,8 +153,14 @@ void ws2812_init(void) {
NULL, // end_cb NULL, // end_cb
PAL_PORT(RGB_DI_PIN), PAL_PORT(RGB_DI_PIN),
PAL_PAD(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN),
# if defined(WB32F3G71xx) || defined(WB32FQ95xx)
0,
0,
WS2812_SPI_DIVISOR
# else
WS2812_SPI_DIVISOR_CR1_BR_X, WS2812_SPI_DIVISOR_CR1_BR_X,
0 0
# endif
#else #else
// HAL_SPI_V2 // HAL_SPI_V2
# if SPI_SUPPORTS_CIRCULAR == TRUE # if SPI_SUPPORTS_CIRCULAR == TRUE