Loading...
Searching...
No Matches

Default configuration for WS2812/SK6812 RGB LEDs. More...

Detailed Description

Default configuration for WS2812/SK6812 RGB LEDs.

Author
Marian Buschsieweke maria.nosp@m.n.bu.nosp@m.schsi.nosp@m.ewek.nosp@m.e@ovg.nosp@m.u.de

Definition in file ws281x_params.h.

#include <limits.h>
#include "board.h"
#include "saul_reg.h"
#include "ws281x.h"
+ Include dependency graph for ws281x_params.h:

Go to the source code of this file.

Macros

#define WS281X_TIMER_DEV   TIMER_DEV(2)
 Timer used for WS281x (by the timer_gpio_ll implementation)
 
#define WS281X_TIMER_MAX_VALUE   UINT_MAX
 Maximum value of the timer used for WS281x (by the timer_gpio_ll implementation)
 
#define WS281X_TIMER_FREQ   16000000
 Frequency for the timer used for WS281x (by the timer_gpio_ll implementation)
 
#define WS281X_SPI_DEV   SPI_DEV(0)
 SPI device to use for WS281x RGB LED data transmission.
 
#define WS281X_SPI_CLK   3200000
 SPI clock speed: 3.2 MHz → 312.5 ns per SPI bit.
 
#define WS281X_SAUL_INFO   { .name = "WS281X RGB LED" }
 SAUL info.
 

Variables

static const ws281x_params_t ws281x_params []
 Initialization parameters for WS281x devices.
 
static const saul_reg_info_t ws281x_saul_info []
 Additional meta information to keep in the SAUL registry.
 

Default configuration parameters for WS281x RGB LEDs

#define WS281X_PARAM_PIN   (GPIO_PIN(0, 0))
 GPIO pin connected to the data pin of the first LED.
 
#define WS281X_PARAM_NUMOF   (8U)
 Number of LEDs chained.
 
#define WS281X_PARAM_BUF   (ws281x_buf)
 Data buffer holding LED states.
 
#define WS281X_PARAMS
 WS281x initialization parameters.
 
uint8_t ws281x_buf [WS281X_PARAM_NUMOF *WS281X_BYTES_PER_DEVICE]
 Data buffer holding the LED states.
 

Timing parameters for WS2812/SK6812 RGB LEDs

#define WS281X_T_DATA_NS   (1250U)
 Data transmission time in nanoseconds.
 
#define WS281X_T_DATA_ONE_NS   (650U)
 The high-time of a 1 in nanoseconds.
 
#define WS281X_T_DATA_ZERO_NS   (325U)
 The high-time of a 0 in nanoseconds.
 
#define WS281X_T_END_US   (80U)
 Time in microseconds to pull the data line low to signal end of data.
 

Macro Definition Documentation

◆ WS281X_PARAM_BUF

#define WS281X_PARAM_BUF   (ws281x_buf)

Data buffer holding LED states.

Definition at line 44 of file ws281x_params.h.

◆ WS281X_PARAM_NUMOF

#define WS281X_PARAM_NUMOF   (8U)

Number of LEDs chained.

Definition at line 37 of file ws281x_params.h.

◆ WS281X_PARAM_PIN

#define WS281X_PARAM_PIN   (GPIO_PIN(0, 0))

GPIO pin connected to the data pin of the first LED.

Definition at line 34 of file ws281x_params.h.

◆ WS281X_PARAMS

#define WS281X_PARAMS
Value:
{ \
.pin = WS281X_PARAM_PIN, \
.numof = WS281X_PARAM_NUMOF, \
.buf = WS281X_PARAM_BUF, \
}
#define WS281X_PARAM_PIN
GPIO pin connected to the data pin of the first LED.
Definition board.h:71
#define WS281X_PARAM_NUMOF
Number of LEDs chained.
Definition board.h:74
#define WS281X_PARAM_BUF
Data buffer holding LED states.

WS281x initialization parameters.

Definition at line 51 of file ws281x_params.h.

◆ WS281X_SAUL_INFO

#define WS281X_SAUL_INFO   { .name = "WS281X RGB LED" }

SAUL info.

Definition at line 169 of file ws281x_params.h.

◆ WS281X_SPI_CLK

#define WS281X_SPI_CLK   3200000

SPI clock speed: 3.2 MHz → 312.5 ns per SPI bit.

4 SPI bits add up to 1.25 µs period, which is the time to transmit one WS281x bit.

Definition at line 162 of file ws281x_params.h.

◆ WS281X_SPI_DEV

#define WS281X_SPI_DEV   SPI_DEV(0)

SPI device to use for WS281x RGB LED data transmission.

This SPI must support DMA.

Definition at line 153 of file ws281x_params.h.

◆ WS281X_T_DATA_NS

#define WS281X_T_DATA_NS   (1250U)

Data transmission time in nanoseconds.

For the SK6812, WS2812 and WS2812b this is 1.25 µs. This is the total time required to transmit one bit.

Definition at line 79 of file ws281x_params.h.

◆ WS281X_T_DATA_ONE_NS

#define WS281X_T_DATA_ONE_NS   (650U)

The high-time of a 1 in nanoseconds.

Definition at line 86 of file ws281x_params.h.

◆ WS281X_T_DATA_ZERO_NS

#define WS281X_T_DATA_ZERO_NS   (325U)

The high-time of a 0 in nanoseconds.

Definition at line 93 of file ws281x_params.h.

◆ WS281X_T_END_US

#define WS281X_T_END_US   (80U)

Time in microseconds to pull the data line low to signal end of data.

For the WS2812 it is ≥ 50µs, for the SK6812 it is ≥ 80µs. We choose 80µs to be compatible with both.

Definition at line 103 of file ws281x_params.h.

◆ WS281X_TIMER_DEV

#define WS281X_TIMER_DEV   TIMER_DEV(2)

Timer used for WS281x (by the timer_gpio_ll implementation)

A single timer is configured for any number of WS281x strands, so this does not need to be part of params.

It is required that the timer has at least 2 channels. (Future versions may require a 3rd channel).

It is required that the timer's MAX_VALUE is 2^n-1, which is a trivial but not explicitly stated case.

This timer is configured at WS281x initialization time, and kept stopped outside of transmissions.

The default value of 2 is chosen because the only platform on which the module is usable is nRF5x, where TIMER_DEV(1) is in use by the radio module. It is strongly advised to explicitly set this timer to a known free timer, as the default may change without notice.

Definition at line 127 of file ws281x_params.h.

◆ WS281X_TIMER_FREQ

#define WS281X_TIMER_FREQ   16000000

Frequency for the timer used for WS281x (by the timer_gpio_ll implementation)

This should be set to a frequency that is a close multiple of 3MHz, depending on the precise low and high times. A value of 16MHz works well.

Definition at line 144 of file ws281x_params.h.

◆ WS281X_TIMER_MAX_VALUE

#define WS281X_TIMER_MAX_VALUE   UINT_MAX

Maximum value of the timer used for WS281x (by the timer_gpio_ll implementation)

This macro needs to be defined to the maximum value of WS281X_TIMER_DEV.

Definition at line 135 of file ws281x_params.h.

Variable Documentation

◆ ws281x_params

const ws281x_params_t ws281x_params[]
static
Initial value:
=
{
}
#define WS281X_PARAMS
WS281x initialization parameters.

Initialization parameters for WS281x devices.

Definition at line 62 of file ws281x_params.h.

◆ ws281x_saul_info

const saul_reg_info_t ws281x_saul_info[]
static
Initial value:
=
{
}
#define WS281X_SAUL_INFO
SAUL info.

Additional meta information to keep in the SAUL registry.

Definition at line 175 of file ws281x_params.h.