feat(encoder): 添加编码器模块支持

- 在CMakeLists.txt中添加encoder_module.c和encoder_event.c源文件
- 配置设备树pinctrl设置编码器引脚(QDEC_A和QDEC_B)
- 在设备树中启用qdec外设并配置相关参数
- 添加atguigu厂商前缀到vendor-prefixes.txt
- 创建encoder_event.h事件头文件定义编码器事件结构
- 在prj.conf中启用NRFX_QDEC和PINCTRL_DYNAMIC配置
- 实现encoder_module.c包含完整的编码器驱动逻辑
- 实现encoder_event.c处理编码器事件的发布和记录
This commit is contained in:
2026-04-10 10:40:28 +08:00
parent b9bb326e8b
commit e226338565
8 changed files with 308 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include "encoder_event.h"
static void log_encoder_event(const struct app_event_header *aeh)
{
const struct encoder_event *event = cast_encoder_event(aeh);
APP_EVENT_MANAGER_LOG(aeh, "detents:%d", event->detents);
}
static void profile_encoder_event(struct log_event_buf *buf,
const struct app_event_header *aeh)
{
const struct encoder_event *event = cast_encoder_event(aeh);
nrf_profiler_log_encode_int8(buf, event->detents);
}
APP_EVENT_INFO_DEFINE(encoder_event,
ENCODE(NRF_PROFILER_ARG_S8),
ENCODE("detents"),
profile_encoder_event);
APP_EVENT_TYPE_DEFINE(encoder_event,
log_encoder_event,
&encoder_event_info,
APP_EVENT_FLAGS_CREATE(
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));