/*
 * touch.h
 *
 *  Created on: 2021年8月7日
 *      Author: wuwenfeng
 */

#ifndef TOUCH_H_
#define TOUCH_H_
#include "main.h"


#define TCLK(x) HAL_GPIO_WritePin(TCLK_GPIO_Port,TCLK_Pin,x)
#define TCS(x) HAL_GPIO_WritePin(TCS_GPIO_Port,TCS_Pin,x)
#define TDIN(x) HAL_GPIO_WritePin(TDIN_GPIO_Port,TDIN_Pin,x)
#define TDOUT HAL_GPIO_ReadPin(TDOUT_GPIO_Port,TDOUT_Pin)
#define TPEN HAL_GPIO_ReadPin(TPEN_GPIO_Port,TPEN_Pin)

typedef struct
{
	char begin;
	float x_acc;
	float y_acc;
	int   x_offset;
	int   y_offset;
	char end;
}touch_config;

typedef struct
{
	uint16_t adc_x;
	uint16_t adc_y;
	int pix_x;
	int pix_y;
	char move_flag:1;
	char c:1;  //有按键按下
	char d:1;  //成功读取adc值
}touch_device;


void TP_Server();
void TP_adjustment(char mode);
char TP_XY(int *x,int *y);
#endif /* TOUCH_H_ */
