📄 drv_tp.h
字号:
/************************************************************************
* *
* Copyright (C) SHANGHAI EPSON CORP. 2001 *
* *
* File name: drv_tp.h *
* This is touch panel header file. *
* *
* Revision history *
* 2001.05.18 Stella.Yuan Start. *
* 2004.05.27 David.Ji Modulize *
* *
************************************************************************/
#ifndef _TP_H_
#define _TP_H_
/*------------------------------------------------------*/
/* Macro define */
/*------------------------------------------------------*/
#define TP_STATUS_PENUP (0x0)
#define TP_STATUS_PENDOWN (0x1)
#define TP_STAGE_INIT (0x1)
#define TP_STAGE_SAMPL (0x2)
#define TP_SAMPLE_TIMES (0x8)
#define SCREEN_MARGIN (10)
#define SCREEN_WIDTH (320)
#define SCREEN_HEIGHT (240)
/* adjust position range define */
#define TP_RNG1_XL 890
#define TP_RNG1_XH 930
#define TP_RNG1_YL 860
#define TP_RNG1_YH 930
#define TP_RNG2_XL 200
#define TP_RNG2_XH 250
#define TP_RNG2_YL 180
#define TP_RNG2_YH 250
//Registers
#define REG_TM16_3_PSC 0x0004014a // 16bit Timer 3, Prescaler
#define REG_TM16_3_CTL 0x0004819e // 16bit Timer 3
#define REG_TM16_3_CMPA 0x00048198
#define REG_TM16_3_CMPB 0x0004819a
#define REG_TM16_3_IMASK 0x00040273 // Upper 4-bits
#define REG_TM16_3_IFLAG 0x00040283 // Upper 4-bits
#define REG_TM16_3_ILEVL 0x00040267 // Upper 4-bits
/* code macro define */
#define TP_M_RUNTM (*(volatile unsigned char *)REG_TM16_3_CTL |= 0x01)
#define TP_M_STOPTM (*(volatile unsigned char *)REG_TM16_3_CTL &= 0xfe)
#define TP_M_STOPADC (*(volatile unsigned char*)0x40244=0x0)
#define TP_M_EN_TMINT *(volatile unsigned char*)REG_TM16_3_IMASK |= 0x40
#define TP_M_DS_TMINT *(volatile unsigned char*)REG_TM16_3_IMASK &= 0xbf
#define TP_M_CL_TMINT *(volatile unsigned char*)REG_TM16_3_IFLAG |= 0x40
/*------------------------------------------------------*/
/* Structure define */
/*------------------------------------------------------*/
typedef enum{
TPCTL_INITAL,
TPCTL_SCANX,
TPCTL_SCANY,
} T_TPCtlP;
typedef struct{
unsigned short usX;
unsigned short usY;
} T_POINT;
typedef struct{
unsigned char ucStage; // stage
unsigned char ucStatus; // status
unsigned short usADC_X; // average x value
unsigned short usADC_Y; // average y value
unsigned short usLOG_X; // logical x value
unsigned short usLOG_Y; // ~ y value
float fStep_X; // step x value
float fStep_Y; // step y value
T_POINT stPoint_UL; // Upper & Left point
T_POINT stPoint_BR; // Bottom & right point
} T_TPCtlDev;
/*------------------------------------------------------*/
/* Function prototype */
/*------------------------------------------------------*/
void fnTP_InitHL(void);
void fnTP_InitAL(void);
void fnTP_EnTP(void);
void fnTP_CtlP(T_TPCtlP);
void fnTP_GetLogPos(unsigned short*, unsigned short*);
unsigned char fnTP_CalAvg(unsigned short*, unsigned short*);
unsigned char fnTP_ChkRng (unsigned short,unsigned short,\
unsigned short,unsigned short, unsigned short,unsigned short);
/* static function */
static void fnTPHL_InitP(void);
static void fnTPHL_InitK(void);
static void fnTPHL_InitADC(void);
static void fnTPHL_InitTM(void);
static void fnTPAL_MapPos(T_TPCtlDev*);
/* interrupt function */
void Int_TP_TM(void) __attribute__ ((interrupt_handler));
void Int_TP_K(void) __attribute__ ((interrupt_handler));
void Int_TP_ADC(void); // use ent_int, no neeed __attribute__
#endif// _TP_
/*------------ End of this file -----------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -