📄 touch.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/* Copyright 1999,2000,2001 Intel Corp. */
/*++
Module Name: tchpdd.h
Abstract:
This has the header file definitions for the touch driver.
Notes:
Created: July 22, 1997
--*/
#ifndef __TOUCH_H__
#define __TOUCH_H__
//
// Digitizer related definitions.
//
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | DELTA_X_COORD_VARIANCE |
// Maximum allowed variance in the X coordinate samples.
//
#define DELTA_X_COORD_VARIANCE 0x16
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | DELTA_Y_COORD_VARIANCE |
// Maximum allowed variance in the X coordinate samples.
//
#define DELTA_Y_COORD_VARIANCE 0x16
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | MIN_X_DIGITIZER_COORD |
// Minimum X coordinate.
//
#define MIN_X_DIGITIZER_COORD 0
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | MAX_X_DIGITIZER_COORD |
// Maximum X coordinate.
//
#define MAX_X_DIGITIZER_COORD (1<<10)
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | MIN_Y_DIGITIZER_COORD |
// Minimum Y coordinate.
//
#define MIN_Y_DIGITIZER_COORD 0
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | MAX_Y_DIGITIZER_COORD |
// Maximum Y coordinate.
//
#define MAX_Y_DIGITIZER_COORD (1<<10)
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | MAX_NOISE_COUNT |
// Maximum noise count.
//
#define MAX_NOISE_COUNT 4
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | TOUCHPANEL_SAMPLE_RATE_LOW |
// Low sampling rate.
//
#define TOUCHPANEL_SAMPLE_RATE_LOW 150
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | TOUCHPANEL_SAMPLE_RATE_HIGH |
// High sampling rate.
//
#define TOUCHPANEL_SAMPLE_RATE_HIGH 150
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @const ULONG | TOUCH_NUM_REJECT |
// Number of initial samples to reject.
//
#define TOUCH_NUM_REJECT 1
//
// TOUCH_TIMER_INCREMENT is the constant that decides the sampling rate of the touch controller's
// ADC. The formulae used to get the number below is :-
// (3.6864 * 10^6)
// TOUCH_TIMER_INCREMENT = ---------------
// Sample Rate
// For Example if the Sample Rate decided is 150 samples per second then the
// TOUCH_TIMER_INCREMENT should be 0x6000
#define TOUCH_TIMER_INCREMENT 0x9000
// UCB1x00 CODEC defines
#define UCB_IO_DATA 0x005A
#define UCB_IO_DIR 0x005C
#define UCB_RE_IE 0x005E
#define UCB_FE_IE 0x0060
#define UCB_INT_CS 0x0062
#define UCB_TCH_CR 0x0064
#define UCB_ADC_CR 0x0066
#define UCB_ADC_DATA 0x0068
#define UCB_ADC_X 0x8008
#define UCB_ADC_XSTART 0x8088
#define UCB_ADC_Y 0x8000
#define UCB_ADC_YSTART 0x8080
#define UCB_ADC_RES 0x0000
#define UCB_ADC_DONE 0x8000
#define UCB_PEN_DOWN 0x3000
// mask definitions for ucb1x00Touch Control Register Bits
#define TSMX_POW 0x0001
#define TSPX_POW (0x0001 << 1)
#define TSMY_POW (0x0001 << 2)
#define TSPY_POW (0x0001 << 3)
#define TSPX_GND (0x0001 << 5)
#define TSMX_GND (0x0001 << 4)
#define TSMY_GND (0x0001 << 6)
#define TSPY_GND (0x0001 << 7)
#define TSC_BIAS_ENA (0x0001 << 11)
#define TSC_MODE_INT 0x0000
#define TSC_MODE_PREASSURE (0x0001 << 8)
#define TSC_MODE_POSITION (0x0001 << 9)
#define TSPX_LOW (0x0001 << 12)
#define TSMX_LOW (0x0001 << 13)
// mask definitions for ucb1x00ierBits
#define TSPX_INT (0x0001 << 12)
#define ADC_INT (0x0001 << 11)
#define TSMX_INT (0x0001 << 13)
#define TCLIP_INT (0x0001 << 14)
#define ACLIP_INT (0x0001 << 15)
#define IO_INT_CLR 0x3FF
// mask definitions for ADC Control Register
#define ADC_SYNC_ENA 0x0001
#define VREFBYP_CON (0x0001 << 1)
#define ADC_INPUT_TSPX 0x0000
#define ADC_INPUT_TSMX 0x0004
#define ADC_INPUT_TSPY (ADC_INPUT_TSMX << 1)
#define ADC_INPUT_TSMY (ADC_INPUT_TSPY | ADC_INPUT_TSMX)
#define ADC_INPUT_AD0 (ADC_INPUT_TSMX << 2)
#define ADC_INPUT_AD1 (ADC_INPUT_AD0 | ADC_INPUT_TSMX)
#define ADC_INPUT_AD2 (ADC_INPUT_AD0 | ADC_INPUT_TSPY)
#define ADC_INPUT_AD3 (ADC_INPUT_AD2 | ADC_INPUT_TSMX)
#define EXT_REF_ENA (0x0001 << 5)
#define ADC_START (0x0001 << 7)
#define ADC_ENA (0x0001 << 15)
#define ADC_INPUT_TEMPERATURE 0x0018
#define ADC_INPUT_VOLTAGE 0x001c
//mask definitions for ADC Data Bits
#define ADC_DATA 0x3FF
#define ADC_DATA_VAL (0x00000001 << 15)
#define NUMBER_SAMPLES_PER_POINT 3
//
// Status field valid values
//
#define TOUCH_PEN_DOWN 0
#define TOUCH_PEN_UP 1
#define TOUCH_TIMER 2
#define TOUCH_PEN_SAMPLE 2
#define UCB_INTERRUPT_MODE (0x0)
#define UCB_PRESSURE_MODE (0x1)
#define UCB_POSITION_MODE (0x2)
// There are two expected stylus interrupt states: sylus down (the stylus is currently up) and
// stylus up or a timer event (the stylus is down and will either be lifted or the timer will
// fire and gwes will capture the point for drawing).
//
typedef enum
{
PEN_DOWN,
PEN_UP_OR_TIMER
} EXPECTED_INT_EVENT;
#define MAX_ADC_VAL 0x3FF
typedef struct
{
USHORT XSample; //@field X Coordinate.
USHORT YSample; //@field Y Coordinate.
} TOUCHPANEL_POINT_SAMPLE, *PTOUCHPANEL_POINT_SAMPLE;
//
// @doc INTERNAL DRIVERS PDD TOUCH_PANEL
// @type TOUCHPANEL_POINT_SAMPLES |
// Array of NUMBER_SAMPLES_PER_POINT samples.
//
typedef TOUCHPANEL_POINT_SAMPLE TOUCHPANEL_POINT_SAMPLES[NUMBER_SAMPLES_PER_POINT];
static BOOL AllocateTouchPanelResources(void);
static void DeallocateTouchPanelResources(void);
static void EnableTouchTimerInterrupt(UINT32);
static void EnableTouchInterrupt(void);
TOUCH_PANEL_SAMPLE_FLAGS PDDSampleTouchScreen(INT *x, INT *y);
#endif // __TOUCH_H__.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -