?? hosttouch.cpp
字號:
/******************************************************************/
//
// Copyright (c) Texas Instruments 2005. All rights reserved.
//
/*******************************************************************
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.
Module Name:
HostTouch.CPP
Abstract:
This module presents an example to use TSC2046 Touch Screen
driver. The host processor here is Intel's PXA27x (Bulverde)
processor and code was tested on MainStone development
platform.
Functions:
Revision History:
Rev 0.0 Original Release WXF 9-30-2005
********************************************************************/
//-------------------------------------------------------------------
// Include Files
//-------------------------------------------------------------------
#include <windows.h>
#include <bsp.h>
#include <TSC2046SPI.h>
#include "HostTouch.H" // functions from host processor
//------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------
static volatile BULVERDE_INTR_REG *g_pICRegs = NULL;
static volatile BULVERDE_OST_REG *g_pOSTRegs = NULL;
static volatile MAINSTONEII_BLR_REGS *g_pBLRegs = NULL;
//
//-------------------------------------------------------------------
// Function: HWDeallocateTouchPanelResources(void)
// Purpose: Clean up host for any PDD-allocated touch panel resources
//-------------------------------------------------------------------
//
void HWDeallocateTouchPanelResources(void)
{
if (g_pICRegs)
{
VirtualFree((void *)g_pICRegs, 0, MEM_RELEASE);
g_pICRegs = NULL;
}
if (g_pOSTRegs)
{
VirtualFree((void *)g_pOSTRegs, 0, MEM_RELEASE);
g_pOSTRegs = NULL;
}
if (g_pBLRegs)
{
VirtualFree((void *)g_pBLRegs, 0, MEM_RELEASE);
g_pBLRegs = NULL;
}
}
//
//-------------------------------------------------------------------
// Function: BOOL HWAllocateTouchPanelResources(void)
// Purpose: Allocate touch panel resources on host
//-------------------------------------------------------------------
//
BOOL HWAllocateTouchPanelResources(void)
{
PHYSICAL_ADDRESS RegPA;
if (g_pICRegs == NULL)
{
RegPA.QuadPart = BULVERDE_BASE_REG_PA_INTC;
g_pICRegs = (volatile BULVERDE_INTR_REG *) MmMapIoSpace(RegPA, 0x400, FALSE);
}
if (g_pOSTRegs == NULL)
{
RegPA.QuadPart = BULVERDE_BASE_REG_PA_OST;
g_pOSTRegs = (volatile BULVERDE_OST_REG *) MmMapIoSpace(RegPA, 0x400, FALSE);
}
if (g_pBLRegs == NULL)
{
RegPA.QuadPart = MAINSTONEII_BASE_REG_PA_FPGA;
g_pBLRegs = (volatile MAINSTONEII_BLR_REGS *) MmMapIoSpace(RegPA, 0x400, FALSE);
}
if ( !g_pICRegs || !g_pOSTRegs || !g_pBLRegs)
{
RETAILMSG(1, (TEXT("ERROR: Failed to allocate touch panel resources (Error=%u).\r\n"),
GetLastError()));
HWDeallocateTouchPanelResources();
return(FALSE);
}
return(TRUE);
}
//
//---------------------------------------------------------------------------------
// Function: HWGetTouchStatus
// Purpose: This function check the status of the /PENIRQ of Mainstone platform
// (/PENIRQ had been mapped to GPIO0 of the processor to give the host
// interrupt when touching on panel).
// Returns: BOOL
//----------------------------------------------------------------------------------
//
BOOL HWGetTouchStatus(void)
{
BOOL PenDown;
// check /PENIRQ status
if (g_pBLRegs->misc_rd & (1 << 9))
PenDown = 0; // /PENIRQ is high = panel is up (no touch)
else
PenDown = 1; // /PENIRQ is low = panel is down (touched)
RETAILMSG(1,(TEXT("HWGetTouchStatus: PenStatus=%d\r\n"),PenDown));
return (PenDown);
}
//
//---------------------------------------------------------------------------------
// Function: HWEnableTouchTimerIRQ
// Purpose: This function will use Timer 1 of the processor to give a
// timer interrupt after timeout msec.
// Returns: void
//----------------------------------------------------------------------------------
//
void HWEnableTouchTimerIRQ(UINT32 TimeInterval)
{
UINT32 TimerMatch;
XLLP_OST_HANDLE_T XllpOSTHandle;
// Obtain pointers to OST and INTC registers.
XllpOSTHandle.pOSTRegs = (XLLP_OST_T *) g_pOSTRegs;
XllpOSTHandle.pINTCRegs = (XLLP_INTC_T *) g_pICRegs;
// XLLI initializes oier and rtsr to zeroes, so no further
// initialization needs to be done. Match timers and
// alarms are disabled.
//
// Current usage of Match registers:
// M0 - Scheduler
// M1 - Touch Panel
// M2 - Profiler
//
// Configure and arm the timer interrupt to interrupt
// every specified system tick interval.
TimerMatch = (XllpOSTHandle.pOSTRegs->oscr0 + TimeInterval);
XllpOstConfigureTimer (&XllpOSTHandle, MatchReg1, TimerMatch);
}
///////////////////////////////////////////////////////////
///// End of HostTouch.CPP Functions
///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -