📄 tsp_auto_test.c
字号:
/*********************************************************************************************
* File: tsp_auto_test.c
* Author: embest
* Desc: Touch Screen (Auto) Test
* History:
* R.X.Huang, Programming modify, March 12, 2005
*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
/* include files */
/*------------------------------------------------------------------------------------------*/
#include <string.h>
#include "2410lib.h"
#include "tsp_auto_test.h"
/*------------------------------------------------------------------------------------------*/
/* constants define */
/*------------------------------------------------------------------------------------------*/
#define ADCPRS 39
/*********************************************************************************************
* name: tsp_auto_int
* func: Touch screen interrupt handler (ADC auto)
* para: none
* ret: none
* modify: R.X.Huang, March 12, 2005
* comment:
*********************************************************************************************/
void tsp_auto_int(void)
{
rINTSUBMSK |= (BIT_SUB_ADC|BIT_SUB_TC);// Mask sub interrupt (ADC and TC)
// TC(Touch screen Control) Interrupt
if(rADCTSC&0x100)
{
uart_printf(" Stylus Up!!\n");
rADCTSC &= 0xff; // Set stylus down interrupt
}
else
{
uart_printf(" Stylus Down!!\n");
// <Auto X-Position and Y-Position Read>
// Stylus Down,Don't care,Don't care,Don't care,Don't care,XP pullup Dis,Auto,No operation
rADCTSC = (0<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(1<<3)|(1<<2)|(0);
rADCCON |= 0x1; // Start Auto conversion
while(rADCCON & 0x1); // check if Enable_start is low
while(!(0x8000&rADCCON)); // Check ECFLG
uart_printf(" X-Posion[AIN5] is %04d\n", (0x3ff&rADCDAT0));
uart_printf(" Y-Posion[AIN7] is %04d\n", (0x3ff&rADCDAT1));
// Stylus Up,Don't care,Don't care,Don't care,Don't care,XP pullup En,Normal,Waiting mode
rADCTSC = (1<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);
}
rSUBSRCPND |= BIT_SUB_TC;
rINTSUBMSK = ~(BIT_SUB_TC); // Unmask sub interrupt (TC)
ClearPending(BIT_ADC);
}
/*********************************************************************************************
* name: tsp_auto_test
* func: Touch screen interrupt handler (ADC auto)
* para: none
* ret: none
* modify: R.X.Huang, March 12, 2005
* comment:
*********************************************************************************************/
void tsp_auto_test(void)
{
uart_printf(" Touch Screen (auto) Test Example.\n");
uart_printf(" Auto X/Y position conversion mode test\n");
rADCDLY = (50000); // ADC Start or Interval Delay
rADCCON = (1<<14)|(ADCPRS<<6)|(0<<3)|(0<<2)|(0<<1)|(0);
// Enable Prescaler,Prescaler,AIN5/7 fix,Normal,Disable read start,No operation
rADCTSC = (0<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);//tark
// Down,YM:GND,YP:AIN5,XM:Hi-z,XP:AIN7,XP pullup En,Normal,Waiting for interrupt mode
pISR_ADC = (unsigned)tsp_auto_int;
rINTMSK &= ~(BIT_ADC);
rINTSUBMSK &= ~(BIT_SUB_TC);
uart_printf(" Type any key to exit!!!\n");
uart_printf(" Stylus Down, please...... \n");
uart_getch();
rINTSUBMSK |= BIT_SUB_TC;
rINTMSK |= BIT_ADC;
uart_printf(" end.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -