extern "C"
BOOL
DdsiTouchPanelGetDeviceCaps(
INT iIndex,
LPVOID lpOutput
)
{
if ( lpOutput == NULL )
{
ERRORMSG(1, (__TEXT("TouchPanelGetDeviceCaps: invalid parameter.\r\n")));
SetLastError(ERROR_INVALID_PARAMETER);
DebugBreak();
return FALSE;
}
switch ( iIndex )
{
case TPDC_SAMPLE_RATE_ID:
{
TPDC_SAMPLE_RATE *pTSR = (TPDC_SAMPLE_RATE*)lpOutput;
pTSR -> SamplesPerSecondLow = TOUCHPANEL_SAMPLE_RATE_LOW;
pTSR -> SamplesPerSecondHigh = TOUCHPANEL_SAMPLE_RATE_HIGH;
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);
DebugBreak();
return FALSE;
}
return TRUE;
}
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 );
}
BOOL
DdsiTouchPanelEnable(
VOID
)
{
BOOL Ret;
if(v_pIOPregs == NULL) {
v_pIOPregs = (volatile IOPreg *)
VirtualAlloc(0,sizeof(IOPreg),MEM_RESERVE, PAGE_NOACCESS);
if(v_pIOPregs == NULL) {
ERRORMSG(1,(TEXT("For IOPreg: VirtualAlloc failed!\r\n")));
return (FALSE);
}
else {
if(!VirtualCopy((PVOID)v_pIOPregs,(PVOID)(IOP_BASE),sizeof(IOPreg),
PAGE_READWRITE | PAGE_NOCACHE )) {
ERRORMSG(1,(TEXT("For pIOPregs: VirtualCopy failed!\r\n")));
PddpTouchPanelDeallocateVm();
return (FALSE);
}
}
}
if(v_pADCregs == NULL) {
v_pADCregs = (volatile ADCreg *)
VirtualAlloc(0,sizeof(ADCreg),MEM_RESERVE, PAGE_NOACCESS);
if(v_pADCregs == NULL) {
ERRORMSG(1,(TEXT("For ADCreg: VirtualAlloc failed!\r\n")));
return (FALSE);
}
else {
if(!VirtualCopy((PVOID)v_pADCregs,(PVOID)(ADC_BASE),sizeof(ADCreg),
PAGE_READWRITE | PAGE_NOCACHE )) {
ERRORMSG(1,(TEXT("For pADCregs: VirtualCopy failed!\r\n")));
PddpTouchPanelDeallocateVm();
return (FALSE);
}
}
}
if(v_pPWMregs == NULL) {
v_pPWMregs = (volatile PWMreg *)
VirtualAlloc(0,sizeof(PWMreg),MEM_RESERVE, PAGE_NOACCESS);
if(v_pPWMregs == NULL) {
ERRORMSG(1,(TEXT("For PWMreg: VirtualAlloc failed!\r\n")));
return (FALSE);
}
else {
if(!VirtualCopy((PVOID)v_pPWMregs,(PVOID)(PWM_BASE),sizeof(PWMreg),
PAGE_READWRITE | PAGE_NOCACHE )) {
ERRORMSG(1,(TEXT("For PWMreg: VirtualCopy failed!\r\n")));
return (FALSE);
}
}
}
if(v_pINTregs == NULL) {
v_pINTregs = (volatile INTreg *)
VirtualAlloc(0,sizeof(INTreg),MEM_RESERVE, PAGE_NOACCESS);
if(v_pINTregs == NULL) {
ERRORMSG(1,(TEXT("For INTreg: VirtualAlloc failed!\r\n")));
return (FALSE);
}
else {
if(!VirtualCopy((PVOID)v_pINTregs,(PVOID)(INT_BASE),sizeof(INTreg),
PAGE_READWRITE | PAGE_NOCACHE )) {
ERRORMSG(1,(TEXT("For INTreg: VirtualCopy failed!\r\n")));
return (FALSE);
}
}
}
if ( v_pDriverGlobals == NULL )
{
v_pDriverGlobals =
(PDRIVER_GLOBALS)
VirtualAlloc( 0,
DRIVER_GLOBALS_PHYSICAL_MEMORY_SIZE,
MEM_RESERVE,
PAGE_NOACCESS
);
if ( v_pDriverGlobals == NULL )
{
DEBUGMSG( ZONE_ERROR, (TEXT( "TouchPanelEnable: VirtualAlloc failed!\r\n")) );
PddpTouchPanelDeallocateVm();
return ( FALSE );
}
Ret = VirtualCopy( (LPVOID)v_pDriverGlobals,
(LPVOID)DRIVER_GLOBALS_PHYSICAL_MEMORY_START,
DRIVER_GLOBALS_PHYSICAL_MEMORY_SIZE,
PAGE_READWRITE | PAGE_NOCACHE
);
if ( Ret == FALSE )
{
DEBUGMSG( ZONE_ERROR, (TEXT( "TouchPanelEnable: VirtualCopy failed!\r\n")) );
PddpTouchPanelDeallocateVm();
return ( FALSE );
}
}
// Set up mutex for access to shared registers
if ((v_hTchAudMutex = CreateMutex(NULL, FALSE, TCHAUD_MUTEX_NAME)) == NULL) {
DEBUGMSG(ZONE_ERROR, (TEXT("TouchPanelEnable: Error %u in CreateMutex\r\n"),
GetLastError()));
return ( FALSE );
}
// Power on touch panel
TouchPanelPowerOn();