feat: 添加LED灯带模块支持

- 在CMakeLists.txt中添加led_strip_module.c源文件和led_strip_en_event.c事件文件
- 在设备树配置中添加SPI1接口的WS2812灯带引脚控制配置
- 在板级配置文件中添加LED灯带设备节点和别名定义
- 新增led_strip_en_event事件头文件和实现,用于控制灯带使能状态
- 配置prj.conf启用LED Strip和WS2812 SPI驱动
- 实现完整的LED灯带模块功能,包括:
  - 初始化和电源管理
  - RGB色彩效果渲染
  - 通过GPIO控制灯带供电
  - 响应应用事件进行启停控制
This commit is contained in:
2026-04-13 15:23:46 +08:00
parent 968fb626bb
commit ff8f0d81d7
7 changed files with 376 additions and 0 deletions

View File

@@ -46,6 +46,21 @@
};
};
spi1_ws2812_default: spi1_ws2812_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 4)>,
<NRF_PSEL(SPIM_MOSI, 0, 20)>;
};
};
spi1_ws2812_sleep: spi1_ws2812_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 4)>,
<NRF_PSEL(SPIM_MOSI, 0, 20)>;
low-power-enable;
};
};
pwm0_default: pwm0_default {
group1 {
psels = <NRF_PSEL(PWM_OUT0, 1, 11)>;

View File

@@ -2,6 +2,7 @@
#include <nordic/nrf52840_qiaa.dtsi>
#include "mini_keyboard-pinctrl.dtsi"
#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/led/led.h>
#include <zephyr/dt-bindings/mipi_dbi/mipi_dbi.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
@@ -14,10 +15,12 @@
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
zephyr,display = &screen_lcd;
zephyr,led-strip = &led_strip;
};
aliases {
led0 = &myled0;
led-strip = &led_strip;
qdec0 = &qdec;
backlight = &backlight;
};
@@ -206,6 +209,28 @@
cs-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
};
&spi1 {
status = "okay";
pinctrl-0 = <&spi1_ws2812_default>;
pinctrl-1 = <&spi1_ws2812_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
reg = <0>;
spi-max-frequency = <6400000>;
chain-length = <17>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
bits-per-symbol = <8>;
reset-delay = <8>;
supply-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
};
};
&pwm0 {
status = "okay";
pinctrl-0 = <&pwm0_default>;