touch.c

来自「SPI INTERFACE驱动 IC为1289的TFT显示屏」· C语言 代码 · 共 60 行

C
60
字号
/**************************************************************************************
* 名    称: 
* 功    能: 
* 参    数: 
* 返 回 值: 
*
* 修改历史:
*   版本    日期     作者     
*   ----------------------------------------------------
*   1.0   2008.8.13  孙逸洁       www.http://shop35330111.taobao.com
**************************************************************************************/
void touch_Init(void)
{
    touch_CS=1;
    touch_DCLK=1;
    touch_DIN=1;
}
/**************************************************************************************
* 名    称: 
* 功    能: 
* 参    数: 
* 返 回 值: 
*
* 修改历史:
*   版本    日期     作者     
*   ----------------------------------------------------
*   1.0   2008.8.13  孙逸洁       www.http://shop35330111.taobao.com
**************************************************************************************/ 
uint read_trouch (unsigned char cmd) 
{
	uint temp=0;
    uchar i;
	touch_CS=0;

	spi_send(cmd);		//命令
	temp=spi_send(0);	//读数
	i=spi_send(0);
	temp<<=8;
	temp|=i;
	temp>>=3;			 //读数据前有一个空脉冲

	touch_CS=1;
	return temp;
}
/**************************************************************************************
* 名    称: 
* 功    能: 
* 参    数: 
* 返 回 值: 
*
* 修改历史:
*   版本    日期     作者     
*   ----------------------------------------------------
*   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);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?