S3C2440之触摸屏
时间:11-27
来源:互联网
点击:
- {
int i; U32 saveAdcdly; if(rADCDAT0&0x8000) { //Uart_Printf("Stylus Up!!"); rADCTSC&=0xff; // Set stylus down interrupt bit } //else //Uart_Printf("Stylus Down!!"); rADCTSC=(1<3)|(1<2); //Pull-up disable,(在触发中断后,上拉电阻要无效) Seq. X,Y postion measure. saveAdcdly=rADCDLY; //save ADCDLY(启动延时) rADCDLY=40000; //Normal conversion mode delay about (1/50M)*40000=0.8ms rADCCON|=0x1; //start ADC while(rADCCON & 0x1); //check if Enable_start is low,转换开启结束 while(!(rADCCON & 0x8000)); //check if EC(End of Conversion) flag is high, This line is necessary~!! //conversion over while(!(rSRCPND & (BIT_ADC))); //check if ADC is finished with interrupt bit,等待中断清零? xdata=(rADCDAT0&0x3ff); ydata=(rADCDAT1&0x3ff);//读取转换结果,x轴坐标值放入rADCDAT0,y轴坐标值放入ADCDAT1 //YH 0627, To check Stylus Up Interrupt. rSUBSRCPND|=BIT_SUB_TC; ClearPending(BIT_ADC);//清楚中断标志位 rINTSUBMSK=~(BIT_SUB_TC);//使能中断? rINTMSK=~(BIT_ADC); rADCTSC =0xd3; //Waiting for interrupt//[0:7]Wfait,XP_PU,XP_Dis,XM_Dis,YP_Dis,YM_En rADCTSC=rADCTSC|(1<8); // Detect tylus up sinterrupt signal.检查触笔抬起中断 while(1) //to check Pen-up state { if(rSUBSRCPND & (BIT_SUB_TC)) //check if ADC is finished with interrupt bit { //Uart_Printf("Stylus Up Interrupt~!");//触笔抬起! break; //if Stylus is up(1) state } } Uart_Printf("count=d XP=d, YP=d", count++, xdata, ydata); //X-position Conversion data rADCDLY=saveAdcdly; //恢复ADCDLY原值 rADCTSC=rADCTSC&~(1<8); // Detect stylus Down interrupt signal.检查触笔落下中断(下一次检测) rSUBSRCPND|=BIT_SUB_TC; rINTSUBMSK=~(BIT_SUB_TC); // Unmask sub interrupt (TC)//使能中断 ClearPending(BIT_ADC); - }
效果图:
S3C2440触摸 相关文章:
- S3C2440触摸屏驱动代码分析(12-01)
- S3C2440 触摸屏应用(11-21)
- s3c2440触摸屏测试(11-20)
- s3c2440的触摸屏校正与测试(11-20)
- s3c2440的触摸屏应用与校正(11-19)
- Windows CE 进程、线程和内存管理(11-09)