Touch
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 |
#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 |
Initializes Touch default values
Definition at line
76
of file
touch.h
.
#define TOUCH_X1_PIN 5 |
#define TOUCH_X1_PORT gpioPortD |
#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 |
#define TOUCH_Y1_PORT gpioPortD |
#define TOUCH_Y2_PIN 1 |
#define TOUCH_Y2_PORT gpioPortD |
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
enum TOUCH_State_TypeDef |
touch driver states
Definition at line
77
of file
touch.c
.
Function Documentation
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.
ADC0 IRQ Handler
Definition at line
255
of file
touch.c
.
References ADC_InitSingle_TypeDef::acqTime , ADC_DataSingleGet() , ADC_InitSingle() , ADC_IntClear() , ADC_Start() , ADC_X , ADC_Y , adcAcqTime128 , adcAcqTime16 , adcRefVDD , adcResOVS , adcStartSingle , TOUCH_Pos_TypeDef::adcx , TOUCH_Pos_TypeDef::adcy , GPIO_PinInGet() , GPIO_PinModeSet() , gpioModeInput , gpioModeInputPullFilter , gpioModePushPull , TOUCH_Pos_TypeDef::pen , ADC_InitSingle_TypeDef::reference , ADC_InitSingle_TypeDef::resolution , TOUCH_CallUpcall() , TOUCH_RecalculatePosition() , TOUCH_StateChanged() , TOUCH_X1_PIN , TOUCH_X1_PORT , TOUCH_X2_PIN , TOUCH_X2_PORT , TOUCH_Y1_PIN , TOUCH_Y1_PORT , TOUCH_Y2_PIN , TOUCH_Y2_PORT , TOUCH_Pos_TypeDef::x , and TOUCH_Pos_TypeDef::y .
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 .
void TOUCH_Init | ( | TOUCH_Config_TypeDef * |
config
|
) |
Initialize touch panel driver.
- Parameters
-
config
Driver configuration data.
Definition at line
364
of file
touch.c
.
References ADC_Init() , ADC_INIT_DEFAULT , ADC_InitSingle() , ADC_IntClear() , ADC_IntDisable() , ADC_IntEnable() , ADC_PrescaleCalc() , ADC_Start() , ADC_Y , adcRefVDD , adcResOVS , adcStartSingle , BSP_PeripheralAccess() , BSP_TOUCH , CMU_ClockEnable() , cmuClock_ADC0 , TOUCH_Config_TypeDef::frequency , TOUCH_Config_TypeDef::ignore , TOUCH_Config_TypeDef::oversampling , ADC_Init_TypeDef::ovsRateSel , ADC_Init_TypeDef::prescale , ADC_InitSingle_TypeDef::reference , and ADC_InitSingle_TypeDef::resolution .
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() .