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

Page 200

Advertising
background image

Sample API Modules

Appendix B

B-42

/* Let’s initialize the send PCCC command block to be empty. */
memset((char *) &pcccCmdBlk, 0x0, sizeof(PLC540V_SPCCC_CMD_TYPE));

/* Let’s initialize the send PCCC reply packet to be empty. */
memset((char *) pcccReplyPacket, 0x0, pcccReplyPacketSize);

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

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

BM_W8,
(char far *) pcccCommandPacket,
vmeCommandPacketAddr,
pcccCommandPacketSize);

if (status->epcStatus == EPC_SUCCESS)
{

/* Build the command block. */
pcccCmdBlk.commandWord = kPLC540V_SEND_PCCC;
pcccCmdBlk.responseWord = 0;
pcccCmdBlk.cmdIntLevel = cmdIntLevel;
pcccCmdBlk.cmdStatusId = cmdStatusId;
pcccCmdBlk.transferInfo.addressModifier = addrMod;
pcccCmdBlk.transferInfo.width = width;
pcccCmdBlk.packetAddressHigh = HIWORD(vmeCommandPacketAddr);
pcccCmdBlk.packetAddressLow = LOWORD(vmeCommandPacketAddr);
pcccCmdBlk.packetSize = pcccCommandPacketSize;

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

BM_W16,
(char far *) &pcccCmdBlk,
vmeCmdBlkAddr,
sizeof(PLC540V_SPCCC_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);

if (status->plc540vStatus == kPLC540V_SUCCESS)
{

/* If sending the command block address didn’t fail, then the
PLC-5/40V has started processing the command.

If the user of this function hasn’t set up any VME interrupts
to be generated, then we will poll the PLC-5/40V until the
its done processing the command. This is indicated by a
non-zero value in the response word of the command block.

If the user has set up VME interrupts, then we will simply
continue by retrieving the PCCC reply packet.
*/
if (cmdIntLevel == kVME_NO_INT_LEVEL)
{
/* Let’s poll the PLC-5/40V until its done. */
poll_plc540v_until_response(vmeCmdBlkAddr,

kVME_A24_ADDR_SPACE,
status);

}

Advertising