From e9f7e574ba7c48de1e5c7541ef884c1f08645d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 9 Mar 2020 09:44:29 +0100 Subject: [PATCH] led_ws2812b: use open drain data signal --- lib/led_ws2812b.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/led_ws2812b.c b/lib/led_ws2812b.c index 25bf2ac..7615437 100644 --- a/lib/led_ws2812b.c +++ b/lib/led_ws2812b.c @@ -38,6 +38,9 @@ /** @defgroup led_ws2812b_spi SPI peripheral used to control the WS2812B LEDs * @{ */ +/** SPI peripheral + * @note SPI2 is 5V tolerant and can be operated in open-drain mode will 1 kO pull-up resistor to 5V to get 5V signal level + */ #define LED_WS2812B_SPI 2 /**< SPI peripheral */ /** @} */ @@ -105,7 +108,7 @@ void led_ws2812b_setup(void) // setup SPI to transmit data rcc_periph_clock_enable(RCC_SPI_MOSI_PORT(LED_WS2812B_SPI)); // enable clock for SPI output peripheral - gpio_set_mode(SPI_MOSI_PORT(LED_WS2812B_SPI), GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, SPI_MOSI_PIN(LED_WS2812B_SPI)); // set MISO as output (needs to be shifted to 5V) + gpio_set_mode(SPI_MOSI_PORT(LED_WS2812B_SPI), GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_OPENDRAIN, SPI_MOSI_PIN(LED_WS2812B_SPI)); // set MOSI as output (push-pull needs to be shifted to 5V, open-drain consumes up to 5 mA with pull-up resistor of 1 kO) rcc_periph_clock_enable(RCC_AFIO); // enable clock for SPI alternate function rcc_periph_clock_enable(RCC_SPI(LED_WS2812B_SPI)); // enable clock for SPI peripheral spi_reset(SPI(LED_WS2812B_SPI)); // clear SPI values to default