ts1.c
来自「S3C24A0的完整BSP包,对开发此芯片的开发者很有用.」· C语言 代码 · 共 87 行
C
87 行
/*****************************************
NAME: ts.c
DESC: S3C24A0 Touch Screen Test Code
HISTORY: 2002.04.29:draft ver 0.0
*****************************************/
#include <string.h>
#include "24a0addr.h"
#include "24a0lib.h"
#include "Ts.h"
#include "def.h"
void __irq TsAutoTest(void)
{
unsigned int WHATIRQ=0;
rINTSUBMSK|=(BIT_SUB_ADC|BIT_SUB_PENUP|BIT_SUB_PENDN); // Mask sub interrupt (ADC, PENUP and PENDN)
WHATIRQ = (rSUBSRCPND>>17) & 0x3;
switch(WHATIRQ)
{
case 1:
case 3:
rSUBSRCPND=BIT_SUB_PENUP|BIT_SUB_PENDN;//Clear Sub-Source Pending, PENUP
Uart_Printf("\nStylus up!!\n");
rINTSUBMSK=~(BIT_SUB_PENUP|BIT_SUB_PENDN|BIT_SUB_ADC);//Unmask Sub-Interrupt, PENUP
break;
case 2:
rSUBSRCPND=BIT_SUB_PENDN;//Clear Sub-Source Pending, PENDN
rADCTSC=(0<<8)|(1<<3)|(1<<2)|(0);
rADCCON|=0x1;// Start Auto conversion
while(rADCCON & 0x1);//Check if Enable_start is low
while(!(0x8000&rADCCON));//Check ECFLG
rADCTSC=(0<<8)|(13<<4)|(0<<3)|(0<<2)|1;//for returning to X-position....
rADCTSC=0xd3; //for waiting interruupt
while(((rSUBSRCPND>>17)&0x02) !=0x2);
rSUBSRCPND=BIT_SUB_PENDN|BIT_SUB_ADC;//Clear Sub-Source Pending, PENDN
Uart_Printf("\nStylus down!!\n");
Uart_Printf("X-Posion[AIN5] is %04d\n", (0x3ff&rADCDAX));
Uart_Printf("Y-Posion[AIN7] is %04d\n\n", (0x3ff&rADCDAY));
rINTSUBMSK=~(BIT_SUB_PENDN|BIT_SUB_PENUP|BIT_SUB_ADC);//Unmask Sub-Interrupt, PENDN
break;
default:
break;
}
// ClearPending(BIT_ADC_PENUP_DOWN);
rSRCPND=(1<<31);
rINTPND=(1<<31);
}
void Ts_Auto(void)
{
Uart_Printf("[Touch Screen Test.]\n");
Uart_Printf("Auto X/Y position conversion mode test\n");
rADCDLY=(1000); // ADC Start or Interval Delay
// Enable Prescaler,Prescaler,AIN5/7 fix,Normal,Disable read start,No operation
rADCCON = (1<<14)|(ADCPRS<<6)|(0<<3)|(0<<2)|(0<<1)|0;
//rADCTSC=(0<<8)|(13<<4)|(0<<3)|(0<<2)|3;//tark, XP pullup En,Normal,Waiting for interrupt mode
rADCTSC=0xd3;
pISR_ADC_PENUP_DOWN=(unsigned)TsAutoTest;
rINTMSK=~(BIT_ADC_PENUP_DOWN);
rINTSUBMSK=~(BIT_SUB_ADC|BIT_SUB_PENUP|BIT_SUB_PENDN);
Uart_Printf("\nType any key to exit!!!\n");
Uart_Printf("\nStylus Down, please...... \n");
Uart_Getch();
rINTSUBMSK|=(BIT_SUB_ADC|BIT_SUB_PENUP|BIT_SUB_PENDN);
rINTMSK|=BIT_ADC_PENUP_DOWN;
Uart_Printf("[Touch Screen Test.]\n");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?