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

Page 150

Advertising
background image

Appendix A

Sample Applications

A-28

#include ”busmgr.h” // Radisys’s VME driver definitions
#include ”pccc.h” // Generic Allen-Bradley (AB) PCCC definitions
#include ”p40vger.h” // AB PCCC Get Edit Resource
#include ”p40vrer.h” // AB PCCC Return Edit Resource
#include ”p40vapc.h” // AB PCCC Apply Port Configuration
#include ”p40vwbp.h” // AB PCCC Write Bytes Physical
#include ”p40vihas.h” // AB PCCC Id Host and Status
#include ”p40vdla.h” // AB PCCC Download All
#include ”p40vdlc.h” // AB PCCC Download Complete
#include ”p40vscm.h” // AB PCCC Set CPU Mode

/***************************************************************************/
/************************* PRIVATE DEFINITIONS ****************************/
/***************************************************************************/
// PLC-5/40V is using 0x900000 for VME communications.
const unsigned long kvmeSlaveAddress = 0x900000L;

// PLC-5/40V is using ULA0 which is 0xFC00
const unsigned short kplc540vUla = 0xFC00;

// This is the number of bytes to be written to the PLC-5/40V.
const unsigned short kWriteSize = kPLC540V_PCCC_MAX_WBP_DATA;

/***************************************************************************/
/************************* PRIVATE TYPE DEFINITIONS ************************/
/***************************************************************************/
// The ”bucket” that we are using to writing the PLC data, address and length
// to the output file.
#pragma pack(1)
typedef struct
{

// The PLC memory address
unsigned long plcAddress;

// The number of bytes of PLC data in this packet.
unsigned short plcDataLength;

// The PLC data...
unsigned char plcData[kWriteSize];

}FILE_PACKET_TYPE;
#pragma pack()

/***************************************************************************/
/********************* PRIVATE FUNCTIONS DEFINITIONS ***********************/
/***************************************************************************/
void write_filepacket_to_plc(FILE_PACKET_TYPE *filePacket, UWORD writeCounter);
void download_is_complete(void);
void download_all(void);
void get_edit_resource(void);
void return_edit_resource(void);
void apply_port_configuration(void);
void plc_in_remote_program_mode(void);
void check_for_faults(void);

/***************************************************************************/
/******************************* MAINLINE **********************************/
/***************************************************************************/

Advertising