1. X1000/platform/kernel/arch/mips/xburst/soc-x1000/chip-x1000/phoenix/common/board_base.c
添加平台驱动与平台设备代码:
#include <linux/input.h>
#include <linux/rotary_encoder.h>
//#define GPIO_ROTARY_A 1
//#define GPIO_ROTARY_B 2
static struct rotary_encoder_platform_data my_rotary_encoder_info = {
.steps = 24,
.axis = ABS_X,
.relative_axis = false,
.rollover = false,
.gpio_a = GPIO_PC(5), //GPIO_ROTARY_A, 填入实际引脚A
.gpio_b = GPIO_PC(4), //GPIO_ROTARY_B, 填入实际引脚B
.inverted_a = 0,
.inverted_b = 0,
.half_period = false,
//.wakeup_source = false,
};
static struct platform_device rotary_encoder_device = {
.name = "rotary-encoder",
.id = 0,
.dev = {
.platform_data = &my_rotary_encoder_info,
}
};
添加设备:
DEF_DEVICE(&rotary_encoder_device, 0, 0),
2. make menuconfig
勾选旋转编码器驱动:
Device Drivers ---> Input device support ---> Miscellaneous devices
---> <*> Rotary encoders connected to GPIO pins
选中用户接口, 使驱动产生 /dev/input/eventX 设备
Device Drivers ---> Input device support ---> <*> Event interface
3. 下载编译 http://elinux.org/images/9/93/Evtest.c
执行 evtest /dev/input/eventX
离线
这个顶起,我打算在V3s也加上旋转编码器。
是不是两个脚都要接中断脚上?
离线
旋转编码器,正交解码,让我想起了飞思卡尔智能车
离线
旋转编码器,正交解码,让我想起了飞思卡尔智能车
一看就是参加过竞赛的
离线
Linux里面驱动真全,这个都有
离线