📄 touch.c
字号:
#include <LPC213x.h>
#include "SPI.h"
#include "Touch.h"
//====================================================================================
void TPIOInit(void)
{
TP_CS_1;
TP_CS_OUT;
TP_INT_IN;
}
//====================================================================================
unsigned int ReadTP(unsigned char cmd)
{
unsigned int t;
TP_CS_0;
MSPISendData(cmd); //命令
t = MSPISendData(0x00);
t <<= 8;
t |= MSPISendData(0x00);
t >>= 3;
TP_CS_1;
return t;
}
//====================================================================================
void TPAdXY(int *x,int *y)
{
int adx,ady;
// SSPCPSR = 8; // PCLK 16分频 过高出错 SSP
S0SPCCR <<= 4;
adx=ReadTP(CHX);
ady=ReadTP(CHY);
S0SPCCR >>= 4;
// SSPCPSR = 2; // PCLK 4分频 //SSP
*x=adx;
*y=ady;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -