- 在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处理编码器事件的发布和记录
34 lines
577 B
Plaintext
34 lines
577 B
Plaintext
&pinctrl {
|
|
i2c0_default: i2c0_default {
|
|
group1 {
|
|
psels = <NRF_PSEL(TWIM_SDA, 1, 0)>,
|
|
<NRF_PSEL(TWIM_SCL, 0, 24)>;
|
|
};
|
|
};
|
|
|
|
i2c0_sleep: i2c0_sleep {
|
|
group1 {
|
|
psels = <NRF_PSEL(TWIM_SDA, 1, 0)>,
|
|
<NRF_PSEL(TWIM_SCL, 0, 24)>;
|
|
low-power-enable;
|
|
};
|
|
};
|
|
|
|
encoder_default: encoder_default {
|
|
group1 {
|
|
psels = <NRF_PSEL(QDEC_A, 0, 10)>,
|
|
<NRF_PSEL(QDEC_B, 1, 6)>;
|
|
bias-pull-up;
|
|
};
|
|
};
|
|
|
|
encoder_sleep: encoder_sleep {
|
|
group1 {
|
|
psels = <NRF_PSEL(QDEC_A, 0, 10)>,
|
|
<NRF_PSEL(QDEC_B, 1, 6)>;
|
|
low-power-enable;
|
|
bias-pull-up;
|
|
};
|
|
};
|
|
};
|