1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/**************************************************************************
* AW5306_Drv.h
*
* AW5306 Driver code version 1.0
*
* Create Date : 2012/06/25
*
* Modify Date :
*
* Create by : wuhaijun
*
**************************************************************************/
#ifndef AW5306_DRV_H
#define AW5306_DRV_H
#define Release_Ver 219
#define MAX_POINT 5
#define NUM_TX 21 // TX number of TOUCH IC
#define NUM_RX 12 // RX number of TOUCH IC
//#define NEWBASE_PROCESS //new base process need test!!!
#define ABS(X) ((X > 0) ? (X) : (-X))
typedef enum{
RawDataMode = 0,
DeltaMode,
MonitorMode
}enumWorkMode;
typedef enum{
BASE_INITIAL,
BASE_FAST_TRACE,
BASE_STABLE,
TEMP_DRIFT
} CompensateMode;
typedef struct {
unsigned short Base[NUM_TX][NUM_RX];
unsigned short ChipBase[NUM_TX][NUM_RX];
signed char Flag[NUM_TX][NUM_RX];
signed char BaseCnt[NUM_TX][NUM_RX];
unsigned char CompensateFlag;
unsigned char TraceTempIncCnt;
unsigned char TraceTempDecCnt;
unsigned char CompensateStateFrameCnt;
short LastMaxDiff;
CompensateMode CompensateState;
unsigned int InitialFrameCnt;
unsigned char PosBigAreaTouchFlag;
unsigned char NegBigAreaTouchFlag;
unsigned char BigAreaFirstFlag;
unsigned char BigAreaChangeFlag;
unsigned short BigTouchFrame;
unsigned short FrameCnt;
unsigned char LongStableCnt;
unsigned char PosPeakCnt;
unsigned char NegPeakCnt;
unsigned char PeakCheckFrameCnt;
unsigned char BaseFrozen;
unsigned char PosPeakCompensateCnt[MAX_POINT];
unsigned char NegPeakCompensateCnt[MAX_POINT];
}STRUCTBASE;
typedef struct {
unsigned char Peak[MAX_POINT][2];
unsigned char LastPeak[MAX_POINT][2];
unsigned char NegPeak[MAX_POINT][2];
unsigned char CurrentPointNum;
unsigned char CurrentNegPointNum;
unsigned char LastPointNum;
}STRUCTPEAK;
typedef struct {
unsigned short X,Y; // X,Y coordinate
unsigned char PointID; // Assigned point ID
unsigned char Event; // Event of current point
}STRUCTPOINT;
typedef struct {
STRUCTPOINT PointInfo[MAX_POINT];
STRUCTPOINT RptPoint[MAX_POINT];
unsigned char PointNum;
unsigned char LastPointNum;
unsigned char NegPointNum;
unsigned char FilterPointCnt;
unsigned char FirstLiftUpFlag;
unsigned char TouchStatus;
unsigned char PointHoldCnt[MAX_POINT];
unsigned char PointPressCnt[MAX_POINT];
}STRUCTFRAME;
typedef struct {
unsigned char fileflag[14];
unsigned char TXOFFSET[(NUM_TX+1)/2];
unsigned char RXOFFSET[(NUM_RX+1)/2];
unsigned char TXCAC[NUM_TX];
unsigned char RXCAC[NUM_RX];
unsigned char TXGAIN[NUM_TX];
short SOFTOFFSET[NUM_TX][NUM_RX];
}STRUCTCALI;
#define NOISE_LISTENING 0
#define NOISE_SCAN 1
#define NOISE_FREQ_JUMP 2
#define NOISE_SEEK_FAIL 3
#define NOISE_FRM_NORMAL 0
#define NOISE_FRM_PRE_MEASURE 1
#define NOISE_FRM_MEASURE 2
typedef struct {
unsigned char AllFrmCnt; // Frame counter to generate noise meaure frame indicator
unsigned char NoiseFrmCnt; // Frame counter for noise level checking
unsigned char IdleFrmCnt; // No touch frame counter
unsigned char State; // Noise checking state: LISTENING, SCAN, JUMP
unsigned char FrmState; // Frame type indicator: PRE_MEAUSRE, MEAUSRE, NORMAL
short NoiseNormal; // Noise in working freq
short NoiseScan; // Noise in scan freq
short Better_NoiseScan; //pfx:smaller Noise in Scan freq
unsigned char Better_ScanFreqID; //pfx:the Scan Freq for the smaller Noise
unsigned char ScanFreqID; // Scan freq ID
unsigned char WorkFreqID; // Current freq ID
short NoiseTh1; // Diff threshold for noise too high judgement
char JumpTh; // frame number threshold for freq jumping
char FailedFreqList [32]; // Searched freq indicator for freq scanning
}STRUCTNOISE;
void AW5306_TP_Init(void);
void AW5306_TP_Reinit(void);
void AW5306_Sleep(void);
char AW5306_TouchProcess(void);
void AW5306_ChargeMode(char mode);
unsigned char AW5306_GetPointNum(void);
unsigned char AW5306_GetPeakNum(void);
char AW5306_GetPoint(int *x,int *y, int *id, int *event,char Index);
void AW5306_GetBase(unsigned short *data, char x,char y);
void AW5306_GetDiff(short *data, char x,char y);
char AW5306_GetPeak(unsigned char *x,unsigned char *y,unsigned char Index);
char AW5306_GetNegPeak(unsigned char *x,unsigned char *y,unsigned char Index);
char AW5306_GetCalcPoint(unsigned short *x,unsigned short *y,unsigned char Index);
char AW5306_CLB(void);
void AW5306_CLB_GetCfg(void);
void AW5306_CLB_WriteCfg(void);
void TP_Force_Calibration(void);
void FreqScan(unsigned char BaseFreq);
#endif
|