下面是这个模块加载函数中调用的一个配置端口函数


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 struct timer_list touch_timer =
TIMER_INITIALIZER(touch_timer_fire, 0, 0);


  因为这个定时器的期间设置为0,这表示当驱动加载后会执行一次定时函数touch_timer_fire


static void touch_timer_fire(unsigned long data)
{
     unsigned long data0;
     unsigned long data1;
       int updown;
     data0 = ioread32(base_addr+S3C2410_ADCDAT0);  //读取X坐标
     data1 = ioread32(base_addr+S3C2410_ADCDAT1);  //读取Y坐标
      updown = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && (!(data1 & S3C2410_ADCDAT0_UPDOWN)); //触摸屏是否被按下,如果按下updowm=1
      if (updown) {
             if (count != 0) {
                     long tmp;                                                                                        
                     tmp = xp;
                     xp = yp;
                     yp = tmp;                                                                                        
           xp >>= 2;
           yp >>= 2;
                    input_report_abs(dev, ABS_X, xp);
                    input_report_abs(dev, ABS_Y, yp);
                    input_report_key(dev, BTN_TOUCH, 1);
                    input_report_abs(dev, ABS_PRESSURE, 1);
                    input_sync(dev);
             }
             xp = 0;    
             yp = 0;
             count = 0;
             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 { //没有被按下
             count = 0;        //初始化count为0,表示当前AD转换没发生
             input_report_key(dev, BTN_TOUCH, 0);  //向input子系统报告未按下
             input_report_abs(dev, ABS_PRESSURE, 0);
             input_sync(dev);
             iowrite32(WAIT4INT(0), base_addr+S3C2410_ADCTSC); //等待按键中断
              if (OwnADC) { //OwnADC是获取一把锁标示,在此为0
                     OwnADC = 0;
                     up(&ADC_LOCK);
              }
      }