Setup command – Rockwell Automation 6008-SV2R VMEbus remote I/O Scanner User Manual
Page 137
Chapter
Programming the Scanner
8
8Ć3
SETUP command
/*
**
** SETUP() –– set up a 6008–SV2 channel
**
**
This function executes a SETUP command, using the parameters provided by the caller
**
in the setup_data structure.
**
**
parameters:
pointer to channel structure
**
pointer to setup_data structure
**
return values:
–1
= unable to lock general data area semaphore
**
–2
= did not get cmd–complete interrupt
**
ELSE
channel confirmation status word
**
**
NOTE: this routine overwrites the channel structure CmdCmplIrq & CmdCmplVec fields
**
with the interrupt level and vector contained in the setup_param structure.
**
*/
int
setup (channel far *chan, setup_data far *setup_param)
{
csa_data far
*csa;
unsigned short far
*vid;
unsigned short
setup_len;
unsigned short
res;
/* update the command complete interrupt settings */
chan–>CmdCmplIrq
=
(unsigned short)
setup_param–>cmdcmpl_irq_level;
chan–>CmdCmplVec
=
(unsigned short)
setup_param–>cmdcmpl_irq_vector;
/* map the channel & establish pointers */
map_channel(chan);
csa
= (csa_data far *) chan–>ControlStatusArea;
vid
= (unsigned short far *) chan–>VmeIdArea;
/* determine length of setup data */
setup_len = (unsigned short)
((chan–>ScannerMode == MODE_COMPATIBLE) ? SVC_SETUP_SIZE :
SVS_SETUP_SIZE);
/* get the semaphore */
if (lock_gda(chan) != 0) {
fprintf(stdout, ”setup: lock aquire FAILED\n”);
unmap_channel(chan);
return –1;
}
/* set up the control/status area */
csa–>cnfstat = 0x000F;
/* confirmation status word */
csa–>cmd
= CMD_SETUP;
/* command word */
csa–>datalen = setup_len;
/* length of data word */
/* copy the setup parameters */
blockcpy(chan–>GeneralDataArea, setup_param, (size_t) setup_len);