<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > S3C2440之觸摸屏

S3C2440之觸摸屏

作者: 時(shí)間:2016-11-27 來(lái)源:網(wǎng)絡(luò ) 收藏
Test_Touchpanel.c實(shí)現檢測觸點(diǎn)坐標
  1. #defineREQCNT30
  2. #defineADCPRS9//YH0627
  3. #defineLOOP1
  4. void__irqAdcTsAuto(void);
  5. intcount=0;
  6. volatileintxdata,ydata;
  7. voidTest_Touchpanel(void)
  8. {
  9. rADCDLY=50000;//Normalconversionmodedelayabout(1/3.6864M)*50000=13.56ms
  10. rADCCON=(1<<14)+(ADCPRS<<6);//ADCPRSEn,ADCPRSValue
  11. Uart_Printf("ADCtouchscreentest");
  12. rADCTSC=0xd3;//[0:7]Wfait,XP_PU(在等待中斷模式下,上拉電阻要有效),XP_Dis,XM_Dis,YP_Dis,YM_En
  13. pISR_ADC=(int)AdcTsAuto;
  14. rINTMSK=~BIT_ADC;//ADCTouchScreenMaskbitclear,enableADCint
  15. rINTSUBMSK=~(BIT_SUB_TC);//enablesubADCint
  16. Uart_Printf("Typeanykeytoexit!!!");
  17. Uart_Printf("StylusDown,please......");
  18. Uart_Getch();
  19. rINTSUBMSK|=BIT_SUB_TC;//getakeythenmasksubADCint;exit
  20. rINTMSK|=BIT_ADC;//maskADCint
  21. Uart_Printf("TouchScreenTestisFinished!!!");
  22. }
  23. void__irqAdcTsAuto(void)
  24. {
  25. inti;
  26. U32saveAdcdly;
  27. if(rADCDAT0&0x8000)
  28. {
  29. //Uart_Printf("StylusUp!!");
  30. rADCTSC&=0xff;//Setstylusdowninterruptbit
  31. }
  32. //else
  33. //Uart_Printf("StylusDown!!");
  34. rADCTSC=(1<<3)|(1<<2);//Pull-updisable,(在觸發(fā)中斷后,上拉電阻要無(wú)效)Seq.X,Ypostionmeasure.
  35. saveAdcdly=rADCDLY;//saveADCDLY(啟動(dòng)延時(shí))
  36. rADCDLY=40000;//Normalconversionmodedelayabout(1/50M)*40000=0.8ms
  37. rADCCON|=0x1;//startADC
  38. while(rADCCON&0x1);//checkifEnable_startislow,轉換開(kāi)啟結束
  39. while(!(rADCCON&0x8000));//checkifEC(EndofConversion)flagishigh,Thislineisnecessary~!!
  40. //conversionover
  41. while(!(rSRCPND&(BIT_ADC)));//checkifADCisfinishedwithinterruptbit,等待中斷清零?
  42. xdata=(rADCDAT0&0x3ff);
  43. ydata=(rADCDAT1&0x3ff);//讀取轉換結果,x軸坐標值放入rADCDAT0,y軸坐標值放入ADCDAT1
  44. //YH0627,TocheckStylusUpInterrupt.
  45. rSUBSRCPND|=BIT_SUB_TC;
  46. ClearPending(BIT_ADC);//清楚中斷標志位
  47. rINTSUBMSK=~(BIT_SUB_TC);//使能中斷?
  48. rINTMSK=~(BIT_ADC);
  49. rADCTSC=0xd3;//Waitingforinterrupt//[0:7]Wfait,XP_PU,XP_Dis,XM_Dis,YP_Dis,YM_En
  50. rADCTSC=rADCTSC|(1<<8);//Detecttylusupsinterruptsignal.檢查觸筆抬起中斷
  51. while(1)//tocheckPen-upstate
  52. {
  53. if(rSUBSRCPND&(BIT_SUB_TC))//checkifADCisfinishedwithinterruptbit
  54. {
  55. //Uart_Printf("StylusUpInterrupt~!");//觸筆抬起!
  56. break;//ifStylusisup(1)state
  57. }
  58. }
  59. Uart_Printf("count=dXP=d,YP=d",count++,xdata,ydata);//X-positionConversiondata
  60. rADCDLY=saveAdcdly;//恢復ADCDLY原值
  61. rADCTSC=rADCTSC&~(1<<8);//DetectstylusDowninterruptsignal.檢查觸筆落下中斷(下一次檢測)
  62. rSUBSRCPND|=BIT_SUB_TC;
  63. rINTSUBMSK=~(BIT_SUB_TC);//Unmasksubinterrupt(TC)//使能中斷
  64. ClearPending(BIT_ADC);
  65. }

效果圖:

本文引用地址:http://dyxdggzs.com/article/201611/322378.htm
上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: S3C2440觸摸

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>