beautypg.com

Rockwell Automation 2711P Software Development Kit User Manual User Manual

Page 92

background image

Publication 2711P-UM005A-EN-P - March 2007

92 Device Drivers

if (INVALID_HANDLE_VALUE == (pDrvData->hEvent = CreateEvent(NULL,FALSE,FALSE,NULL)))

{

ERRORMSG(1,(TEXT("DRV_Init: CreateEvent call failed.\r\n")));

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Init-\r\n")));

DRV_Deinit((DWORD)pDrvData);

return (0);

}

//

// Now initialize the interrupt so that the kernel starts sending

// events for this IRQ

//

if (!InterruptInitialize(pDrvData->Gii.SysIntr,pDrvData->hEvent,NULL,0))

{

ERRORMSG(1,(TEXT("DRV_Init: InterruptInitialize call failed.\r\n")));

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Init-\r\n")));

DRV_Deinit((DWORD)pDrvData);

return (0);

}

//

// Create the IST thread.

//

if (INVALID_HANDLE_VALUE ==

(pDrvData->hThread = CreateThread(NULL,0,IstThreadProc,pDrvData,

0,&pDrvData->dwThreadId)))

{

ERRORMSG(1,(TEXT("DRV_Init: CreateThread() call failed.\r\n")));

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Init-\r\n")));

DRV_Deinit((DWORD)pDrvData);

return (0);

}

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Init-\r\n")));

return ((DWORD)pDrvData);

}

/////////////////////////////////////////////////////////////////////

//

// DRV_Deinit()

//

// Refer to Microsoft documentation on Device Driver Development for a

// detailed description of this function and its parameters

//

/////////////////////////////////////////////////////////////////////

BOOL

DRV_Deinit(

DWORD hDeviceContext

)

{

PDRV_DATA pDrvData = (PDRV_DATA)hDeviceContext;

DEBUGMSG(ZONE_FUNC, (TEXT("DRV_Deinit+\r\n")));