Skip to content

Commit 1622210

Browse files
Marek Matejcarlescufi
authored andcommitted
samples: led_ws2812: ESP32 support
Add overlays for esp32s2, esp32s3, esp32c3 based boards, which has RGB led assembled. Those boards are capable of driving the RGB led using SPI. The default MOSI idle level is different to how DI driver expect it to be. Signed-off-by: Marek Matej <[email protected]>
1 parent 01ba923 commit 1622210

File tree

6 files changed

+135
-0
lines changed

6 files changed

+135
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_WS2812_STRIP_SPI=y
2+
CONFIG_SPI=y
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/led/led.h>
8+
9+
&spi2 {
10+
/* Workaround to support WS2812 driver */
11+
line-idle-low;
12+
13+
led_strip: ws2812@0 {
14+
compatible = "worldsemi,ws2812-spi";
15+
16+
/* SPI */
17+
reg = <0>; /* ignored, but necessary for SPI bindings */
18+
spi-max-frequency = <6400000>;
19+
20+
/* WS2812 */
21+
chain-length = <1>; /* arbitrary; change at will */
22+
spi-cpha;
23+
spi-one-frame = <0xf0>; /* 11110000: 625 ns high and 625 ns low */
24+
spi-zero-frame = <0xc0>; /* 11000000: 312.5 ns high and 937.5 ns low */
25+
color-mapping = <LED_COLOR_ID_GREEN
26+
LED_COLOR_ID_RED
27+
LED_COLOR_ID_BLUE>;
28+
};
29+
};
30+
31+
&pinctrl {
32+
spim2_default: spim2_default {
33+
group2 {
34+
pinmux = <SPIM2_MOSI_GPIO8>;
35+
};
36+
};
37+
};
38+
39+
/ {
40+
aliases {
41+
led-strip = &led_strip;
42+
};
43+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_WS2812_STRIP_SPI=y
2+
CONFIG_SPI=y
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/led/led.h>
8+
9+
&spi3 {
10+
/* Workaround to support WS2812 driver */
11+
line-idle-low;
12+
13+
led_strip: ws2812@0 {
14+
compatible = "worldsemi,ws2812-spi";
15+
16+
/* SPI */
17+
reg = <0>; /* ignored, but necessary for SPI bindings */
18+
spi-max-frequency = <6400000>;
19+
20+
/* WS2812 */
21+
chain-length = <1>; /* arbitrary; change at will */
22+
spi-cpha;
23+
spi-one-frame = <0xf0>; /* 11110000: 625 ns high and 625 ns low */
24+
spi-zero-frame = <0xc0>; /* 11000000: 312.5 ns high and 937.5 ns low */
25+
color-mapping = <LED_COLOR_ID_GREEN
26+
LED_COLOR_ID_RED
27+
LED_COLOR_ID_BLUE>;
28+
};
29+
};
30+
31+
&pinctrl {
32+
spim3_default: spim3_default {
33+
group2 {
34+
pinmux = <SPIM3_MOSI_GPIO18>;
35+
};
36+
};
37+
};
38+
39+
/ {
40+
aliases {
41+
led-strip = &led_strip;
42+
};
43+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_WS2812_STRIP_SPI=y
2+
CONFIG_SPI=y
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/led/led.h>
8+
9+
&spi3 {
10+
/* Workaround to support WS2812 driver */
11+
line-idle-low;
12+
13+
led_strip: ws2812@0 {
14+
compatible = "worldsemi,ws2812-spi";
15+
16+
/* SPI */
17+
reg = <0>; /* ignored, but necessary for SPI bindings */
18+
spi-max-frequency = <6400000>;
19+
20+
/* WS2812 */
21+
chain-length = <1>; /* arbitrary; change at will */
22+
spi-cpha;
23+
spi-one-frame = <0xf0>; /* 11110000: 625 ns high and 625 ns low */
24+
spi-zero-frame = <0xc0>; /* 11000000: 312.5 ns high and 937.5 ns low */
25+
color-mapping = <LED_COLOR_ID_GREEN
26+
LED_COLOR_ID_RED
27+
LED_COLOR_ID_BLUE>;
28+
};
29+
};
30+
31+
&pinctrl {
32+
spim3_default: spim3_default {
33+
group2 {
34+
pinmux = <SPIM3_MOSI_GPIO48>;
35+
};
36+
};
37+
};
38+
39+
/ {
40+
aliases {
41+
led-strip = &led_strip;
42+
};
43+
};

0 commit comments

Comments
 (0)