📄 tsc2101spi.h
字号:
/*************************************************************/
//
// Copyright (c) Texas Instruments 2003. 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:
TSC2101SPI.H
Abstract:
This header file contains the function prototypes
to the SPI for interfacing with TI's TSC2101 device.
Functions:
Revision History:
***************************************************************/
#ifndef __TSC2101SPI_H__
#define __TSC2101SPI_H__
#include "TSC2101Regs.H"
BOOL Is_DAV_Open(void);
void SPIWait(unsigned int microSec) ;
//@@APE: here is a way to switch between the DRVLIB SPI and the DLL SPI
//If USE_DLL is not declared, we declare the SPI functions as we are used to do.
//If it is declared, we only declare pointers (through the DECLARE macro) to these functions and the ImportFunctions
//will have to be called to give them the good address (through the IMPORT_FUNC macro)
#ifdef USE_DLL
//this macro helps declaring a pointer to a function, giving the return type, the name of the function and its parapeter types
#define DECLARE(RET,NAME,ARGS) RET (*NAME) ARGS
//this macro helps importing a function from a DLL. Use the same parameters as DECLARE macro plus an instance of the DLL
#define IMPORT_FUNC(RET,NAME,ARGS,INSTANCE) NAME= (RET (*) ARGS) GetProcAddress(INSTANCE,TEXT(#NAME))
#else
#define MUTEX_NAME (TEXT("SPIMUTEX"))
#define DECLARE(RET,NAME,ARGS) RET NAME ARGS
#endif
//@@APE: end here is a way to switch between the DRVLIB SPI and the DLL SPI
#ifdef __cplusplus
extern "C" {
#endif
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
//// SPI Functions that builds the Interface for ////
//// the Host Processor and the TSC2101 Device ////
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
//***************************************************
// SPI Configuration or Setup
//***************************************************
DECLARE(void,InitializeSPIDriver,(void));
DECLARE(void,DeinitializeSPIDriver,(void));
DECLARE(void,SetupSPIController,(BOOL));
DECLARE(void,StopSPIController,(BOOL));
//***************************************************
// SPI Transaction
//***************************************************
DECLARE(void,SPITransaction,(unsigned __int16 *pWord,unsigned __int16 NbWords,BOOL bInPowerHandler));
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//// ALL of the following functions are tired to the device ////
//// TSC2101 but "processor independent" ////
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//***************************************************************
//
// TSC2101 Touch Screen, Keypad, Audio and GPIO
// Control Registers Writing and Readings
//
//***************************************************************
// Special Functions for Control TSC2101
DECLARE(void,TSC2101Reset,(BOOL bInPowerHandler));
DECLARE(void,TSC2101StopConversions,(BOOL bInPowerHandler));
DECLARE(void,TSC2101SetupADCReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
// Functions for Control TSC2101 Touch Screen
DECLARE(unsigned __int16, TSC2101ReadADCReg,(BOOL bInPowerHandler));
DECLARE(unsigned __int16 ,TSC2101ReadREFReg,(BOOL bInPowerHandler));
DECLARE(unsigned __int16, TSC2101ReadCFGReg,(BOOL bInPowerHandler));
DECLARE(void ,TSC2101WriteADCReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
DECLARE(void ,TSC2101WriteREFReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
DECLARE(void ,TSC2101WriteCFGReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
// Functions for Control TSC2101 Audio
//DECLARE(unsigned __int16 ,TSC2101ReadAudioControlReg,(BOOL bInPowerHandler));
//DECLARE(unsigned __int16 ,TSC2101ReadAudioADCVolumeReg,(BOOL bInPowerHandler));
//DECLARE(unsigned __int16 ,TSC2101ReadAudioDACVolumeReg,(BOOL bInPowerHandler));
//DECLARE(unsigned __int16 ,TSC2101ReadAudioByPassReg,(BOOL bInPowerHandler));
//DECLARE(unsigned __int16 ,TSC2101ReadAudioKeyClickReg,(BOOL bInPowerHandler));
//DECLARE(unsigned __int16 ,TSC2101ReadAudioPowerReg,(BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteAudioControlReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteAudioADCVolumeReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteAudioDACVolumeReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteAudioByPassReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteAudioKeyClickReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteAudioPowerReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
// Functions for Control TSC2101 GPIOs
//DECLARE(unsigned __int16, TSC2101ReadGPIOReg,(BOOL bInPowerHandler));
//DECLARE(void ,TSC2101WriteGPIOReg,(unsigned __int16 newValue,BOOL bInPowerHandler));
// Functions for General TSC2101 Control Register R/W
DECLARE(unsigned __int16, TSC2101ReadReg,(unsigned __int16 sourceReg,BOOL bInPowerHandler));
DECLARE(void, TSC2101WriteReg,(unsigned __int16 targetReg,unsigned __int16 newValue,BOOL bInPowerHandler));
//***************************************************************
//
// Touch Screen, Keypad, BAT1/2, AUX1/2, TEMP1/2 and DAC
// Data Readings
//
//***************************************************************
// Functions for TSC2101 Touch Screen Data Read
DECLARE(void, TSC2101ReadX,(unsigned __int16 *pXdata,BOOL bInPowerHandler));
DECLARE(void, TSC2101ReadXY,(unsigned __int16 *pXdata,unsigned __int16 *pYdata,BOOL bInPowerHandler));
DECLARE(void, TSC2101ReadXYZ,(unsigned __int16 *pXdata,unsigned __int16 *pYdata,unsigned __int16 *pZ1data,unsigned __int16 *pZ2data,BOOL bInPowerHandler));
// Functions for TSC2101 BAT1, BAT2, AUX1 & AUX2 Data Read
DECLARE(void ,TSC2101ReadPORTData,(unsigned __int16 *pBdata,unsigned __int16 *pA1data,unsigned __int16 *pA2data,BOOL bInPowerHandler));
// Functions for TSC2101 Temperature Measurement Data Read
DECLARE(unsigned __int16, TSC2101ReadTEMP1Data,(BOOL bInPowerHandler));
DECLARE(unsigned __int16, TSC2101ReadTEMP2Data,(BOOL bInPowerHandler));
//***************************************************************
// local subroutines
//***************************************************************
// TSC2101 Initial Setup
DECLARE(void, InitTSC2101Touch,(BOOL bInPowerHandler));
DECLARE(void, InitTSC2101Audio,(BOOL bInPowerHandler));
// TSC2101 ADC Mutex handling
DECLARE(HANDLE, CreateTSCMutex,(void));
DECLARE(BOOL, GrabTSCMutex,(HANDLE hTempMutex, int iTimeout));
DECLARE(void, ReleaseTSCMutex,(HANDLE hTempMutex));
DECLARE(void, CloseTSCMutex,(HANDLE hTempMutex));
#ifdef __cplusplus
}
#endif
#ifdef USE_DLL
__inline int ImportFunctions(void)
{
HINSTANCE hinstLib;
hinstLib = LoadLibrary(TEXT("SPIDLL.dll"));
if (hinstLib == NULL)
{
DEBUGMSG(1,(__TEXT("SPIDLL not loaded\r\n")));
return 1;
}
else
{
DEBUGMSG(1,(__TEXT("SPIDLL loaded\r\n")));
}
IMPORT_FUNC(void,InitializeSPIDriver,(void));
IMPORT_FUNC(void,DeinitializeSPIDriver,(void));
IMPORT_FUNC(void,SetupSPIController,(BOOL));
IMPORT_FUNC(void,StopSPIController,(BOOL));
IMPORT_FUNC(void,SPITransaction,(unsigned __int16 *pWords,unsigned __int16 NbWords,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void,TSC2101Reset,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void,TSC2101StopConversions,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void,TSC2101SetupADCReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(unsigned __int16, TSC2101ReadADCReg,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(unsigned __int16 ,TSC2101ReadREFReg,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(unsigned __int16, TSC2101ReadCFGReg,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void ,TSC2101WriteADCReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void ,TSC2101WriteREFReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void ,TSC2101WriteCFGReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16 ,TSC2101ReadAudioControlReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16 ,TSC2101ReadAudioADCVolumeReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16 ,TSC2101ReadAudioDACVolumeReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16 ,TSC2101ReadAudioByPassReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16 ,TSC2101ReadAudioKeyClickReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16 ,TSC2101ReadAudioPowerReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteAudioControlReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteAudioADCVolumeReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteAudioDACVolumeReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteAudioByPassReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteAudioKeyClickReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteAudioPowerReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(unsigned __int16, TSC2101ReadGPIOReg,(BOOL bInPowerHandler),hinstLib);
// IMPORT_FUNC(void ,TSC2101WriteGPIOReg,(unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(unsigned __int16, TSC2101ReadReg,(unsigned __int16 sourceReg,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void, TSC2101WriteReg,(unsigned __int16 targetReg,unsigned __int16 newValue,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void, TSC2101ReadX,(unsigned __int16 *pXdata,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void, TSC2101ReadXY,(unsigned __int16 *pXdata,unsigned __int16 *pYdata,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void, TSC2101ReadXYZ,(unsigned __int16 *pXdata,unsigned __int16 *pYdata,unsigned __int16 *pZ1data,unsigned __int16 *pZ2data,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void ,TSC2101ReadPORTData,(unsigned __int16 *pBdata,,unsigned __int16 *pA1data,unsigned __int16 *pA2data,BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(unsigned __int16, TSC2101ReadTEMP1Data,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(unsigned __int16, TSC2101ReadTEMP2Data,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void, InitTSC2101Touch,(BOOL bInPowerHandler),hinstLib);
IMPORT_FUNC(void, InitTSC2101Audio,(BOOL bInPowerHandler),hinstLib);
// TSC2101 ADC Mutex handling
IMPORT_FUNC(HANDLE, CreateTSCMutex,(void),hinstLib);
IMPORT_FUNC(BOOL, GrabTSCMutex,(HANDLE hTempMutex, int iTimeout),hinstLib);
IMPORT_FUNC(void, ReleaseTSCMutex,(HANDLE hTempMutex),hinstLib);
IMPORT_FUNC(void, CloseTSCMutex,(HANDLE hTempMutex),hinstLib);
return 0;
}
#else
__inline int ImportFunctions(void)
{
return 0;
}
#endif
#endif
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -