- 在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控制灯带供电 - 响应应用事件进行启停控制
28 lines
818 B
C
28 lines
818 B
C
#include "led_strip_en_event.h"
|
|
|
|
static void log_led_strip_en_event(const struct app_event_header *aeh)
|
|
{
|
|
const struct led_strip_en_event *event = cast_led_strip_en_event(aeh);
|
|
|
|
APP_EVENT_MANAGER_LOG(aeh, "enabled:%u", event->enabled);
|
|
}
|
|
|
|
static void profile_led_strip_en_event(struct log_event_buf *buf,
|
|
const struct app_event_header *aeh)
|
|
{
|
|
const struct led_strip_en_event *event = cast_led_strip_en_event(aeh);
|
|
|
|
nrf_profiler_log_encode_uint8(buf, event->enabled);
|
|
}
|
|
|
|
APP_EVENT_INFO_DEFINE(led_strip_en_event,
|
|
ENCODE(NRF_PROFILER_ARG_U8),
|
|
ENCODE("enabled"),
|
|
profile_led_strip_en_event);
|
|
|
|
APP_EVENT_TYPE_DEFINE(led_strip_en_event,
|
|
log_led_strip_en_event,
|
|
&led_strip_en_event_info,
|
|
APP_EVENT_FLAGS_CREATE(
|
|
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));
|