buf[0]=i2c_smbus_read_byte_data(ts>client, 0x12);
buf[1]=i2c_smbus_read_byte_data(ts>client, 0x13);
buf[2]=i2c_smbus_read_byte_data(ts>client, 0x14);
buf[3]=i2c_smbus_read_byte_data(ts>client, 0x15);
buf[4]=i2c_smbus_read_byte_data(ts>client, 0x16);
buf[5]=i2c_smbus_read_byte_data(ts>client, 0x17);
buf[6]=i2c_smbus_read_byte_data(ts>client, 0x18);
buf[7]=i2c_smbus_read_byte_data(ts>client, 0x19);
buf[8]=i2c_smbus_read_byte_data(ts>client, 0x1a);
buf[9]=i2c_smbus_read_byte_data(ts>client, 0x1b);
buf[10]=i2c_smbus_read_byte_data(ts>client, 0x1c);
buf[11]=i2c_smbus_read_byte_data(ts>client, 0x1d);
buf[12]=i2c_smbus_read_byte_data(ts>client, 0x1e);
buf[13]=i2c_smbus_read_byte_data(ts>client, 0x1f);
(2) 触摸屏事件信息上报
通过对buf数组的分析,获取当前事件具体信息,然后通过input_report系列函数进行事件信息的应用层上报:
if(fingermark==2){
input_report_key(ts>input_dev,ABS_MT_TRACKING_ID,0);
input_report_abs(ts>input_dev, ABS_MT_TOUCH_MAJOR, f1z);
input_report_abs(ts>input_dev, ABS_MT_POSITION_X, f1x);
input_report_abs(ts>input_dev, ABS_MT_POSITION_Y, f1y);
input_mt_sync(ts>input_dev);
input_report_key(ts>input_dev,ABS_MT_TRACKING_ID,1);
input_report_abs(ts>input_dev, ABS_MT_TOUCH_MAJOR, f2z);
input_report_abs(ts>input_dev, ABS_MT_POSITION_X, f2x);
input_report_abs(ts>input_dev, ABS_MT_POSITION_Y, f2y);
input_mt_sync(ts>input_dev)
input_sync(ts>input_dev);
}
else if(fingermark==1){
input_report_key(ts>input_dev,ABS_MT_TRACKING_ID,0);
input_report_abs(ts>input_dev, ABS_MT_TOUCH_MAJOR, f1z);
input_report_abs(ts>input_dev, ABS_MT_POSITION_X, f1x);
input_report_abs(ts>input_dev, ABS_MT_POSITION_Y, f1y);
input_mt_sync(ts>input_dev);
input_sync(ts>input_dev);
}
else{
input_report_abs(ts>input_dev, ABS_MT_TOUCH_MAJOR, 0);
input_mt_sync(ts>input_dev);
input_sync(ts>input_dev);
}
2.3 Cypress 7958驱动在内核中的移植
通过改写Makefile与KCONFIG完成Cypress 7985在内核中的移植,以帮助GCC工具链实现对内核的编译。
2.3.1 Kconfig的修改
在/driver/input/touchscreen/Kconfig中添加如下语句:
config TOUCHSCREEN_CYPRESS
tristate "CYPRESS 7958 touchscreens"
help
Say Y here if you have a CYPRESS 7958 touchscreen connected to your system .
If unsure, say N.
以实现将文件编译选项添加到MAKE MENUCONFIG中。由于触摸屏驱动属于系统基本输入设备驱动,本身调用了I/O中断,不能实现模块编译,只能完全编译进内核。在后续的研发中发现可以使用时钟中断将其模块化编译进内核,但由于时钟中断影响UCLINUX时间片的运行,故弃之不用。
2.3.2 Makefile的修改
然后在/driver/input/touchscreen/Makefile中添加对应编译信息:
obj$(CONFIG_TOUCHSCREEN_CYPRESS) +=touchscreen_cypress.o
最终在编译选项中将/MAKEFILE中的ARCH选项设置为S3C6410,在make menuconfig命令之后的选项中选择TOUCHSREEN_CYPRESS选项并选择编译进内核。
结语
本设计以I2C方式对多点触摸屏进行驱动,通过嵌入式Linux将多点触摸输入方式应用到嵌入式应用系统中,丰富了单一的键盘输入与单点输入方式, 减小了系统尺寸,提高了系统的可靠性。使得嵌入式系统的输入方式简单易行,同时也增强了嵌入式系统与人之间的通信能力,简化了繁琐的调试。采用三星公司的S3C6410 ARM11处理器,加快了实验的操作步骤。实践证明,该设计驱动多点触摸屏幕的速度以及稳定性满足调试要求。该设计只需对底层驱动进行简单修改,就可直接应用于单片机以及其他全部可以运行Linux的嵌入式系统中。