zoukankan      html  css  js  c++  java
  • [国嵌攻略][141][触摸屏驱动编程]

    开启XY坐标转换,并上报

    触摸屏驱动文件在/drivers/input/touchscreen/s3c2410_ts.c

    static void touch_timer_fire(unsigned long data)
    {
          unsigned long data0;
          unsigned long data1;
        int updown;
    
          data0 = ioread32(base_addr+S3C2410_ADCDAT0);
          data1 = ioread32(base_addr+S3C2410_ADCDAT1);
    
         updown = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && (!(data1 & S3C2410_ADCDAT0_UPDOWN));
    
         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_abs(dev, ABS_PRESSURE, 1);
                input_report_key(dev, BTN_TOUCH, 1);
                
                //同步上报
                input_sync(dev);
                
                //显示坐标
                printk("x = %d, y = %d
    ", xp, yp);
            }
            
            //清零转换坐标
            xp = 0;
            yp = 0;
            count = 0;
            
             //启动坐标转换
            iowrite32(1<<2, base_addr + S3C2410_ADCTSC);                                            //设置自动转换模式
            iowrite32(ioread32(base_addr + S3C2410_ADCCON) | (1<<0), base_addr + S3C2410_ADCCON);   //开启坐标转换
         } else {
             count = 0;
    
             input_report_key(dev, BTN_TOUCH, 0);
             input_report_abs(dev, ABS_PRESSURE, 0);
             input_sync(dev);
    
             iowrite32(WAIT4INT(0), base_addr+S3C2410_ADCTSC);
            if (OwnADC) {
                OwnADC = 0;
                up(&ADC_LOCK);
            }
         }
    }
  • 相关阅读:
    [转]spring学习笔记7.自动装配(补充)
    [转]JSON 入门指南
    [转]spring学习笔记补: 生命周期
    rownum的用法
    简易计算器实现
    Flush the AOS cache from code
    通过Batch发送Report
    Export excel file format
    The report's image auto resizes (Always use in report)
    Save the users last values in a dialog
  • 原文地址:https://www.cnblogs.com/d442130165/p/5271278.html
Copyright © 2011-2022 走看看