源码地址:https://github.com/774639008/MyProject/commit/2129384d2e0004dc859caa4d8b81d8669ecf5850?diff=unified
这是tsc.c文件
#include"s3c2440.h"
#include"tsc.h"
#include"lcd.h"
#include"irq.h"
#include "graphics.h"
#include "type.h"
#include <math.h>
#define TSC_WAIT_DOWN (0xd3)//等待按下中断
#define TSC_WAIT_UP (0x1d3)//等待抬起中断
#define TSC_AUTO_XY (0xc) //自动X Y轴采样
//设置常见的寄存器参数
#define PRSCVL (49<<6) //预分频值,ADCCLK = PCLK/(PRSCVL+1)<2.5M,现在设置为1MHZ
#define PRSCEN (1<<14) //预分频使能位
#define ADCCON_VAL (PRSCVL | PRSCEN) //其他位不设置
//设置消除抖动延时
//X-Tal = 3.6864MHZ,实际工作的时候
#define DELAY1 (36864) //默认消除抖动延时10ms,所以 DELAY1=10ms*X-Tal=10/1000 * 3.6864MHZ
//采样转换延时,采用PCLK,同时等待时间 > 5个周期的ADCCLK 也就是时间>1/1MHZ*5*2=10us
//在实际的测量环境中,长一点测量的值比较稳定,但是过长会导致出现抬起的时候被采样到,所以一般设置值 100us-5ms
//这边设置成1ms左右
#define DELAY2 (4000)//这个可以调整的
#define Y_BEGIN (165)
#define X_BEGIN (947) //变大往右,变小往左
#define Y_END (878)
#define X_END (80) //变大往右,变小往左
#define TSP_SAMPLE_NUM 8 //采样点数
#define TSP_INVALIDLIMIT 10 //有效分布范围
#define TSP_CHANGE 20 //前后点有效具体范围
#define PLENGTH(x1,y1,x2,y2)