?? ts_auto.c
字號:
#include <string.h>
#include "2410addr.h"
//#include "2410lib.h"
#include "Ts_auto.h"
#include "sysincludes.h"
#define ADCPRS 39
void __irq Adc_or_TsAuto(void)
{
rINTSUBMSK|=(BIT_SUB_ADC|BIT_SUB_TC); // Mask sub interrupt (ADC and TC)
// TC(Touch screen Control) Interrupt
if(rADCTSC&0x100)
{
//Uart_Printf("\nStylus Up!!\n");
rADCTSC&=0xff; // Set stylus down interrupt
}
else
{
// Uart_Printf("\nStylus Down!!\n");
// <Auto X-Position and Y-Position Read>
rADCTSC=(0<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(1<<3)|(1<<2)|(0);
// Stylus Down,Don't care,Don't care,Don't care,Don't care,XP pullup Dis,Auto,No operation
rADCCON|=0x1; // Start Auto conversion
while(rADCCON & 0x1); //check if Enable_start is low
while(!(0x8000&rADCCON)); // Check ECFLG
Uart_Printf("\r\n Touch X Y Position\n");
Uart_Printf("X-Posion[AIN5] is %04d\n", (0x3ff&rADCDAT0));
Uart_Printf("Y-Posion[AIN7] is %04d\n", (0x3ff&rADCDAT1));
rADCTSC=(1<<8)|(1<<7)|(1<<6)|(0<<5)|(1<<4)|(0<<3)|(0<<2)|(3);
// Stylus Up,Don't care,Don't care,Don't care,Don't care,XP pullup En,Normal,Waiting mode
}
rSUBSRCPND|=BIT_SUB_TC;
rINTSUBMSK=~(BIT_SUB_TC); // Unmask sub interrupt (TC)
ClearPending(BIT_ADC);
}
void Ts_Auto(void)
{
Uart_Printf("[觸摸屏測試程序.]\n");
Uart_Printf("請點擊觸摸屏進行測試,請注意串口輸出內容\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)Adc_or_TsAuto;
rINTMSK=~(BIT_ADC);
rINTSUBMSK=~(BIT_SUB_TC);
// rINTSUBMSK|=BIT_SUB_TC;
// rINTMSK|=BIT_ADC;
//Uart_Printf("[Touch Screen Test.]\n");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -