ws2812b: use push-pull output for noisy cable
This commit is contained in:
parent
4f91856445
commit
ac9eb9bac9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user