samples: led_ws2812: add example for Everlight B1414
This patch adds a devicetree configuration example for the Everlight
B1414 LED controller.
An overlay for the nucleo_f070rb board is provided. It assumes that
a B1414 LED controller is connected to the PA7 pin (SPI 1 MOSI). The
WS2812 SPI driver is used.
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
diff --git a/samples/drivers/led_ws2812/README.rst b/samples/drivers/led_ws2812/README.rst
index c8b5a28..f8dd176 100644
--- a/samples/drivers/led_ws2812/README.rst
+++ b/samples/drivers/led_ws2812/README.rst
@@ -8,7 +8,7 @@
This sample application demonstrates basic usage of the WS2812 LED
strip driver, for controlling LED strips using WS2812, WS2812b,
-SK6812, and compatible driver chips.
+SK6812, Everlight B1414 and compatible driver chips.
Requirements
************
diff --git a/samples/drivers/led_ws2812/boards/nucleo_f070rb.conf b/samples/drivers/led_ws2812/boards/nucleo_f070rb.conf
new file mode 100644
index 0000000..36185d5
--- /dev/null
+++ b/samples/drivers/led_ws2812/boards/nucleo_f070rb.conf
@@ -0,0 +1,2 @@
+CONFIG_SPI=y
+CONFIG_SPI_STM32_DMA=y
diff --git a/samples/drivers/led_ws2812/boards/nucleo_f070rb.overlay b/samples/drivers/led_ws2812/boards/nucleo_f070rb.overlay
new file mode 100644
index 0000000..00a054f
--- /dev/null
+++ b/samples/drivers/led_ws2812/boards/nucleo_f070rb.overlay
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 Seagate Technology LLC
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <dt-bindings/led/led.h>
+
+#include "../f070rb-bindings.h"
+
+&spi1 { /* MOSI on PA7 */
+ dmas = <&dma1 3 0 0x20440 0x03>, <&dma1 2 0 0x20480 0x03>;
+ dma-names = "tx", "rx";
+
+ led_strip: b1414@0 {
+ compatible = "everlight,b1414", "worldsemi,ws2812-spi";
+ label = "B1414";
+
+ /* SPI */
+ reg = <0>; /* ignored, but necessary for SPI bindings */
+ spi-max-frequency = <B1414_SPI_FREQ>;
+
+ /* B1414 */
+ chain-length = <18>; /* arbitrary; change at will */
+ spi-one-frame = <B1414_ONE_FRAME>;
+ spi-zero-frame = <B1414_ZERO_FRAME>;
+ color-mapping = <LED_COLOR_ID_BLUE
+ LED_COLOR_ID_GREEN
+ LED_COLOR_ID_RED>;
+
+ reset-delay = <250>;
+ status = "okay";
+ };
+};
+
+&dma1 {
+ status = "okay";
+};
+
+/ {
+ aliases {
+ led-strip = &led_strip;
+ };
+};
diff --git a/samples/drivers/led_ws2812/f070rb-bindings.h b/samples/drivers/led_ws2812/f070rb-bindings.h
new file mode 100644
index 0000000..3aa138b
--- /dev/null
+++ b/samples/drivers/led_ws2812/f070rb-bindings.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2021 Seagate Technology LLC
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef ZEPHYR_SAMPLES_DRIVERS_LED_WS2812_F070RB_BINDINGS_H
+#define ZEPHYR_SAMPLES_DRIVERS_LED_WS2812_F070RB_BINDINGS_H
+
+/*
+ * Everlight B1414 LED controller;
+ *
+ * Each bit of the control signal (waveform) is described with a 1.2 us pulse:
+ * 0 bit: 300 ns high and 900 ns low.
+ * 1 bit: 900 ns high and 300 ns low.
+ *
+ * At 6 MHz, one bit represents 166.666 ns.
+ * 1200 ns -> 7.2 bits
+ * 300 ns -> 1.8 bits
+ * 900 ns -> 5.4 bits
+ */
+#define B1414_SPI_FREQ 6000000
+#define B1414_ZERO_FRAME 0x60
+#define B1414_ONE_FRAME 0x7C
+
+#endif