diff --git a/lib/led_ws2812b.c b/lib/led_ws2812b.c index 7615437..6dfbe20 100644 --- a/lib/led_ws2812b.c +++ b/lib/led_ws2812b.c @@ -39,9 +39,9 @@ * @{ */ /** 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 + * @note SPI2 is 5V tolerant and can be operated in open-drain mode with 1-10 kO pull-up resistor to 5V to get 5V signal level for short cables */ -#define LED_WS2812B_SPI 2 /**< SPI peripheral */ +#define LED_WS2812B_SPI 2 /**< SPI peripheral (SPI2_MOSI = PB15) */ /** @} */ /** bit template to encode one byte to be shifted out by SPI to the WS2812B LEDs @@ -108,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_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) + 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 MOSI as output (push-pull, works better for long noisy cables, also works well enough without voltage shifter) 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