touch.c File Reference

EFM32GG_DK3750, Touch panel driver. More...

#include <stdlib.h>
#include <string.h>
#include "em_device.h"
#include "em_adc.h"
#include "em_gpio.h"
#include "em_cmu.h"
#include "touch.h"
#include <math.h>
#include "calibrate.h"
#include "bsp.h"
#include "i2cdrv.h"
#include "eeprom.h"
Include dependency graph for touch.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ADC_X   adcSingleInpCh1
 Input channel 1.
#define ADC_Y   adcSingleInpCh4
 Input channel 4.
#define TOUCH_X1   gpioPortD, 5
 Port D5.
#define TOUCH_X2   gpioPortD, 4
 Port D4.
#define TOUCH_Y1   gpioPortD, 3
 Port D3.
#define TOUCH_Y2   gpioPortD, 1
 Port D2.

Enumerations

enum  TOUCH_State_TypeDef {
  TOUCH_INIT,
  TOUCH_CHECK_PRESS,
  TOUCH_MEASURE_X,
  TOUCH_MEASURE_Y
}
 

touch driver states

More...

Functions

void TOUCH_RecalculatePosition (volatile TOUCH_Pos_TypeDef *pos)
 Convert ADC readings into XY position.
void TOUCH_CallUpcall (void)
 Function that calls registered upcall.
int TOUCH_StateChanged (void)
 Check if cursor state changed (down or move).
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_IsBusy (void)
 Check status of the touch panel.
void TOUCH_Init (TOUCH_Config_TypeDef *config)
 Initialize touch panel driver.
TOUCH_Pos_TypeDefTOUCH_GetPos (void)
 Returns current touch position and state.
void TOUCH_RegisterUpcall (TOUCH_Upcall_TypeDef *new_upcall)
 Register upcall which will be call every position or state change.
int TOUCH_CalibrationTable (POINT *displayPtr, POINT *screenPtr)
 Set calibration table.

Variables

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

Detailed Description

EFM32GG_DK3750, Touch panel driver.

Author:
Energy Micro AS
Version:
3.20.0

License

(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. 4. The source and compiled code may only be used on Energy Micro "EFM32" microcontrollers and "EFR4" radios.

DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no obligation to support this Software. Energy Micro AS is providing the Software "AS IS", with no express or implied warranties of any kind, including, but not limited to, any implied warranties of merchantability or fitness for any particular purpose or warranties against infringement of any proprietary rights of a third party.

Energy Micro AS will not be liable for any consequential, incidental, or special damages, or any other relief, or for any claim by any third party, arising from your use of this Software.

Definition in file touch.c.


Define Documentation

#define ADC_X   adcSingleInpCh1

Input channel 1.

Definition at line 55 of file touch.c.

Referenced by ADC0_IRQHandler().

#define ADC_Y   adcSingleInpCh4

Input channel 4.

Definition at line 56 of file touch.c.

Referenced by ADC0_IRQHandler(), and TOUCH_Init().

#define TOUCH_X1   gpioPortD, 5

Port D5.

Definition at line 59 of file touch.c.

Referenced by ADC0_IRQHandler().

#define TOUCH_X2   gpioPortD, 4

Port D4.

Definition at line 60 of file touch.c.

Referenced by ADC0_IRQHandler(), and TOUCH_IsBusy().

#define TOUCH_Y1   gpioPortD, 3

Port D3.

Definition at line 61 of file touch.c.

Referenced by ADC0_IRQHandler().

#define TOUCH_Y2   gpioPortD, 1

Port D2.

Definition at line 62 of file touch.c.

Referenced by ADC0_IRQHandler().


Enumeration Type Documentation

touch driver states

Definition at line 65 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.

Definition at line 233 of file touch.c.

References ADC_X, ADC_Y, TOUCH_Pos_TypeDef::adcx, TOUCH_Pos_TypeDef::adcy, TOUCH_Pos_TypeDef::pen, TOUCH_CallUpcall(), TOUCH_RecalculatePosition(), TOUCH_StateChanged(), TOUCH_X1, TOUCH_X2, TOUCH_Y1, TOUCH_Y2, TOUCH_Pos_TypeDef::x, and TOUCH_Pos_TypeDef::y.

Here is the call graph for this function:

void TOUCH_CallUpcall ( void   ) 

Function that calls registered upcall.

Definition at line 199 of file touch.c.

Referenced by ADC0_IRQHandler().

Here is the caller graph for this function:

void TOUCH_RecalculatePosition ( volatile TOUCH_Pos_TypeDef pos  ) 

Convert ADC readings into XY position.

Parameters:
[in] pos Pointer to position structure

Definition at line 172 of file touch.c.

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

Referenced by ADC0_IRQHandler().

Here is the caller graph for this function:

int TOUCH_StateChanged ( void   ) 

Check if cursor state changed (down or move).

Returns:
1 if the cursor state has changed

Definition at line 212 of file touch.c.

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

Referenced by ADC0_IRQHandler().

Here is the caller graph for this function:


Variable Documentation

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

Calibration table.

Definition at line 85 of file touch.c.