Detailed Description

Touch panel driver for DK3650, DK3750 and DK3850 Development Kits.

Data Structures

struct TOUCH_Config_TypeDef
struct TOUCH_Pos_TypeDef

Macros

#define ADC_X adcSingleInpCh1
#define ADC_Y adcSingleInpCh4
#define TOUCH_INIT_DEFAULT
#define TOUCH_X1_PIN 5
#define TOUCH_X1_PORT gpioPortD
#define TOUCH_X2_PIN 4
#define TOUCH_X2_PORT gpioPortD
#define TOUCH_Y1_PIN 3
#define TOUCH_Y1_PORT gpioPortD
#define TOUCH_Y2_PIN 1
#define TOUCH_Y2_PORT gpioPortD

Typedefs

typedef void( TOUCH_Upcall_TypeDef ) ( TOUCH_Pos_TypeDef *)

Enumerations

enum TOUCH_State_TypeDef {
TOUCH_INIT ,
TOUCH_CHECK_PRESS ,
TOUCH_MEASURE_X ,
TOUCH_MEASURE_Y
}

Functions

void ADC0_IRQHandler (void)
Interrupt handler is executed with frequency ~28Hz when panel is not pressed and with frequency ~140Hz when panel is pressed - this will give ~50 readings per second.
int TOUCH_CalibrationTable (POINT *displayPtr, POINT *screenPtr)
Set calibration table.
void TOUCH_CallUpcall (void)
Function that calls registered upcall.
TOUCH_Pos_TypeDef * TOUCH_GetPos (void)
Returns current touch position and state.
void TOUCH_Init ( TOUCH_Config_TypeDef *config)
Initialize touch panel driver.
int TOUCH_IsBusy (void)
Check status of the touch panel.
void TOUCH_RecalculatePosition (volatile TOUCH_Pos_TypeDef *pos)
Convert ADC readings into XY position.
void TOUCH_RegisterUpcall ( TOUCH_Upcall_TypeDef *new_upcall)
Register upcall which will be call every position or state change.
int TOUCH_StateChanged (void)
Check if cursor state changed (down or move)

Variables

MATRIX calibrationMatrix = { 103800, 2048, -8184704, -384, 102144, -16424640, 287650 }

Macro Definition Documentation

#define ADC_X   adcSingleInpCh1

Input channel 1

Definition at line 63 of file touch.c .

Referenced by ADC0_IRQHandler() .

#define ADC_Y   adcSingleInpCh4

Input channel 4

Definition at line 64 of file touch.c .

Referenced by ADC0_IRQHandler() , and TOUCH_Init() .

#define TOUCH_INIT_DEFAULT
Value:
{ 500000, /* 500kHz sampling frequency */ \
1, /* Ignore moves not greater than 1 pixel */ \
adcOvsRateSel128, /* Oversampling 128 times */ \
}

Initializes Touch default values

Definition at line 76 of file touch.h .

#define TOUCH_X1_PIN   5

Pin 5

Definition at line 68 of file touch.c .

Referenced by ADC0_IRQHandler() .

#define TOUCH_X1_PORT   gpioPortD

Port D

Definition at line 67 of file touch.c .

Referenced by ADC0_IRQHandler() .

#define TOUCH_X2_PIN   4

Pin 4

Definition at line 70 of file touch.c .

Referenced by ADC0_IRQHandler() , and TOUCH_IsBusy() .

#define TOUCH_X2_PORT   gpioPortD

Port D

Definition at line 69 of file touch.c .

Referenced by ADC0_IRQHandler() , and TOUCH_IsBusy() .

#define TOUCH_Y1_PIN   3

Pin 3

Definition at line 72 of file touch.c .

Referenced by ADC0_IRQHandler() .

#define TOUCH_Y1_PORT   gpioPortD

Port D

Definition at line 71 of file touch.c .

Referenced by ADC0_IRQHandler() .

#define TOUCH_Y2_PIN   1

Pin 1

Definition at line 74 of file touch.c .

Referenced by ADC0_IRQHandler() .

#define TOUCH_Y2_PORT   gpioPortD

Port D

Definition at line 73 of file touch.c .

Referenced by ADC0_IRQHandler() .

Typedef Documentation

typedef void( TOUCH_Upcall_TypeDef) ( TOUCH_Pos_TypeDef *)

touch panel upcall type definition

Definition at line 83 of file touch.h .

Enumeration Type Documentation

touch driver states

Definition at line 77 of file touch.c .

Function Documentation

int TOUCH_CalibrationTable ( POINT * displayPtr,
POINT * screenPtr
)

Set calibration table.

Parameters
[in] displayPtr Table of display points
[in] screenPtr Table of adc values reflecting display points
Returns
Returns OK if calibration table is set.

Definition at line 433 of file touch.c .

References calibrationMatrix .

TOUCH_Pos_TypeDef * TOUCH_GetPos ( void )

Returns current touch position and state.

Returns
Current touch position and state

Definition at line 396 of file touch.c .

References ADC_IntDisable() , ADC_IntEnable() , TOUCH_Pos_TypeDef::adcx , TOUCH_Pos_TypeDef::adcy , TOUCH_Pos_TypeDef::pen , TOUCH_Pos_TypeDef::x , and TOUCH_Pos_TypeDef::y .

int TOUCH_IsBusy ( void )

Check status of the touch panel.

Returns
0 if panel is idle (not touched).

Definition at line 344 of file touch.c .

References GPIO_PinInGet() , TOUCH_X2_PIN , and TOUCH_X2_PORT .

void TOUCH_RecalculatePosition ( volatile TOUCH_Pos_TypeDef * pos )

Convert ADC readings into XY position.

Parameters
[in] pos Pointer to position structure

Definition at line 185 of file touch.c .

References TOUCH_Pos_TypeDef::adcx , TOUCH_Pos_TypeDef::adcy , calibrationMatrix , TOUCH_Pos_TypeDef::pen , TOUCH_Pos_TypeDef::x , and TOUCH_Pos_TypeDef::y .

Referenced by ADC0_IRQHandler() .

void TOUCH_RegisterUpcall ( TOUCH_Upcall_TypeDef * new_upcall )

Register upcall which will be call every position or state change.

Parameters
[in] new_upcall Pointer to upcall function

Definition at line 416 of file touch.c .

int TOUCH_StateChanged ( void )

Check if cursor state changed (down or move)

Returns
1 if the cursor state has changed

Definition at line 228 of file touch.c .

References TOUCH_Pos_TypeDef::pen , TOUCH_Pos_TypeDef::x , and TOUCH_Pos_TypeDef::y .

Referenced by ADC0_IRQHandler() .

Variable Documentation

MATRIX calibrationMatrix = { 103800, 2048, -8184704, -384, 102144, -16424640, 287650 }

Calibration table

Definition at line 97 of file touch.c .

Referenced by TOUCH_CalibrationTable() , and TOUCH_RecalculatePosition() .