📄 ex18.c
字号:
/****************************************************************************/
//
//
// Created by Starlight Embeded Studio
// www.cedn.cn
// If there are any concerns on the code
// go to www.cedn.cn for discussion
//
/****************************************************************************/
#include <stdio.h>
#include "44B.H"
void Delay(int time)
{
static int DelayLoopCount = 500;
int i,j=0;
for(j=0;j<time;j++)
for(i=0;i<DelayLoopCount;i++);
}
int GetTouch(void)
{
return (rPDATG & 0x04);
}
void SetTouchIdle(void)
{
*(CPLD_REG5) = 0x07;
}
void SetTouchIo(void)
{
rCLKCON = rCLKCON | (1<<12);
rPCONG &= 0xFFFFFFCF;
rPUPG |= 0x00000000;
SetTouchIdle();
Delay(100);
}
void SetTouchY(void)
{
*(CPLD_REG5) = 0x05;
}
void SetTouchX(void)
{
*(CPLD_REG5) = 0x0A;
}
void TouchADC(unsigned short *x, unsigned short *y)
{
int i;
if (!GetTouch()) return;
rADCPSR = 10;
SetTouchX();
Delay(1000);
{
rADCCON = 0x1 | (1<<2);
while(rADCCON & 0x1);
while(!(rADCCON & 0x40));
for(i = 0; i < rADCPSR; i++);
*x = rADCDAT;
}
rADCPSR = 10;
SetTouchY();
Delay(1000);
{
rADCCON = 0x1|(0<<2);
while(rADCCON & 0x1);
while(!(rADCCON & 0x40));
for(i = 0; i < rADCPSR; i++);
*y = rADCDAT;
}
SetTouchIdle();
printf("(X,Y)=(%3d,%3d)\n",*x,*y);
}
void Test18()
{
unsigned short x1,y1;
printf("Start Test Touch Screen!\n");
SetTouchIdle();
while(1) TouchADC(&x1,&y1);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -