⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tchpdd.cpp

📁 WM9713 audio codec driver for WinCE 5.0
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//-----------------------------------------------------------------------------
// Copyright (c) Wolfson Microelectronics plc.  All rights reserved.
//
// This software as well as any related documentation is furnished under 
// license and may only be used or copied in accordance with the terms of the 
// license. The information in this file is furnished for informational use 
// only, is subject to change without notice, and should not be construed as 
// a commitment by Wolfson Microelectronics plc. Wolfson Microelectronics plc
// assumes no responsibility or liability for any errors or inaccuracies that
// may appear in this document or any software that may be provided in
// association with this document. 
//
// Except as permitted by such license, no part of this document may be 
// reproduced, stored in a retrieval system, or transmitted in any form or by 
// any means without the express written consent of Wolfson Microelectronics plc. 
//
// $Id: tchpdd.cpp 2828 2006-04-06 14:11:45Z ian $
//
// The PDD (Platform Dependent Driver) is responsible for
// communicating with the touch panel to calibrate and receive
// touch panel points.
//
// Wolfson touch screen driver.
//
// Warning:
//  This driver is specifically written for Wolfson Codecs. It is not a 
//  general CODEC device driver.
//
//-----------------------------------------------------------------------------

/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995, 1996, 1997  Microsoft Corporation

Module Name:  

  tchpdd.cpp

Abstract:  

  This module contains the DDSI implementation and PDD support routines
  for the touch panel.
  
Functions:

  TouchDriverCalibrationPointGet
  DdsiTouchPanelGetDeviceCaps
  DdsiTouchPanelSetMode
  DdsiTouchPanelEnable
  DdsiTouchPanelDisable
  DdsiTouchPanelAttach
  DdsiTouchPanelDetach
  DdsiTouchPanelGetPoint
  DdsiTouchPanelPowerHandler
  
Revision History:

  John Lindquist (Intergraph) 7/2/95
  Larry Morris (Rho)  9/22/95
  Killian Murphy (Eclipse TG) 7/31/96 (for P2 platform)
  Manoj Thadani (for Sandgate/Lubbock board) 
  Manoj thadani (for Bulverde-Mainstone) 8/6/02
--*/

//--------------------------------------------------------------------------------------
// Include Files
//--------------------------------------------------------------------------------------
#include    <windows.h>
#include	<types.h>
#include    <nkintr.h>
#if ( _WIN32_WCE >= 500 && !defined( WM_BSP_TAHITI ) )
#   include <bsp_cfg.h>
#else
#   include <oalintr.h>
#endif
#include    <tchddsi.h>
#include    "WMTypes.h"
#include    "WMConfig.h"
#include    "WMDevice.h"
#include    "WMTouch.h"
#include    "WMInterrupts.h"

#if !WM_TOUCH || !WM_AUXADC
#error Mismatch: The Wolfson API is not configured for Touch, build system is configured for Touch
#endif /* !WM_TOUCH || !WM_AUXADC */

//-----------------------------------------------------------------------------------------
// defines
//-----------------------------------------------------------------------------------------

#if WM_I2S
/* 2 Wire Address - 0011010 */
#   define WM_I2S_DEVICE_ID_PRIMARY             WM_DEV_I2S_PRIMARY 
#   define WM_I2S_DEVICE_ID_SECONDARY           WM_DEV_I2S_SECONDARY 
#endif

#ifndef ZONE_ALWAYS
#   define ZONE_ALWAYS      TRUE
#endif

//-----------------------------------------------------------------------------------------
// Global Variables.
//-----------------------------------------------------------------------------------------
DWORD gIntrTouch			= SYSINTR_TOUCH;
DWORD gIntrTouchChanged		= SYSINTR_TOUCH_CHANGED;

static TOUCH_PANEL_SAMPLE_FLAGS	PrevStateFlags;
static WM_DEVICE_HANDLE			hTouchDevice;

// The MDD requires a minimum of MIN_CAL_COUNT consecutive samples before
// it will return a calibration coordinate to GWE.  This value is defined
// in the PDD so that each OEM can control the behaviour of the touch
// panel and still use the Microsoft supplied MDD.  Note that the extern "C"
// is required so that the variable name doesn't get decorated, and
// since we have an initializer the 'extern' is actually ignored and
// space is allocated.
extern "C" const int MIN_CAL_COUNT = 25;

INT		CurrentSampleRateSetting = 0;	//	Low sample rate setting

//
// DDSI Implementation
//

//	@DOC	EX_TOUCH_DDSI EXTERNAL DRIVERS TOUCH_DRIVER
//	@FUNC   BOOL | TouchDriverCalibrationPointGet |
//
// Gives a single calibration point.
// 
// 	@XREF
// 		<l TouchPanelReadCalibrationPoint.TouchPanelReadCalibrationPoint>
// 		<l TouchPanelSetCalibration.TouchPanelSetCalibration>
// 		<l TouchPanelReadCalibrationAbort.TouchPanelReadCalibrationAbort>
// 
// 
// 	@COMM
// 
// This function is called to get a single calibration point, in screen
// coordinates, when the input system is calibrating the touch driver.  The input system
// will then draw a target on the screen for the user to press on.
// 
// The driver may use the cDisplayX and cDisplayY to compute a coordinate.
// It does not need to remember this computed value internally since it will
// be passed back when the input system has collected all of the points and
// calls <l TouchPanelSetCalibration.TouchPanelSetCalibration>.
// 
extern "C" BOOL TouchDriverCalibrationPointGet(TPDC_CALIBRATION_POINT *pTCP)
{
	INT32	cDisplayWidth = pTCP->cDisplayWidth;
	INT32	cDisplayHeight = pTCP->cDisplayHeight;

	int	CalibrationRadiusX = cDisplayWidth/10;
	int	CalibrationRadiusY = cDisplayHeight/10;


	switch (pTCP->PointNumber) 
	{
		case	0:	// Middle
			pTCP->CalibrationX = cDisplayWidth/2;
			pTCP->CalibrationY = cDisplayHeight/2;
			break;

		case	1:	// Upper Left
			pTCP->CalibrationX = CalibrationRadiusX*2;
			pTCP->CalibrationY = CalibrationRadiusY*2;
			break;

		case	2:  // Lower Left
			pTCP->CalibrationX = CalibrationRadiusX*2;
			pTCP->CalibrationY = cDisplayHeight - CalibrationRadiusY*2;
			break;

		case	3:  // Lower Right
			pTCP->CalibrationX = cDisplayWidth - CalibrationRadiusX*2;
			pTCP->CalibrationY = cDisplayHeight - CalibrationRadiusY*2;
			break;

		case	4:	// Upper Right
			pTCP->CalibrationX = cDisplayWidth - CalibrationRadiusX*2;
			pTCP->CalibrationY = CalibrationRadiusY*2;
			break;

		default:
			pTCP->CalibrationX = cDisplayWidth/2;
			pTCP->CalibrationY = cDisplayHeight/2;
			SetLastError(ERROR_INVALID_PARAMETER);
			return FALSE;
		}

	return TRUE;
}

//------------------------------------------------------------------------------------------
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func ULONG | DdsiTouchPanelGetDeviceCaps |
//
// Queries capabilities about the physical touch panel device.
//
// @parm ULONG | iIndex |
//
// Specifies the capability to query. They are one of the following:
//
// @flag TPDC_SAMPLERATE_ID |
// The sample rate.
// @flag TPDC_CALIBRATIONPOINTS_ID |
// The X and Y coordinates used for calibration.
// @flag TPDC_CALIBRATIONDATA_ID |
// The X and Y coordinates used for calibration mapping.
//
// @parm LPVOID | lpOutput |
// Points to the memory location(s) where the queried information
// will be placed. The format of the memory referenced depends on
// the setting of iIndex. If 0, returns the number of words
// required for the output data.
//
// @rdesc
// The return values is set to the amount of information supplied and depends
// on the setting of the iIndex argument.
//
// @comm
// Implemented in the PDD.
//------------------------------------------------------------------------------------------
extern "C" BOOL DdsiTouchPanelGetDeviceCaps( INT iIndex, LPVOID lpOutput)
{
	if (lpOutput == NULL) 
	{
		ERRORMSG(1,(__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
		SetLastError(ERROR_INVALID_PARAMETER);
		return FALSE;
	}

	switch ( iIndex )
	{
		case TPDC_SAMPLE_RATE_ID:
			{
			TPDC_SAMPLE_RATE	*pTSR = (TPDC_SAMPLE_RATE*)lpOutput;

			pTSR->SamplesPerSecondLow = WM_TOUCH_SAMPLE_RATE;
			pTSR->SamplesPerSecondHigh = WM_TOUCH_SAMPLE_RATE;
			pTSR->CurrentSampleRateSetting = CurrentSampleRateSetting;
			}
			break;

		case TPDC_CALIBRATION_POINT_COUNT_ID:
			{
			TPDC_CALIBRATION_POINT_COUNT *pTCPC = (TPDC_CALIBRATION_POINT_COUNT*)lpOutput;
			pTCPC->flags = 0;
			pTCPC->cCalibrationPoints = 5;
			}
			break;

		case TPDC_CALIBRATION_POINT_ID:
			return(TouchDriverCalibrationPointGet((TPDC_CALIBRATION_POINT*)lpOutput));

		default:
			ERRORMSG(1,(__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
			SetLastError(ERROR_INVALID_PARAMETER);
			return FALSE;
	}
	return TRUE;
}

//------------------------------------------------------------------------------------------
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func BOOL | DdsiTouchPanelSetMode |
// Sets information about the physical touch panel device.
//
// @parm ULONG | iIndex |
// Specifies the mode to set. They are one of the following:
//
// @flag TPSM_SAMPLERATE_HIGH_ID |
// Sets the sample rate to the high rate.
// @flag TPSM_SAMPLERATE_LOW_ID |
// Sets the sample rate to the low rate.
//
// @parm LPVOID | lpInput |
// Points to the memory location(s) where the update information
// resides. The format of the memory referenced depends on the
// Points to the memory location(s) where the queried information
// will be placed.
//
// @rdesc
// If the function succeeds the return value is TRUE, otherwise, it is FALSE.
//
// @comm
// Implemented in the PDD.
//------------------------------------------------------------------------------------------
BOOL DdsiTouchPanelSetMode(INT iIndex,LPVOID  lpInput)
{
    BOOL  ReturnCode = FALSE;

    switch (iIndex) 
	{
        case TPSM_SAMPLERATE_LOW_ID:
        case TPSM_SAMPLERATE_HIGH_ID:
            SetLastError(ERROR_SUCCESS);
            ReturnCode = TRUE;
            break;

        default:
            SetLastError(ERROR_INVALID_PARAMETER);
            break;
    }
    return (ReturnCode);
}

//------------------------------------------------------------------------------------------
// @doc EX_TOUCH_DDSI EXTERNAL DRIVERS DDSI TOUCH_PANEL
//
// @func BOOL | DdsiTouchPanelEnable |
// Powers up and initializes the touch panel hardware for operation.
//
// @rdesc
// If the function succeeds, the return value is TRUE; otherwise, it is FALSE.
//
// @comm
// Implemented in the PDD.
//------------------------------------------------------------------------------------------
BOOL DdsiTouchPanelEnable(void)
{
    WMSTATUS    status = WMS_NO_SUPPORTED_DEVICE;

    DEBUGMSG(ZONE_FUNCTION,(TEXT( "DdsiTouchPanelEnable+\r\n")));

    //
    // Initialise the Wolfson library.
    //
#if WM_I2S
    /*
     * Try the I2S first...
     */
    status = WMOpenTouchDevice( WM_I2S_DEVICE_ID_PRIMARY, &hTouchDevice );
    if ( WM_SUCCESS( status ) )
    {
        DEBUGMSG( ZONE_INIT, ( TEXT( "DdsiTouchPanelEnable - primary I2S device\r\n" ) ) );
    }
    if ( WMS_CODEC_NOT_READY == status || WMS_NO_SUPPORTED_DEVICE == status )
    {
        /*
         * Nothing responding on I2S primary - try secondary instead...
         */
        status = WMOpenTouchDevice( WM_I2S_DEVICE_ID_SECONDARY, &hTouchDevice );
        if ( WM_SUCCESS( status ) )
        {
            DEBUGMSG( ZONE_INIT, ( TEXT( "DdsiTouchPanelEnable - secondary I2S device\r\n" ) ) );
        }
    }
#endif  /* WM_I2S */
#if WM_AC97
    if ( WMS_CODEC_NOT_READY == status || WMS_NO_SUPPORTED_DEVICE == status )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -