8ć13, Bt write / bt read – Rockwell Automation 6008-SV2R VMEbus remote I/O Scanner User Manual
Page 147
Chapter
Programming the Scanner
8
8Ć13
BT WRITE / BT READ
/*
**
** QUEUE_ONESHOT_BT() –– queue a one–shot block transfer read or write
**
**
This function is driven by the data contained in the bt_data structured provided by
**
the caller. The command word (OSBTW/OSBTR), BT address word, tag word, and
**
BT transfer length word are placed in the Control/Status Area. If the command is a
**
OSBTW, then data is copied from the bt_data struct’s data buffer to the channel’s
**
General Data Area. The command is then asserted and its results returned to
**
the caller.
**
**
parameters:
pointer to channel structure
**
pointer to the bt_data structure
**
return values:
–1
= unable to lock general data area semaphore
**
–2
= did not get cmd–complete interrupt
**
ELSE
channel confirmation status word
**
*/
int
queue_oneshot_bt (channel far *chan, bt_data far *block)
{
csa_data far
*csa;
unsigned short far
*gda;
unsigned short
res;
unsigned short
i;
/* map channel & establish pointers */
map_channel(chan);
csa = (csa_data far *) chan–>ControlStatusArea;
gda = (unsigned short far *) chan–>GeneralDataArea;
/* get the semaphore */
if (lock_gda(chan) != 0) {
unmap_channel(chan);
fprintf(stdout, ”osbtwrite: lock aquire FAILED\n”);
return –1;
}
/* set up the control/status area */
csa–>cnfstat = 0x000F;
/* confirmation status word */
csa–>cmd
= block–>cmd;
/* command word */
csa–>addr
= block–>addr;
/* address word */
csa–>tag
= block–>tag;
/* tag word */
csa–>datalen = block–>datalen;
/* length of data word */
/* if a BT write */
if (block–>cmd == CMD_OSBTWRITE) {
/* copy the block data */
for (i = 0; i < block–>datalen; i++) {
gda[i] = block–>data[i];
}
}