53 #define d4dtch_tsc2046_ID 1
58 #if (D4D_MK_STR(D4D_LLD_TCH) == d4dtch_tsc2046_ID)
71 static unsigned char D4DTCH_Init_TSC2046(
void);
72 static unsigned char D4DTCH_DeInit_TSC2046(
void);
74 static unsigned char D4DTCH_GetPositionRaw_TSC2046(
unsigned short *TouchPositionX,
75 unsigned short *TouchPositionY);
89 D4DTCH_GetPositionRaw_TSC2046,
90 D4DTCH_GetRawLimits_TSC2046,
117 static unsigned char D4DTCH_Init_TSC2046(
void)
132 static unsigned char D4DTCH_DeInit_TSC2046(
void)
162 static unsigned char D4DTCH_GetPositionRaw_TSC2046 (
unsigned short *TouchPositionX,
163 unsigned short *TouchPositionY)
165 (void)TouchPositionX;
166 (void)TouchPositionY;
172 #endif //(D4D_MK_STR(D4D_LLD_TCH) == d4dtch_tsc2046_ID)
174 #if 0 // will be implemented ASAP, Petr Gargulak
228 #if (D4D_LLD_TCH == D4D_LLD_TCH_TSC2046)
236 #define GET(x) (x##_PORT) & (1 << (x))
237 #define SET(x) (x##_PORT) |= (1 << (x))
238 #define RESET(x) (x##_PORT) &= ~(1 << (x))
240 #define OUTPUT(x) (x##_DDR) |= (1 << (x))
241 #define INPUT(x) (x##_DDR) &= ~(1 << (x))
243 #define PULL_UP(x) (x##_PE) |= (1 << (x))
244 #define NO_PULL_UP(x) (x##_PE) &= ~(1 << (x))
266 void D4DTCH_Init(
void)
269 #ifdef D4DTCH_MCU_USER_INIT
277 INPUT(D4DTCH_PENIRQ);
289 static unsigned short Tchscr_TSC2046GetChannel(TSC2046_CTRL_BYTE ctrl_byte)
292 unsigned short tmp_res = 0;
323 return (
unsigned short)(tmp_res >> 3);
326 static unsigned char TchScr_GetFilteredAxis(TSC2046_CTRL_BYTE ctrl_byte,
unsigned short *Res)
328 #define AVERAGE_BUFF_LEN 5
331 unsigned short wRes, wSum;
332 unsigned short wADCReading;
333 unsigned char tmp, tmp_res;
336 (void)Tchscr_TSC2046GetChannel(ctrl_byte);
350 wADCReading = Tchscr_TSC2046GetChannel(ctrl_byte);
353 wSum -= wSample[AVERAGE_BUFF_LEN - 1];
354 for(tmp = (AVERAGE_BUFF_LEN - 1); tmp > 0 ;tmp--)
356 wSample[tmp] = wSample[tmp - 1];
359 wSample[0] = wADCReading;
361 wRes = (
unsigned short)(wSum / AVERAGE_BUFF_LEN);
366 if(cnt > AVERAGE_BUFF_LEN) {
375 if(tmp_res >= (AVERAGE_BUFF_LEN - 2)) {
396 unsigned char D4DTCH_GetPositionRaw (
unsigned int *TouchPositionX,
397 unsigned int *TouchPositionY)
400 unsigned short tmpRes;
401 TSC2046_CTRL_BYTE ctrl_byte;
403 if(
GET(D4DTCH_PENIRQ))
406 ctrl_byte.all = TSC_2046_CTRL_BYTE_DIF12_DEFAULT;
408 ctrl_byte.MergedBits.A = TSC2046_CHNL_DIF_Y;
409 if(!TchScr_GetFilteredAxis(ctrl_byte, &tmpRes))
416 #if D4DTCH_AXIS_ORIENT_Y == D4DTCH_AXIS_ORIENT_INVERTED
420 *TouchPositionY = tmpRes;
421 ctrl_byte.MergedBits.A = TSC2046_CHNL_DIF_X;
422 if(!TchScr_GetFilteredAxis(ctrl_byte, &tmpRes)) {
428 #if D4DTCH_AXIS_ORIENT_X == D4DTCH_AXIS_ORIENT_INVERTED
432 *TouchPositionX = tmpRes;
#define D4DTCH_FULL_SCALE
D4D low level touch screen interface API structure.
#define D4DTCH_Y_TOUCH_MIN
D4D Driver main header file.
D4D Driver private header file.
#define D4DTCH_SAMPLE_MARGIN
#define D4DLCD_SPIS_SPTEF
D4D low level touch screen limitation structure.
#define D4DTCH_X_TOUCH_MIN
D4D driver - tsc2046 touch screen driver function header file.
D4D driver - resistive touch screen driver function header file.