imx6 matrix keyboard
imx6需要添加4x4的矩阵键盘。本文记录添加方法。
参考链接
http://processors.wiki.ti.com/index.php/TI-Android-JB-PortingGuide
http://blog.sina.com.cn/s/blog_54aa47930102vesb.html
http://blog.csdn.net/shell_albert/article/details/46801091
http://www.kikikoo.com/uid-20768928-id-5084287.html
http://blog.csdn.net/shell_albert/article/details/46618655
添加驱动
驱动源码driver/input/keyboard/matrix_keypad.c
CONFIG_KEYBOARD_MATRIX:
Enable support for GPIO driven matrix keypad.
To compile this driver as a module, choose M here: the
module will be called matrix_keypad.
Symbol: KEYBOARD_MATRIX [=y]
Type : tristate
Prompt: GPIO driven matrix keypad support
Defined at drivers/input/keyboard/Kconfig:224
Depends on: !S390 && INPUT [=y] && INPUT_KEYBOARD [=y] && GENERIC_GPIO [=y]
Location:
-> Device Drivers
-> Input device support
-> Generic input layer (needed for keyboard, mouse, ...) (INPUT [=y])
-> Keyboards (INPUT_KEYBOARD [=y])
添加设备
vi arch/arm/mach-mx6/board-mx6q_sabresd.c
// COL
#define SABRESD_KEY0 IMX_GPIO_NR(4, 6)
#define SABRESD_KEY1 IMX_GPIO_NR(4, 8)
#define SABRESD_KEY2 IMX_GPIO_NR(4, 10)
#define SABRESD_KEY3 IMX_GPIO_NR(4, 12)
// ROW
#define SABRESD_KEY4 IMX_GPIO_NR(4, 7)
#define SABRESD_KEY5 IMX_GPIO_NR(4, 9)
#define SABRESD_KEY6 IMX_GPIO_NR(4, 11)
#define SABRESD_KEY7 IMX_GPIO_NR(4, 13)
static const uint32_t sabresd_keymap[] = {
KEY(0, 0, KEY_ESC),
KEY(0, 1, KEY_0),
KEY(0, 2, KEY_1),
KEY(0, 3, KEY_OK),
KEY(1, 0, KEY_2),
KEY(1, 1, KEY_3),
KEY(1, 2, KEY_4),
KEY(1, 3, KEY_5),
KEY(2, 0, KEY_6),
KEY(2, 1, KEY_7),
KEY(2, 2, KEY_8),
KEY(2, 3, KEY_9),
KEY(3, 0, KEY_F1),
KEY(3, 1, KEY_0),
KEY(3, 2, KEY_F2),
KEY(3, 3, KEY_F3),
};
static const struct matrix_keymap_data sabresd_keymap_data = {
.keymap = sabresd_keymap,
.keymap_size = ARRAY_SIZE(sabresd_keymap),
};
static const unsigned int sabresd_keypad_cols[] = {
SABRESD_KEY0,
SABRESD_KEY1,
SABRESD_KEY2,
SABRESD_KEY3,
};
static const unsigned int sabresd_keypad_rows[] = {
SABRESD_KEY4,
SABRESD_KEY5,
SABRESD_KEY6,
SABRESD_KEY7,
};
static struct matrix_keypad_platform_data sabresd_kpd_pdata = {
.keymap_data = &sabresd_keymap_data,
.col_gpios = sabresd_keypad_cols,
.row_gpios = sabresd_keypad_rows,
.num_col_gpios = ARRAY_SIZE(sabresd_keypad_cols),
.num_row_gpios = ARRAY_SIZE(sabresd_keypad_rows),
.col_scan_delay_us = 10,
.debounce_ms = 10,
.wakeup = 1,
.active_low = 1,
//.active_low = 0,
};
static struct platform_device sabresd_keypad = {
.name = "matrix-keypad",
.id = -1,
.dev = {
.platform_data = &sabresd_kpd_pdata,
},
};
再添加初始化函数
static void __init mx6_sabresd_board_init(void)
{
......
platform_device_register(&sabresd_keypad)
......
}
查看效果
root@android:/data # cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="gpio-keys"
P: Phys=gpio-keys/input0
S: Sysfs=/devices/platform/gpio-keys/input/input0
U: Uniq=
H: Handlers=event0
B: PROP=0
B: EV=3
B: KEY=100000 0 0 0
I: Bus=0019 Vendor=0000 Product=0000 Version=0000
N: Name="matrix-keypad"
P: Phys=
S: Sysfs=/devices/platform/matrix-keypad/input/input1
U: Uniq=
H: Handlers=event1
B: PROP=0
B: EV=100013
B: KEY=1 0 0 0 0 0 0 0 0 0 38000000 ffe
B: MSC=10
I: Bus=0003 Vendor=09da Product=c10a Version=0110
N: Name="A4Tech USB Mouse"
P: Phys=usb-fsl-ehci.1-1.3/input0
S: Sysfs=/devices/platform/fsl-ehci.1/usb2/2-1/2-1.3/2-1.3:1.0/input/input2
U: Uniq=
H: Handlers=mouse0 event2
B: PROP=0
B: EV=1f
B: KEY=ff0000 0 0 0 0 0 0 0 0
B: REL=303
B: ABS=1f00 0
B: MSC=10
root@android:/data # getevent
could not get driver version for /dev/input/mice, Not a typewriter
add device 1: /dev/input/event2
name: "A4Tech USB Mouse"
could not get driver version for /dev/input/mouse0, Not a typewriter
add device 2: /dev/input/event1
name: "matrix-keypad" # matrix-keypad
add device 3: /dev/input/event0
name: "gpio-keys" # gpio-keys```
Tony Liu
2016-12-30, Shenzhen
imx6 matrix keyboard的更多相关文章
- EDA课设-交通灯-Verilog版----FPGA--004
分得到析四个状态: S1: 主干道(绿灯亮) ,支干道(亮红灯):--40S S1: 主干道 (黄灯亮) ,支干道(亮红灯):--4S S1: 主干道 (亮红灯),支干道(绿灯亮):--20S S1: ...
- EasyMonkeyDevice vs MonkeyDevice&HierarchyViewer API Mapping Matrix
1. 前言 本来这次文章的title是写成和前几篇类似的<EasyMonkeyDevice API实践全记录>,内容也打算把每一个API的实践和建议给记录下来,但后来想了下认为这样子并非最 ...
- EasyMonkeyDevice vs MonkeyDevice&HierarchyViewer API Mapping Matrix
1. 前言 本来这次文章的title是写成和前几篇类似的<EasyMonkeyDevice API实践全记录>,内容也打算把每个API的实践和建议给记录下来,但后来想了下觉得这样子并不是最 ...
- angular2系列教程(十一)路由嵌套、路由生命周期、matrix URL notation
今天我们要讲的是ng2的路由的第二部分,包括路由嵌套.路由生命周期等知识点. 例子 例子仍然是上节课的例子:
- Pramp mock interview (4th practice): Matrix Spiral Print
March 16, 2016 Problem statement:Given a 2D array (matrix) named M, print all items of M in a spiral ...
- Fedora 22中的Locale and Keyboard Configuration
Introduction The system locale specifies the language settings of system services and user interface ...
- Atitit Data Matrix dm码的原理与特点
Atitit Data Matrix dm码的原理与特点 Datamatrix原名Datacode,由美国国际资料公司(International Data Matrix, 简称ID Matrix)于 ...
- Android笔记——Matrix
转自:http://www.cnblogs.com/qiengo/archive/2012/06/30/2570874.html#translate Matrix的数学原理 在Android中,如果你 ...
- 通过Matrix进行二维图形仿射变换
Affine Transformation是一种二维坐标到二维坐标之间的线性变换,保持二维图形的"平直性"和"平行性".仿射变换可以通过一系列的原子变换的复合来 ...
随机推荐
- 了解Solr6.1结构及实现原理
Solr是一个高性能,采用Java5开发,基于Lucene的全文搜索服务器.同时对其进行了扩展,提供了比Lucene更为丰富的查询语言,同时实现了可配置.可扩展并对查询性能进行了优化,并且提供了一个完 ...
- spring mvc 请求转发和重定向(转)
spring mvc controller间跳转 重定向 传参 url:http://zghbwjl.blog.163.com/blog/static/12033667220137795252845/ ...
- UVA 11481 Arrange the Numbers(组合数学 错位排序)
题意:长度为n的序列,前m位恰好k位正确排序,求方法数 前m位选k个数正确排,为cm[m][k],剩余m - k个空位,要错排,这m - k个数可能是前m个数中剩下的,也可能来自后面的n - m个数 ...
- html标准
html1.使用双引号2. <img src=""> 不添加/3. <html lang="zh-CN">4. <a class= ...
- ios数据永久存储之----NSUserDefaults
我们在开发app时不可避免的会在本地存储一些数据,NSUserDefaults就是系统提供的一个用来数据存储的类,本片文章就来介绍一些NSserdefazults的用法. 详细内容:https://m ...
- Android入门(一):Android发展史
Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发.尚未有统一中文名称,中国大陆地区较多人使用“安卓” ...
- HTML5的视频和音频
1.HTML5视频 HTML5 规定了一种通过 video 元素来包含视频的标准方法. <!DOCTYPE html> <html> <head> <meta ...
- 目录的文件权限-X
所有目录务必保持具有X权限(可执行权限)!!,否则无法进入该目录及子目录,且无法读取该目录及子目录下的文件或子目录
- dedecms有条件sql注入(x0day)
https://www.t00ls.net/thread-35569-1-1.html http://localhost/dedecms/plus/advancedsearch.php?mid=1&a ...
- HTML5 WEB SQL
var database = openDatabase("student1", "1.0", "学生表", 1024 * 1024, fun ...