Rockwell Automation 6008-SV2R VMEbus remote I/O Scanner User Manual
Page 155
Chapter
Programming the Scanner
8
8Ć21
/*
**
** WAIT_FOR_IRQ() –– wait for scanner interrupt
**
**
This function waits for an interrupt from the 6008–SV2.
**
**
parameters:
timeout –– timeout interval in milliseconds
**
return value:
FALSE –– interrupt not received or error
**
TRUE –– interrupt received
**
*/
int
wait_for_cmdcmpl (channel far *chan)
{
short
res;
unsigned long
status;
unsigned short
masks[8] = { 0x0000, 0x0002, 0x0004, 0x0008,
0x0010, 0x0020, 0x0040, 0x0080 };
/* enable specified VMEbus interrupt */
EpcEnIntr(chan–>CmdCmplIrq);
/* wake up on the specified VMEbus interrupt */
res = EpcWaitIntr(masks[chan–>CmdCmplIrq], &status, chan–>TimeOut);
/* check result for timeout or error */
if ((res == 0) || (res == ERR_FAIL)) {
printf(”wait: no interrupt received (timeout)!\n”);
return FALSE;
}
/* check result for correct level */
if ((res & masks[chan–>CmdCmplIrq]) != masks[chan–>CmdCmplIrq]) {
printf(”wait: incorrect interrupt level received!\n”);
return FALSE;
}
/* check status for correct vector */
if ((status & 0x000000FF) != chan–>CmdCmplVec) {
printf(”wait: incorrect interrupt vector received\n”);
return FALSE;
}
return TRUE;
}