touch.c File Reference

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

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

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. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  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.

Definition in file touch.c.

#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 "calibrate.h"
#include "bsp.h"
#include "i2cspm.h"
#include "eeprom.h"

Macros

#define ADC_X   adcSingleInpCh1
 
#define ADC_Y   adcSingleInpCh4
 
#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
 

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_TypeDefTOUCH_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 }