现在的位置: 首页 > 综合 > 正文

Linux-2.6.32.2内核在mini2440上的移植(九)—触摸屏驱动移植

2013年08月02日 ⁄ 综合 ⁄ 共 15191字 ⁄ 字号 评论关闭

Linux-2.6.32.2内核在mini2440上的移植(九)---触摸屏驱动移植


移植环境(红色粗字体字修改后内容,蓝色粗体字为特别注意内容)

1,主机环境:VMare下CentOS 5.5 ,1G内存。

2,集成开发环境:Elipse IDE

3,编译编译环境:arm-linux-gcc v4.4.3,arm-none-linux-gnueabi-gcc v4.5.1。

4,开发板:mini2440,2M nor flash,128M nand flash。

5,u-boot版本:u-boot-2009.08

6,linux 版本:linux-2.6.32.2

7,参考文章:

嵌入式linux应用开发完全手册,韦东山,编著。

Mini2440 之Linux 移植开发实战指南

博主黄刚嵌入式Linux之我行——S3C2440上ADC驱动实例开发讲解

【1】在内核中添加触摸屏驱动程序

Linux-2.6.32.2 内核也没有包含支持S3C2440 的触摸屏驱动,因此友善官方自行设计了一个s3c2410_ts.c,它位于linux-src/drivers/input/touchscreen 目录下,你可以自己增加一个s3c2410_ts.c 文件,并复制如下内容:

#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/serio.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/gpio.h>
#include <asm/io.h>
#include <asm/irq.h>

#include <plat/regs-adc.h>
#include <mach/regs-gpio.h>

/* For ts.dev.id.version */
#define S3C2410TSVERSION 0x0101

/*定义一个WAIT4INT宏,该宏将对ADC触摸屏控制寄存器进行操作
S3C2410_ADCTSC_YM_SEN这些宏都定义在regs-adc.h中*/
#define WAIT4INT(x)  (((x)<<8) | \
       S3C2410_ADCTSC_YM_SEN | S3C2410_ADCTSC_YP_SEN | S3C2410_ADCTSC_XP_SEN | \
       S3C2410_ADCTSC_XY_PST(3))

#define AUTOPST      (S3C2410_ADCTSC_YM_SEN | S3C2410_ADCTSC_YP_SEN | S3C2410_ADCTSC_XP_SEN | \
       S3C2410_ADCTSC_AUTO_PST | S3C2410_ADCTSC_XY_PST(0))

//static char *s3c2410ts_name = "s3c2410 TouchScreen";
#define DEVICE_NAME   "mini2440_TouchScreen"
/*设备名称*/

static struct input_dev *ts_dev;/*定义一个输入设备来表示我们的触摸屏设备*/

static long xp;
static long yp;
static int count;

/*定义一个外部的信号量ADC_LOCK,因为ADC_LOCK在ADC驱动程序中已申明
这样就能保证ADC资源在ADC驱动和触摸屏驱动中进行互斥访问*/
extern struct semaphore ADC_LOCK;
static int OwnADC = 0;

static void __iomem *base_addr;/*定义了一个用来保存经过虚拟映射后的内存地址*/

static inline void s3c2410_ts_connect(void)
{
 s3c2410_gpio_cfgpin(S3C2410_GPG(12), S3C2410_GPG12_XMON);
 s3c2410_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPG13_nXPON);
 s3c2410_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPG14_YMON);
 s3c2410_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPG15_nYPON);
}

static void touch_timer_fire(unsigned long data)
{
 
/*用于记录这一次AD转换后的值*/
   unsigned long data0;
   unsigned long data1;
 int updown;
/*用于记录触摸屏操作状态是按下还是抬起*/

   data0 = ioread32(base_addr+S3C2410_ADCDAT0);
   data1 = ioread32(base_addr+S3C2410_ADCDAT1);
 /*记录这一次对触摸屏是压下还是抬起,该状态保存在数据寄存器的第15位,所以需要逻辑与上S3C2410_ADCDAT0_UPDOWN*/
  updown = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && (!(data1 & S3C2410_ADCDAT0_UPDOWN));

  if (updown)/*判断触摸屏的操作状态*/
 {
 
 /*如果状态是按下,并且ADC已经转换了就报告事件和数据*/
   if (count != 0)
//转换四次后进行事件汇报
  {
   long tmp;
                                                                                                
   tmp = xp;
   xp = yp;
   yp = tmp;
   //这里进行转换是因为我们的屏幕使用时采用的是240*320,相当于把原来的屏幕的X,Y 轴变换。
   //个人理解,不知是否正确      
   
                        
   
//设备X,Y 值     
                               
         xp >>= 2;
         yp >>= 2;
#ifdef CONFIG_TOUCHSCREEN_MINI2440_DEBUG
           
/*触摸屏调试信息,编译内核时选上此项后,点击触摸屏会在终端上打印出坐标信息*/
            struct timeval tv;
            do_gettimeofday(&tv);
            printk(KERN_DEBUG "T: %06d, X: %03ld, Y: %03ld\n", (int)tv.tv_usec, xp, yp);
#endif
    input_report_abs(ts_dev, ABS_X, xp);
    input_report_abs(ts_dev, ABS_Y, yp);
   
/*报告按键事件,键值为1(代表触摸屏对应的按键被按下)*/
    input_report_key(ts_dev, BTN_TOUCH, 1);
   
/*报告触摸屏的状态,1表明触摸屏被按下*/
    input_report_abs(ts_dev, ABS_PRESSURE, 1);
  
 /*等待接收方受到数据后回复确认,用于同步*/
    input_sync(ts_dev);
  
 //这个表明我们上报了一次完整的触摸屏事件,用来间隔下一次的报告
   }
  /*如果状态是按下,并且ADC还没有开始转换就启动ADC进行转换*/
   xp = 0;
   yp = 0;
   count = 0;
  
/*设置触摸屏的模式为自动转换模式*/
   iowrite32(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, base_addr+S3C2410_ADCTSC);
 
 /*启动ADC转换*/
   iowrite32(ioread32(base_addr+S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, base_addr+S3C2410_ADCCON);
  
//如果还没有启动ADC 或者ACD 转换四次完毕后则启动ADC
  }
 else
/*否则是抬起状态*/
 {
  //如果是up 状态,则提出报告并让触摸屏处在等待触摸的阶段
   count = 0;

   input_report_key(ts_dev, BTN_TOUCH, 0); /*报告按键事件,键值为0(代表触摸屏对应的按键被释放)*/
   input_report_abs(ts_dev, ABS_PRESSURE, 0);
/*报告触摸屏的状态,0表明触摸屏没被按下*/
   input_sync(ts_dev);
/*等待接收方受到数据后回复确认,用于同步*/

   iowrite32(WAIT4INT(0), base_addr+S3C2410_ADCTSC);
  if (OwnADC)
  {
   OwnADC = 0;
   up(&ADC_LOCK);
  }
  }
}
/*定义并初始化了一个定时器touch_timer,定时器服务程序为touch_timer_fire*/
static struct timer_list touch_timer = TIMER_INITIALIZER(touch_timer_fire, 0, 0);

/*ADC中断服务程序,AD转换完成后触发执行*/
static irqreturn_t stylus_updown(int irq, void *dev_id)
{
 unsigned long data0;
 unsigned long data1;
 int updown;
 
//注意在触摸屏驱动模块中,这个ADC_LOCK 的作用是保证任何时候都只有一个驱动程序使用ADC 的
 //中断线,因为在mini2440adc 模块中也会使用到ADC,这样只有拥有了这个锁,才能进入到启动ADC
 if (down_trylock(&ADC_LOCK) == 0)
 {
  OwnADC = 1;
  data0 = ioread32(base_addr+S3C2410_ADCDAT0);
  data1 = ioread32(base_addr+S3C2410_ADCDAT1);
 
 /*记录这一次对触摸屏是压下还是抬起,该状态保存在数据寄存器的第15位,所以需要逻辑与上
S3C2410_ADCDAT0_UPDOWN*/
  updown = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && (!(data1 & S3C2410_ADCDAT0_UPDOWN));

  if (updown)
  {
   touch_timer_fire(0);
//这是一个定时器函数,当然在这里是作为普通函数调用,用来启动ADC
  }
  else
  {
   OwnADC = 0;
   up(&ADC_LOCK);
//注意这部分是基本不会执行的,除非你触摸后以飞快的速度是否,还来
   //不及启动ADC,当然这种飞快的速度一般是达不到的,笔者调试程序时发现这里是进入不了的
  }
 }

 return IRQ_HANDLED;
}

static irqreturn_t stylus_action(int irq, void *dev_id)
{
 unsigned long data0;
 unsigned long data1;

 if (OwnADC) {//读取数据
  data0 = ioread32(base_addr+S3C2410_ADCDAT0);
  data1 = ioread32(base_addr+S3C2410_ADCDAT1);

  xp += data0 & S3C2410_ADCDAT0_XPDATA_MASK;
  yp += data1 & S3C2410_ADCDAT1_YPDATA_MASK;
  count++;

     if (count < (1<<2)) {//如果小如四次重新启动转换
   iowrite32(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, base_addr+S3C2410_ADCTSC);
   iowrite32(ioread32(base_addr+S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, base_addr+S3C2410_ADCCON);
  } else {
//如果超过四次,则等待1ms 后进行数据上报
   mod_timer(&touch_timer, jiffies+1);
   iowrite32(WAIT4INT(1), base_addr+S3C2410_ADCTSC);
  }
 }

 return IRQ_HANDLED;
}

static struct clk *adc_clock;/*用于保存从平台时钟列表中获取的ADC时钟*/

static int __init s3c2410ts_init(void)
{
 struct input_dev *input_dev;
 /*从平台时钟队列中获取ADC的时钟,这里为什么要取得这个时钟,因为ADC的转换频率跟时钟有关。
     系统的一些时钟定义在arch/arm/plat-s3c24xx/s3c2410-clock.c中*/
 adc_clock = clk_get(NULL, "adc");
 if (!adc_clock) {
  printk(KERN_ERR "failed to get adc clock source\n");
  return -ENOENT;
 }
 /*时钟获取后要使能后才可以使用,clk_enable定义在arch/arm/plat-s3c/clock.c中*/
 clk_enable(adc_clock);
 //获取时钟,挂载APB BUS 上的外围设备,需要时钟控制,ADC 就是这样的设备。

 /*I/O 内存是不能直接进行访问的,必须对其进行映射,为I/O 内存分配虚拟地址,这些虚拟地址以__iomem
   进行说明,但不能直接对其进行访问,需要使用专用的函数,如iowrite32 
 S3C2410_PA_ADC是ADC控制器的基地址,定义在mach-s3c2410/include/mach/map.h中,0x20是虚拟地址长度大小*/
 base_addr=ioremap(S3C2410_PA_ADC,0x20);
 if (base_addr == NULL) {
  printk(KERN_ERR "Failed to remap register block\n");
  return -ENOMEM;
 }

 /* Configure GPIOs */
 s3c2410_ts_connect();
 /*计算结果为(二进制):111111111000000,再根据数据手册得知此处是将AD转换预定标器值设为255、AD转换预定标器使能有效*/
 iowrite32(S3C2410_ADCCON_PRSCEN | S3C2410_ADCCON_PRSCVL(0xFF),\
       base_addr+S3C2410_ADCCON);
//使能预分频和设置分频系数
 iowrite32(0xffff,  base_addr+S3C2410_ADCDLY);
//设置ADC延时,在等待中断模式下表示产生 INT_TC 的间隔延时值为0xffff*/

 /*WAIT4INT宏计算结果为(二进制):11010011,再根据数据手册得知此处是将ADC触摸屏控制寄存器设置成等待中断模式*/
 iowrite32(WAIT4INT(0), base_addr+S3C2410_ADCTSC);
//按照等待中断的模式设置TSC

 /* Initialise input stuff */
 
//allocate memory for new input device,用来给输入设备分配空间,并做一些输入设备通用的初始的设置
 input_dev = input_allocate_device();

 if (!input_dev) {
  printk(KERN_ERR "Unable to allocate the input device !!\n");
  return -ENOMEM;
 }
 //设置事件类型
 ts_dev = input_dev;
 ts_dev->evbit[0] = BIT(EV_SYN) | BIT(EV_KEY) | BIT(EV_ABS);
 ts_dev->keybit[BITS_TO_LONGS(BTN_TOUCH)] = BIT(BTN_TOUCH);
 input_set_abs_params(ts_dev, ABS_X, 0, 0x3FF, 0, 0);
 input_set_abs_params(ts_dev, ABS_Y, 0, 0x3FF, 0, 0);
 input_set_abs_params(ts_dev, ABS_PRESSURE, 0, 1, 0, 0);
 
/*以上四句都是设置事件类型中的code,如何理解呢,先说明事件类型,常用的事件类型EV_KEY、
 EV_MOSSE, EV_ABS(用来接收像触摸屏这样的绝对坐标事件),而每种事件又会有不同类型的编码code,
 比方说ABS_X,ABS_Y,这些编码又会有相应的value*/

 ts_dev->name = DEVICE_NAME;
 ts_dev->id.bustype = BUS_RS232;
 ts_dev->id.vendor = 0xDEAD;
 ts_dev->id.product = 0xBEEF;
 ts_dev->id.version = S3C2410TSVERSION;
 //以上是输入设备的名称和id,这些信息时输入设备的身份信息了,在用户空间如何看到呢?
 //可以通过cat /proc/bus/input/devices,下面是其输出信息
 /*[root@mini2440 /]#cat proc/bus/input/devices
 I: Bus=0013 Vendor=dead Product=beef Version=0101
 N: Name="s3c2410 TouchScreen"
 P: Phys=
 S: Sysfs=/devices/virtual/input/input0
 U: Uniq=
 H: Handlers=event0
 B: EV=b
 B: KEY=0
 B: ABS=1000003
 */

 /* Get irqs */
 
//中断处理
 //stylus_action 和stylus_updown 两个中断处理函数,当笔尖触摸时,会进入到stylus_updown
 if (request_irq(IRQ_ADC, stylus_action, IRQF_SHARED|IRQF_SAMPLE_RANDOM,
  "s3c2410_action", ts_dev)) {
  printk(KERN_ERR "s3c2410_ts.c: Could not allocate ts IRQ_ADC !\n");
  iounmap(base_addr);
  return -EIO;
 }
 if (request_irq(IRQ_TC, stylus_updown, IRQF_SAMPLE_RANDOM,
   "s3c2410_action", ts_dev)) {
  printk(KERN_ERR "s3c2410_ts.c: Could not allocate ts IRQ_TC !\n");
  iounmap(base_addr);
  return -EIO;
 }

 printk(KERN_INFO "%s successfully loaded\n", s3c2410ts_name);

 /* All went ok, so register to the input system */
 
//前面已经设置了设备的基本信息和所具备的能力,所有的都准备好了,现在就可以注册了
 input_register_device(ts_dev);

 return 0;
}

static void __exit s3c2410ts_exit(void)
{
 disable_irq(IRQ_ADC);
 disable_irq(IRQ_TC);
 free_irq(IRQ_TC,ts_dev);
 free_irq(IRQ_ADC,ts_dev);

 if (adc_clock) {
  clk_disable(adc_clock);
  clk_put(adc_clock);
  adc_clock = NULL;
 }

 input_unregister_device(ts_dev);
 iounmap(base_addr);
}
module_init(s3c2410ts_init);
module_exit(s3c2410ts_exit);

 

我们从整体上描述转换的过程:
(1) 如果触摸屏感觉到触摸,则进入updown ISR,如果能获取ADC_LOCK 则调用touch_timer_fire,
启动ADC,
(2) ADC 转换,如果小于四次继续转换,如果四次完毕后,启动1 个时间滴答的定时器,停止ADC,
也就是说在这个时间滴答内,ADC 是停止的,
(3) 这样可以防止屏幕抖动。
(4) 如果1 个时间滴答到时候,触摸屏仍然处于触摸状态则上报转换数据,并重启ADC,重复(2)
(5) 如果触摸笔释放了,则上报释放事件,并将触摸屏重新设置为等待中断状态。

然后打开linux-2.6.32.2/drivers/input/touchscreen/Makefile ,定位到文件末尾,添加该源代码的目标模块,如下红色部分:

obj-$(CONFIG_TOUCHSCREEN_W90X900) += w90p910_ts.o
obj-$(CONFIG_TOUCHSCREEN_PCAP)  += pcap_ts.o
obj-$(CONFIG_TOUCHSCREEN_MINI2440) += s3c2410_ts.o

再打开linux-2.6.32.2/drivers/input/touchscreen/Kconfig ,定位到14行附近,加入如下红色部分,这样就在内核配置中添加了mini2440 的触摸屏驱动选项:

if INPUT_TOUCHSCREEN

config TOUCHSCREEN_MINI2440
 tristate "Samsung S3C2440 touchscreen input driver"
 depends on MACH_MINI2440 && INPUT && INPUT_TOUCHSCREEN && MINI2440_ADC
 default y
 help
  Say Y here if you have the s3c2440 touchscreen.
  If unsure, say N.
  To compile this driver as a module, choose M here: the
  module will be called s3c2410_ts.

config TOUCHSCREEN_MY2440_DEBUG
    boolean "S3C2440 touchscreens input driver debug messages"
    depends on TOUCHSCREEN_MINI2440
    help
        Select this if you want debug messages

config TOUCHSCREEN_ADS7846
 tristate "ADS7846/TSC2046 and ADS7843 based touchscreens"
 depends on SPI_MASTER
 depends on HWMON = n || HWMON
 help

至此,我们就已经在内核中添加完了触摸屏驱动。

【2】配置编译并启动内核

在命令行执行:make menuconfig,然后依次选择如下子菜单,找到刚刚添加的触摸屏驱动选项:
Device Drivers --->
    Input device support --->
        [*] Touchscreens --->
如图所示,按空格键选中“S3C2440 touchscreens input driver debug messages (NEW)” 触摸屏驱动配置选项:

Linux-2.6.32.2内核在mini2440上的移植(九)---触摸屏驱动移植 - singleboy - singleboy的博客

 

 退出并保存以上内核配置,在命令行输入:make uImage,将生成arch/arm/boot/uImage文件,然后复制到nfsboot/kernel目录下。启动开发板,可以在串口终端看到如下启动信息:

... ...

mice: PS/2 mouse device common for all mice
mini2440_TouchScreen successfully loaded
input: mini2440_TouchScreen as /devices/virtual/input/input0
S3C24XX RTC, (c) 2004,2006 Simtec Electronics

... ..

说明触摸屏的驱动加载成功。

【3】创建触摸屏设备节点并测试

(1)新建一个测试文件,代码位于linux-test/codetest/tstest.c,代码如下:

#include <stdio.h>

#include <unistd.h>

#include <stdlib.h>

#include <errno.h>

#include <sys/poll.h>

#include <fcntl.h>

#include <stdio.h>

#include <stdlib.h>
#include <linux/input.h>

struct sample{

 char position[15];

 int x;

 int y;

};

struct sample sample_array[4]=

{

 {"topleft",0,0},

 {"topright",0,0},

 {"bottonleft",0,0},

 {"bottonright",0,0},

};

int X1,X2,Y1,Y2;

 

getsample(int fd,int position)

{  
 struct input_event ev[128];

 int rb,sample_cnt,cntx=0,cnty=0;

   rb=read(fd,ev,sizeof(struct input_event)*128);

 

 if (rb < (int) sizeof(struct input_event)) {

      perror("evtest: short read");

      exit (1);

 }

 

 for (sample_cnt = 0;

     sample_cnt< (int) (rb / sizeof(struct input_event));

     sample_cnt++)

 {

     if (EV_ABS== ev[sample_cnt].type){
          if( sample_cnt%20==0){

          printf("%ld.%06ld ",

                 ev[sample_cnt].time.tv_sec,

                 ev[sample_cnt].time.tv_usec);

            printf("type %d code %d value %d\n",

                 ev[sample_cnt].type,

                 ev[sample_cnt].code, ev[sample_cnt].value);
   }

               if(ABS_X==ev[sample_cnt].code){

                 sample_array[position].x+= ev[sample_cnt].value;

                 cntx++;

                  }

               if(ABS_Y==ev[sample_cnt].code){

                 sample_array[position].y+= ev[sample_cnt].value;

                 cnty++;

                 }
 }

   }

   sample_array[position].x/=cntx;

   sample_array[position].y/=cnty;

}

 

int ts_coordinate(int value,int axes)
{
 int tempX,ret;
 if(ABS_X==axes)ret=240-(240*(value-X2)/(X1-X2));
      if(ABS_Y==axes)ret=320-(320*(value-Y2)/(Y1-Y2));
 return ret;

   
int main(int argc, char **argv)

{

    struct pollfd pfd;

    int n,fd,i=0;

  if ((fd = open("/dev/input/event0",O_RDONLY) )< 0) {

    printf("open error! \n");

   exit(1);

 }

 for(i=0;i<4;i++){

  printf("Please touch the %s for 6 second ! \n",sample_array[i].position);

  sleep(6);

  printf("Time is up Please release\n");

  getsample(fd,i);
            sleep(1);

 }
 for(i=0;i<4;i++){
 printf("%12s x=%4d,y=%4d\n",sample_array[i].position,
                             sample_array[i].x,
                             sample_array[i].y);
 }
      X1=(sample_array[0].x+ sample_array[2].x )/2; 
 X2=(sample_array[1].x+ sample_array[3].x )/2; 
      Y1=(sample_array[0].y+ sample_array[1].y )/2; 
 Y2=(sample_array[2].y+ sample_array[3].y )/2;            

 printf("Coordinate complete,test it now\n");  
 for(i=0;i<4;i++){

  printf("Please touch the %s for 6 second ! \n",sample_array[i].position);

  sleep(6);

  printf("Time is up Please release\n");

  getsample(fd,i);
            sample_array[i].x=ts_coordinate(sample_array[i].x,ABS_X);
            sample_array[i].y=ts_coordinate(sample_array[i].y,ABS_Y);
            sleep(1);

 }
 printf("the data after coordinate \n");  
 for(i=0;i<4;i++){
  printf("%12s x=%4d,y=%4d\n",sample_array[i].position,
                             sample_array[i].x,
                             sample_array[i].y);
 }
 close(fd);
 exit(0);

}

然后保存退出。

(2)在主机终端交叉编译

[root@localhost codetest]# arm-linux-gcc -o tstest tstest.c

将其复制到nfsboot目录下以便在开发板挂载该目录后能够执行

[root@localhost codetest]# cp tstest /nfsboot/nfs

(3)查看设备信息

由启动信息得知触摸屏设备为输入类设备,按如下操作:

[root@mini2440 /]#cat proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 /dev/vc/0
  4 tty
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  7 vcs
 10 misc
 
13 input
 14 sound
可以得知输入类设备的主设备号为13,又按如下操作:

[root@mini2440 /]#cat proc/bus/input/devices
I: Bus=0013 Vendor=dead Product=beef Version=0101
N: Name="mini2440_TouchScreen"
P: Phys=
S: Sysfs=/devices/virtual/input/input0
U: Uniq=
H: Handlers=event0
B: EV=b
B: KEY=0
B: ABS=1000003

[root@mini2440 /]#

可看查看总线的具体输入设备输入设备的名称和id等详细的身份信息信息。

根据这些信息我们建立好设备节点,设置内核调试级别为8,至于为什么设置内核调试级别为8,可以参考文章内核模块调试方法

[root@mini2440 /]#mkdir /dev/input
[root@mini2440 /]#mknod /dev/input/event0 c 13 64
[root@mini2440 /]#echo 8 > /proc/sys/kernel/printk
[root@mini2440 /]#cat /dev/input/event0

然后打开触摸屏设备,点击触摸屏,出现如下信息:

N鐉?N{?N3{NB{N{?mN驳?N蔚N?wN
C??N_?N?xN??N?NBe}Nte?N恊N褵N?莱
N?莱N;?莱NO?莱N^?莱N婜

此时看不到打印的坐标信息,运行测试文件,可以看到如下信息:

[root@mini2440 nfs]#./tstest
Please touch the topleft for 6 second !
Time is up Please release
1308931371.064677 type 3 code 0 value 910
1308931373.034652 type 3 code 0 value 916
Please touch the topright for 6 second !
Time is up Please release
1308931379.909666 type 3 code 1 value 921
1308931380.059651 type 3 code 0 value 920
Please touch the bottonleft for 6 second !
Time is up Please release
1308931387.144660 type 3 code 1 value 72
Please touch the bottonright for 6 second !
Time is up Please release
     topleft x= 911,y=  82
    topright x= 920,y= 920
  bottonleft x= 101,y=  72
 bottonright x=  98,y= 945
Coordinate complete,test it now
Please touch the topleft for 6 second !
Time is up Please release
1308931395.359705 type 3 code 1 value 944
Please touch the topright for 6 second !
Time is up Please release
Please touch the bottonleft for 6 second !
Time is up Please release
Please touch the bottonright for 6 second !
Time is up Please release
1308931421.859651 type 3 code 0 value 97
1308931421.979651 type 3 code 0 value 97
1308931422.084660 type 3 code 1 value 937
the data after coordinate
     topleft x=-14480,y=21165
    topright x=45920,y=28480
  bottonleft x=-30560,y=-17920
 bottonright x=-32400,y=22034
[root@mini2440 nfs]#

有关触摸屏驱动原理详解请参见Mini2440触摸屏程序分析

接下来,将进行USB外设配置

抱歉!评论已关闭.