?? touch.c
字號:
/**************************************************************************************
* 名 稱:
* 功 能:
* 參 數(shù):
* 返 回 值:
*
* 修改歷史:
* 版本 日期 作者
* ----------------------------------------------------
* 1.0 2008.8.13 孫逸潔 www.http://shop35330111.taobao.com
**************************************************************************************/
void touch_Init(void)
{
touch_SET_CS();
touch_SET_DCLK();
touch_SET_DIN();
}
/**************************************************************************************
* 名 稱:
* 功 能:
* 參 數(shù):
* 返 回 值:
*
* 修改歷史:
* 版本 日期 作者
* ----------------------------------------------------
* 1.0 2008.8.13 孫逸潔 www.http://shop35330111.taobao.com
**************************************************************************************/
static unsigned short RD_AD(void)
{
uint temp=0;
uchar i;
touch_CLR_DIN();
touch_SET_DCLK();
for(i=0;i<12;i++)
{
touch_CLR_DCLK();
temp<<=1;
if(IORD_ALTERA_AVALON_PIO_DATA(P3_3_BASE)==1) temp++;
touch_SET_DCLK();
}
touch_SET_CS();
return(temp);
}
/**************************************************************************************
* 名 稱:
* 功 能:
* 參 數(shù):
* 返 回 值:
*
* 修改歷史:
* 版本 日期 作者
* ----------------------------------------------------
* 1.0 2008.8.13 孫逸潔 www.http://shop35330111.taobao.com
**************************************************************************************/
uint read_trouch (unsigned char cmd)
{
unsigned char i;
touch_SET_CS();
touch_CLR_DIN();
touch_CLR_DCLK();
touch_CLR_CS();
for(i=0;i<8;i++)
{
if(cmd&0x80)
touch_SET_DIN();
else
touch_CLR_DIN();
cmd=cmd<<1;
touch_SET_DCLK();
touch_CLR_DCLK();
}
return RD_AD();
}
/**************************************************************************************
* 名 稱:
* 功 能:
* 參 數(shù):
* 返 回 值:
*
* 修改歷史:
* 版本 日期 作者
* ----------------------------------------------------
* 1.0 2008.8.13 孫逸潔 www.http://shop35330111.taobao.com
**************************************************************************************/
void touch_GetAdXY(uint *x,uint *y)
{
*x=read_trouch(CHX);
*y=read_trouch(CHY);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -