Rockwell Automation 2711P Software Development Kit User Manual User Manual
Page 93
Publication 2711P-UM005A-EN-P - March 2007
Device Drivers 93
//
// If the pointer is invalid, just return
//
if (0 == hDeviceContext)
{
DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Deinit-\r\n")));
return (FALSE);
}
//
// If the SYSINTR value is still valid
// disable the IST connection
//
if (0 != pDrvData->Gii.SysIntr)
{
InterruptDisable(pDrvData->Gii.SysIntr);
pDrvData->Gii.SysIntr = 0;
}
#if defined(DRV_USE_ISR)
//
// Free the chain handler
//
// WARNING: this may not unload the actual DLL
// refer to Microsoft documentation on chain handlers
//
if (INVALID_HANDLE_VALUE != pDrvData->hIsrHandler)
{
FreeIntChainHandler(pDrvData->hIsrHandler);
pDrvData->hIsrHandler = INVALID_HANDLE_VALUE;
}
#endif // defined(DRV_USE_ISR)
//
// If the Thread is assumed to still be running,
// try and stop it nicely,
// or terminate it if it is possible.
//
if (INVALID_HANDLE_VALUE != pDrvData->hThread)
{
pDrvData->bExitThread = TRUE;
if (INVALID_HANDLE_VALUE != pDrvData->hEvent)
SetEvent(pDrvData->hEvent);
if (WAIT_OBJECT_0 != WaitForSingleObject(pDrvData->hThread,1000))
TerminateThread(pDrvData->hThread,0);
CloseHandle(pDrvData->hThread);
pDrvData->hThread = INVALID_HANDLE_VALUE;
}
//
// close the event handle
//
if (INVALID_HANDLE_VALUE != pDrvData->hEvent)
{
CloseHandle(pDrvData->hEvent);