Appendix b – Rockwell Automation 1785-Vx0B, D17856.5.9 PLC-5 VME VMEbus Programmable Controllers User Manual User Manual

Page 187

Advertising
background image

Sample API Modules

Appendix B

B-29

static void plc540v_cont_copy(PLC540V_CONT_COPY_COMMAND ccCmd,

PLC540V_CONT_COPY_MODE ccMode,
ULONG vmeDataAddr,
UWORD vmeDataSize,
ULONG vmeCmdBlkAddr,
UWORD baseAddress,
VME_DATA_WIDTH_TYPE width,
VME_ADDRESS_MODIFIER_TYPE addrMod,
UWORD fileNumber,
UWORD elementNumber,
VME_INTERRUPT_LEVEL_TYPE cmdIntLevel,
UBYTE cmdStatusId,
VME_INTERRUPT_LEVEL_TYPE operationIntLevel,
UBYTE operationStatusId,
PLC540V_STATUS_TYPE *status)

{
/* The continuous copy command block. */
static PLC540V_CONT_COPY_CMD_TYPE ccCmdBlk;

/* The continuous copy to VME buffer. */
static UBYTE toVMEBuf[kPLC540V_MAX_TRANSFER_SIZE];

/* Let’s initialize the continuous copy command block to be empty. */
memset((char *) &ccCmdBlk, 0x0, sizeof(PLC540V_CONT_COPY_CMD_TYPE));

/* Let’s initialize the continuous copy to VME buffer. */
memset((char *) &toVMEBuf, 0x0, kPLC540V_MAX_TRANSFER_SIZE);

/* Let’s initialize the status variable to success. */
memset((char *) status, 0x0, sizeof(PLC540V_STATUS_TYPE));

/* Build the command block. */
ccCmdBlk.commandWord = ccCmd;
ccCmdBlk.responseWord = 0;
ccCmdBlk.cmdIntLevel = cmdIntLevel;
ccCmdBlk.cmdStatusId = cmdStatusId;
ccCmdBlk.transferInfo.addressModifier = addrMod;
ccCmdBlk.transferInfo.width = width;
ccCmdBlk.transferInfo.enable = ccMode;
ccCmdBlk.dataAddressHigh = HIWORD(vmeDataAddr);
ccCmdBlk.dataAddressLow = LOWORD(vmeDataAddr);
ccCmdBlk.dataSize = vmeDataSize;
ccCmdBlk.fileNumber = fileNumber;
ccCmdBlk.elementNumber = elementNumber;
ccCmdBlk.operationIntLevel = operationIntLevel;
ccCmdBlk.operationStatusId = operationStatusId;

/* Copy the command block to VME memory. */
status–>epcStatus = EpcToVmeAm((BM_MBO|A24SD),

BM_W16,
(char far *) &ccCmdBlk,
vmeCmdBlkAddr,
sizeof(PLC540V_CONT_COPY_CMD_TYPE));

if (status–>epcStatus == EPC_SUCCESS)
{

/* Send the command block address to the PLC–5/40V’s command
register.
*/
plc540v_send_cmd(baseAddress, vmeCmdBlkAddr, kVME_A24_ADDR_SPACE,

status);

Advertising