在人机交互系统中,键盘、触摸屏等输入设备是一个不可或缺的部分,触摸屏以其非常良好的用户体验得到了广泛的应用。此处以ft5206电容屏为例,实现Linux内核上的驱动。
1、ft5206设备
电容屏为i2c接口,用i2c_board_info来构建ft5206 i2c设备信息表。
#include <linux/input/ft5x06_ts.h>static struct ft5x06_ts_platform_data ft5x06 = {.irq_gpio= S3C2410_GPG(4),.rst_gpio= S3C2410_GPF(5),};static struct i2c_board_info home2416_i2c_devs[] __initdata = {{I2C_BOARD_INFO("ft5206",0x38),.platform_data= &ft5x06;},};
在板级初始化函数home2416_machine_init()中注册i2c设备:
i2c_register_board_info(0,home2416_i2c_devs, ARRAY_SIZE(home2416_i2c_devs));
根据其它i2c电容屏驱动实现,编写ft5x06驱动,ft5x06_ts.c/ ft5x06_ts.h,具体源码可以参考/drivers/input/touchscreen/ft5x06_ts.c、/include/linux/input/ft5x06_ts.h。
在/drivers/input/touchscreen/Makefile中加入ft5x06的内核编译实现。
obj-$(CONFIG_TOUCHSCREEN_FT5X06) +=ft5x06_ts.o
在/drivers/input/touchscreen/Kconfig中加入ft5x06的内核配置。
config TOUCHSCREEN_FT5X06tristate"FocalTech FT5x06 I2C Touchscreen support"dependson I2ChelpSay Y here to enable FocalTech ft5x06touchscreen support.If unsure, say N.To compile this driver as a module, choose Mhere: themodule will be called ft5x06.
2、内核配置
Linux配置支持ft5x06设备驱动,选中Device Drivers->Input device support->Touchscreens->FocalTechFT5x06 I2C Touchscreen support。

3、触摸屏测试
cat /proc/bus/input/devices知道触摸屏设备文件在/dev/input/event1,用hexdump测试触摸屏功能。

hexdump /dev/input/event1。

4、附录
| 文件 | 源码下载 |
|---|---|
| bootloader源码以及使用说明 | https://pan.baidu.com/s/1slczwhJ |
| Qt5.8官网源码 | https://pan.baidu.com/s/1eRDJtNs |
| 本系列例程的根文件系统 | https://pan.baidu.com/s/1nuGmSqt |
| opev3.2.0官网源码 | https://pan.baidu.com/s/1i5btLGT |
| yaffs官网源码 | https://pan.baidu.com/s/1pLpuHw3 |
| busybox-1.26.2官网源码 | https://pan.baidu.com/s/1bpkZynt |
| tslib官网源码 | https://pan.baidu.com/s/1i4EtjfR |
| mplayer-1.3.0官网源码 | https://pan.baidu.com/s/1i5MGRhb |
| 基于S3C2416修改的linux-4.10.10源码 | https://pan.baidu.com/s/1sl0fXlr |
