jade135 发表于 2010-9-29 18:40:18

S3C2440触摸屏代码疑惑

学ARM也有几个星期了,但看代码还是有点难度,下面是S3C2440触摸屏中断处理的代码,有一些自己理解的写上去了但不知道正不正确,贴上来交流一下,感觉那些注释掉的代码不用也可以正常运行,请教一下各位大侠那些代码的作用

void __irq AdcTsAuto(void)
{
//中断一触发说明光标按下,按下来进行ADC转换

        //U32 saveAdcdly;

        //if(rADCDAT0&0x8000)
        //{
                //Uart_Printf("\nStylus Up!!\n");
        //        rADCTSC&=0xff;        // Set stylus down interrupt bit
        //}
        //else
                //Uart_Printf("\nStylus Down!!\n");

        rADCTSC=(1<<3)|(1<<2);                           //设置成自动检测x,y坐标
       
        //saveAdcdly=rADCDLY;
        //rADCDLY=40000;               //Normal conversion mode delay about (1/50M)*40000=0.8ms

          .       
        rADCCON|=0x1;                                                //ADC转换开始,开始后该位清零
        while(rADCCON & 0x1);                                //开始后第一位清零,检测是否开始
        while(!(rADCCON & 0x8000));              //检测ADC转换是否结束
        while(!(rSRCPND & (BIT_ADC)));                //检测中断INT_ADC是否已请求
        xdata=(rADCDAT0&0x3ff);
        ydata=(rADCDAT1&0x3ff);
       
//再度启用中断看光标是否已抬起,抬起则跳出while循环       
        rSUBSRCPND|=BIT_SUB_TC;                       
        ClearPending(BIT_ADC);
        rINTSUBMSK=~(BIT_SUB_TC);
        rINTMSK=~(BIT_ADC);       
        rADCTSC =0xd3;                                          //等待中断Wfait,XP_PU,XP_Dis,XM_Dis,YP_Dis,YM_En
        rADCTSC=rADCTSC|(1<<8);                        // Detect stylus up interrupt signal.
       
        while(1)                                                       //to check Pen-up state
        {
                if(rSUBSRCPND & (BIT_SUB_TC))        //check if ADC is finished with interrupt bit若INT_TC已请求
                {
                        //Uart_Printf("Stylus Up Interrupt~!\n");
                        break;        //if Stylus is up(1) state
                }
        }       
        Uart_Printf("count=%03dXP=%04d, YP=%04d\n", count++, xdata, ydata);               
       
        //rADCDLY=saveAdcdly;
        rADCTSC=rADCTSC&~(1<<8);                         // Detect stylus Down interrupt signal
        rSUBSRCPND|=BIT_SUB_TC;
        rINTSUBMSK=~(BIT_SUB_TC);             
        ClearPending(BIT_ADC);
}
页: [1]
查看完整版本: S3C2440触摸屏代码疑惑