毕业论文外文翻译-基于S3C6410平台和输入子系统的触摸屏驱动程序的开发.doc

上传人:豆**** 文档编号:29917801 上传时间:2022-08-02 格式:DOC 页数:17 大小:533.50KB
返回 下载 相关 举报
毕业论文外文翻译-基于S3C6410平台和输入子系统的触摸屏驱动程序的开发.doc_第1页
第1页 / 共17页
毕业论文外文翻译-基于S3C6410平台和输入子系统的触摸屏驱动程序的开发.doc_第2页
第2页 / 共17页
点击查看更多>>
资源描述

《毕业论文外文翻译-基于S3C6410平台和输入子系统的触摸屏驱动程序的开发.doc》由会员分享,可在线阅读,更多相关《毕业论文外文翻译-基于S3C6410平台和输入子系统的触摸屏驱动程序的开发.doc(17页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、中文译文:外文原文出处:The design of touch screen driver based on Linux input subsystem and S3C6410 platform作者:Liangfeng Fu, Linbo Xie, Zhigang ZhouThe internet of things Engineering Academy,Jiangnan University,Wuxi, china摘要在linux内核2.6或更高版本下,一种基于S3C6410平台和输入子系统的触摸屏驱动程序的开发。为了验证驱动功能,本文也做了它的测试。测试结果表明,触摸屏驱动程序可以正确地

2、捕获触摸坐标信息和是否发生触摸事件的状态。此外,它还可以获得滑动的实时坐标接触状态。该触摸屏驱动程序可以很容易地应用在嵌入式GUI系统如Android,QT,MiniGUI等。关键词:输入子系统,S3C6410,驱动1 简介输入设备驱动程序的开发过程有其传统的方法,这种方法通常包含对设备操作函数集file_operations()结构中函数的定义和实现。例如、open()、read()、write()、ioctl()、llseek()等等。然而,file_operations的实现往往占用了大量开发时间,也是一个容易出错的地区。为了避免做这项工作,本文设计了一个触摸屏基于Linux输入子系统和

3、S3C6410驱动平台,并进行了详细的测试过程,验证了其功能。2 分析Linux2.6内核的输入子系统A输入子系统的分析Linux内核在2.6版本引入了输入子系统的框架。这与其他子系统是同一个级别的。例如,文件系统、网络系统。输入子系统的引入能更有效地开发linux鼠标,键盘或触摸屏等驱动软件。对Linux内核各子系统的进一步研究可以看出系统包装常用特定硬件设备的功能设置。Linux输入子系统由输入驱动层、输入核心层和输入事件处理层 2 构成。在Linux系统中结构如图1所示。输入驱动层通过配置寄存器和中断处理控制具体硬件。输入设备的动作,如点击,按摸,抽象为一个事件并向输入核心层报告。这一部

4、分应该是开发人员的工作。输入核心层连接输入设备驱动和输入事件处理两层。当一个输入事件发生时,核心层从输入设备驱动层接收输入信息并通知输入事件处理层,提供输入事件处理调用接口。这部分是由内核实现。图1 Linux输入子系统的结构事件处理层通过调用输入设备驱动层的接口获得输入信息,然后将消息转换为具体结构可插入到evdev.c文件的缓冲区client_list中。使得AP(应用程序)可以很容易地得到它。此外,输入事件处理层对于每一个输入设备的驱动软件还定义了统一的事件处理设备文件节点。同时,这一部分也是由内核 3 4 实现。关于输入核心层和事件处理层为AP定义统一的文件操作的接口,输入子系统的驱动

5、只需要根据输入核心层提供接口向输入核心层报告输入信息。所以没有必要在乎关于文件的操作接口。B 输入子系统下驱动程序开发模式Linux系统下的设备驱动程序与内核的关系密不可分。内核的设备管理系统定义了一个特殊的方式找和管理的设备驱动程序,这种模式可以遵守程序的开发。在该模式下,一些描述设备的结构和功能都有自己的名称和参数,开发者不可修改的。通常,模块化的知识在驱动程序开起着的重要作用。基于Linux输入子系统的开发模式简单地归纳为 5 :1输入设备的描述结构(input_dev):这个结构定义了输入设备。2输入设备驱动的注册与注销:int input_register_device(struct

6、 input_dev *dev)int input_unregister_device(struct input_dev *dev)3输入设备驱动程序的事件支持:set_bit(event type,xxx_dev.evbit) 输入设备驱动用set_bit()通知输入子系统他们支持什么事件。input_dev结构有一个名为evbit成员,表示支持的事件。经常使用的事件类型的课程包括ev_key(按键),ev_rel(相对位置),ev_abs(绝对定位)等。关键事件,鼠标事件和触摸屏事件分为ev_key,分别ev_rel和ev_abs。4输入设备驱动的事件报告void input_report

7、_key( struct input_dev *dev,unsigned int code, int value)void input_report_rel(struct input_dev *dev,unsigned int code, int value)void input_report_abs( struct input_dev *dev,unsigned int code, int value)input_sync(input_dev)这些函数的原型分别用于报告键盘,鼠标和触摸屏事件。”code”是指输入事件。如果事件类型是ev_key,其代表按下或释放键盘上的键的动作,这是在头文件

8、include/linux/input.h指定的。“value”指的是输入事件的值。如果事件类型是ev_key,值“1”是指“按下”、值“0”是“释放”。input_sync用于事件同步,这将通知事件接收器:一个完整的报告已送过来。3电阻式触摸屏的工作原理及其与处理器S3C6410的连接A电阻式触摸屏的工作原理电阻触摸屏的主体是很薄的多层复合膜。第一层是由玻璃或有机玻璃制成的基本层。第二层是绝缘层,第三层是涂有导电的多羟基树脂层。当手指触摸屏幕时,两绝缘层因承受压力相接触。其中之一是把对坐标Y方向的通电,其电压为5V,一旦电压从0V变化,CPU 控制器检测到的变化,通过比较电压将得到的坐标Y通

9、过A/D变换。相同的的方式得到X坐标。S3C6410如下触摸屏控制器的工作模式:1正常转化模式这种模式的操作是与AIN0 AIN3相同的。可以通过配置ADCCON(ADC控制寄存器)和ADCTSC(ADC触摸屏控制寄存器)完成初始化。所有的开关和上拉电阻应关闭(重置0x58使开关关闭)。转换后的数据可以从ADCDAT0(ADC转换的数据寄存器0)中读出。2分开X/Y坐标转换模式独立的X / Y位置转换模式有两状态;一个是X坐标测量状态,另一个是Y坐标测量状态。触摸屏可使用任意一种转换状态。独立的X / Y坐标转换具体是:X坐标转换状态时对X坐标数据寄存器ADCDAT0写操作,Y坐标转换状态时对

10、Y坐标数据寄存器ADCDAT1写操作。每一次转换完成后产生的一个INT_ADC中断。3自动地X/Y坐标转换模式在这种模式下,控制器将坐标自动转换后分别写入ADCDAT0和ADCDAT1。转换完成后,INT_ADC中断将被引发。同时,ADC转换将自动关闭。对于下一个转换,应该在手动开启。4等待中断模式当触摸屏被按下或弹起时,触摸屏控制器产生中断信号(INT_TC)。这个中断信号将自动被清除。B 触摸屏与处理器S3C6410的连接四线电阻式触摸屏用于本文中的驱动程序设计。图2显示四线电阻式触摸屏和S3C6410处理器之间的连接。图2 四线电阻式触摸屏和S3C6410处理器之间的连接4通过使用Lin

11、ux输入子系统对触摸屏驱动程序的实现结合S3C6410的触摸屏控制器的工作模式与Linux输入子系统的工作原理。我们可以很容易地想象在写Linux内核模块(驱动程序是Linux内核模块)时,基于Linux输入子系统设计一个触摸屏驱动程序的主要工作实现包括模块加载/卸载功能、INT_TC/INT_ADC中断处理程序和触摸事件的报告功能。主要工作各功能如下(程序代码由于空间限制省略了) 7 8 。A模块加载功能这个函数的主要功能:应用和初始化一个输入设备、设置输入设备事件类型、注册INT_TC和INT_ADC中断、配置寄存器中设置S3C6410的工作模式为等待中断模式、注册输入设备驱动程序。B I

12、NT_TC中断处理函数的模块根据触摸屏是否被按下或释放判断ADC的开启与关闭。C INT_ADC中断处理函数模块转换原始数据后通过功能函数向输入核心层报告。D数据报告模块向输入核心层报告数据后并等待下一次触摸事件E模块卸载从内核中卸载驱动模块,释放驱动占用的资源,到这一步触摸屏驱动大部分工作已经完成。module_init(s3c6410ts_init);module_exit(s3c6410ts_remove);F触摸屏驱动触摸事件的流程在S3C6410和Linux 2.6.36基础上作者设计的处理流程如图3所示。图3 触摸屏驱动的事件流程图中,虚线表示将有中断或定时器触发的函数调用。虚线”

13、指触摸或释放将调用INT_TC中断处理函数,虚线”的意思ADC转换结束将调用INT_ADC中断处理函数,虚线”的意思定时器超时后调用函数将报告事件。为了得到更精确的坐标,本文中以八次数据转换的平均值为最终坐标数据。考虑到对坐标实时获取,触控笔滑动(按下但不释放)屏幕上,作者使用了一个定时器实现这一功能,计时器以10ms为周期向输入核心层报告坐标数据,这可以从图看出,在报告触摸事件后,再次启动ADC转换,定时器的时间长度决定实时坐标在滑动状态的准确性。5触摸屏驱动的测试在驱动程序的设计完成后,首先,它应该能被内核兼容,然后编写测试程序验证触摸屏驱动能否正常工作。A把触摸屏驱动编译进内核1)修改L

14、inux的内核配置文件和编译文件。1修改编译文件Makefile,如图4(a)所示:2 修改配置文件Kconfig,如图4(b)所示:图4 Makefile与Kconfig文件的修改2)配置内核3)编译与运行内核B 设计测试程序测试方法:首先,通过调用输入子系统提供的输入事件处理层接口和触摸屏设别驱动节点获得测试数据。然后,在串口终端打印出数据进行分析。测试程序的主要代码如下int main(void)struct input_event ev_ts;ts_fd=open(“/dev/event1”,O_RDWR); while(1)count=read(ts_fd,&ev_ts,sizeof

15、(struct input_event);for(i=0;i(int)count/sizeof(struct input_event);i+)if(EV_KEY=ev_ts.type)printf(“type:%d,code:%d,value:%dn”,ev_ts.type,ev_ts.code,ev_ts.value);if(EV_ABS=ev_ts.type)printf(“type:%d,code:%d,value:%dn”,ev_ts.type,ev_ts.code,ev_ts.value);if(EV_SYN=ev_ts.type)printf(“sys eventnnn”);clo

16、se(ts_fd);C 测试在搭建好软件与硬件平台后,交叉编译测试程序源码。#arm-linux-gcc ts_app.c o ts_app2把生成的可执行的应用程序ts_app2拷贝到开放上,运行测试程序#./ts_app2测试结果如下图:图5 测试驱动程序结果从图5可以看出,驱动程序可以很好的工作,能够准确读出触控点的坐标数据6 结论通过本文的研究,只需要改动几个寄存器的设计就可使得驱动程序适应于其它处理器架构。开发者不需要对文件操作函数设计。本文中的驱动开发包含对输入子系统的分析、如何开发linux设备驱动程序和在测试程序调用驱动获取数据。最好,比较流行的GUI系统,例如,android

17、、Qt和miniGUI也支持linux2.6版本,所以这个驱动程序可以很好地适用乣这些GUI系统。英文原文:AbstractA kind of resistive touch screen driver was developed based on S3C6410 platform and input subsystem in kernel of Linux 2.6 and higher. And to verify the drivers function, this paper also did a test for it in detail. The test results show

18、that the touch screen driver can properly capture the information of touching coordinates and up/down state.Besides, it can also obtain the real-time coordinates of sliding touch state. This touch screen driver can be easily applied in the embedded GUI systems such as android, Qt, miniGUI and etc.Ke

19、ywords:input subsystem, S3C6410, driverI. INTRODUCTIONThe process of developing an input device driver has its traditional method, that method always contains the definition and realization of the devices operational function pointers in the structure of file_operations, such as open, read, write, i

20、octl, llseek and etc 1. However, the realization of the file_operations often occupied a lot of development time, and its also an error-prone area. In order to avoid doing this work, this paper designed a touch screen driver based on Linux input subsystem and the S3C6410 platform, and a detailed tes

21、t process was given to verify its function.II. AN ANALYSIS OF THE INPUT SUBSYSTEM IN LINUX2.6 KERNELA. Input subsystems analysisThe 2.6 edition of the Linux kernel introduced an input subsystem framework. Its on the same level of other subsystems like file system and network system. The introduction

22、 of the input subsystem makes it more efficient to develop drive software of mouse, keyboard or touching screen in Linux. Further study of the subsystems in the Linux kernel shows that the system packed frequently used function sets for specific hardware devices. Linux input subsystem is constructed

23、 by input driver layer, input core layer and input event handle layer 2. And the structure within the Linux system is illustrated in Fig.1.The input driver layer control the specific hardware by configuration of registers and interrupt process. The input motion of input devices, such as click, press

24、 and touch, is abstracted into an event, which will be reported to the input core layer. And this part shall be developers workInput core layer connect two layers of input driver and event handle. When an input event occurred, the core layer receive input messages from the input layer and notice the

25、 event handle layer that an input event happened, and provide event handle a call interface. And this part is realized by the kernelFigure.1. Structure of Linux input subsystemsEvent handle layer get the input messages by calling the input layers interface, and then pack the messages into a specific

26、 structure which would be inserted into the buffer of client_list in evdev.c so that the APs(application programs) can easily get it. Besides, event handle also defined unified device file node for each input devices drive software. And this part is also realized by the kernel 3 4.Concerning that in

27、put core layer and event handle layer defined the unified file operation interfaces for AP, the drives of the input subsystems shall only report the input message to the input core according to the interface provided by the input core layer. So theres no need to care about the file operation interfa

28、ce.B. Driver development mode under the input subsystemThe device drivers under Linux system have an inseparable relationship with the kernel. The Equipment Management System in the kernel defined a special mode to seek and manage the device drivers, this mode should be abided by driver developers.

29、In the mode, some structures and functions that describe the equipment have their own names and parameter, which shall not be modified by developers. Usually, the knowledge of the modes plays a very important role in driver development.The developing mode based on Linux input system is simply conclu

30、ded as follows 5: Input devices descriptive structureinput_dev /This structure defines an input device Input device drivers register and unregisterint input_register_device(struct input_dev *dev)int input_unregister_device(struct input_dev *dev) Input device drivers event supportingset_bit(event typ

31、e,xxx_dev.evbit)The drivers use set_bit() to inform input subsystem what events they supports. The structure input_dev has a member named evbit which represent the supported events. Frequently used classes of event types include EV_KEY (press the keys), EV_REL (relative location), EV_ABS(absolute lo

32、cation) and etc. The key event, mouse event and touch screen event are sorted into EV_KEY, EV_REL and EV_ABS respectively. Input device drivers event reportingvoid input_report_key( struct input_dev *dev, unsigned int code, int value)void input_report_rel(struct input_dev *dev, unsigned int code, in

33、t value)void input_report_abs( struct input_dev *dev, unsigned int code, int value)input_sync(input_dev)These function prototypes above are used for reporting keyboard/key, mouse and touch screenevent respectively. In which the code means the code of the input event. If the event type is EV_KEY, the

34、n it represents the pressed/released buttons code on the keyboard, this is specified in the head file of /include/linux/input.h. And the value means the value of the input event. If the event type is EV_KEY, the value of 1 refers to a press action and 0 refers to a release action. input_sync used fo

35、r the synchronization of event, which will inform the event receiver that a complete report has been sent overIII. RESISTIVE TOUCH SCREENS WORKING PRINCIPLE AND ITS CONNECTION WITH PROCESSOR S3C6410A. The working principles of resistive touch screenThe body of the resistive touching screen is a thin

36、 multi-layer composite film that fits the monitor well. The first layer is the basic layer made by glass or organic glass. The second layer is the insulate layer and the third layer is the polyhydric resin layer which is coated with a conductive layer. When ones finger touch the screen, the two insu

37、lated layer come together under pressure. And one of them is put through the uniformed voltage field of the coordinate Y, whose voltage is 5V, which makes the voltage of determinative layer change from 0V. Once the CPUs controller detected the change, it would get the coordinate of Y by compare the

38、voltage with 5V through A/D transform. The coordinate of X would be got at the same way.The operation modes of touch screen controller of S3C6410 are as follows 6:C6410 are as follows 6: Normal Conversion Mode The operation of this mode is identical with AIN0AIN3s. It can be initialized by setting t

39、he ADCCON (ADC Control Register) and ADCTSC (ADC touch screen control register). All of the switches and pull-up resister should be turned off (reset value 0x58 makes switches turn-off). The converted data can be read out from ADCDAT0 (ADC conversion data 0 register). Separate X/Y position conversio

40、n Mode This mode consists of two states; one is X-position measurement state and the other is Y-position measurement state. The touch screen can use either of the conversion state. A single X/Y coordinates conversion is describe like this: The X Bcoordinate state write the converted X coordinate dat

41、a into register ADCDAT0, and the Y coordinate state write the converted Y coordinate data into register ADCDAT1. An INT_ADC interrupt is generated each time the conversion is done. Automatic mode of X/Y coordinates transform In this mode, the controller converts the coordinates automatically and wri

42、tes them into ADCDAT0 and ADCDAT1 respectively. An INT_ADC interrupt will be triggered once theconversion is done, and then the ADC conversion will be closed up automatically at the same time. For the next conversion, it should be turn on manually. Waiting for interrupt modeTouch screen controller g

43、enerates an interrupt signal (INT_TC) when the stylus pen is down or up. And this interrupt signal will be cleared automatically.B. The connections between S3C6410 and touch screenA four-line resistive touch screen is utilized for the design of its driver in this article. Fig.2 shows the connections

44、 between the four-line resistive touch screen and the S3C6410 processor.Figure.2. The circuit connection between touch screen and the S3C6410 processorIV. THE REALIZATION OF TOUCH SCREEN DRIVER BY USING LINUX INPUT SUBSYSTEMCombining the operation mode of S3C6410s touchscreen controller, the princip

45、le of Linux input subsystem, and the general rules to write a kernel module in Linux (driver is a kernel module in Linux), we can easily imagine that the major work of designing a touch screen driver based on Linux input subsystem include the realization of module load/unload functions, the INT_TC/I

46、NT_ADC interrupt handler, and the touch-events report function. Main work of each function is summarized as follows (program codes are omitted as the space limitations) 7 8.A.The function for module loadingThe main tasks of this function are as follows: applying and initializing an input device, set

47、ting the event types of the input device, registering the INT_TC and INT_ADC interrupt, configuring registers to set s3c6410 work in the interrupt mode of wait for touching, registering an input-device driver.B. The function of the INT_TC interrupt handlerThe INT_TC interrupt will be triggered when

48、touch screen is touched or released, this interrupt handler function can judge the touch screens state(touched or released) by reading the value of touch screen controllers data register on S3C6410 ,this will determine whether to open the ADC converter or not.C. The function of the INT_ADC interrupt handlerThe INT_ADC interrupt will be triggered at the end of every ADC conversion. this interrupt handler

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁