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

Page 163

Advertising
background image

Sample API Modules

Appendix B

B-5

/////////////////////////////////////////////////////////////////
// Common set of functions that are useful throughout the API...
/////////////////////////////////////////////////////////////////
void find_all_plc540v_in_VME( LOCATED_PLC540V_ARRAY_TYPE plcList,

PLC540V_STATUS_TYPE *status);

void read_plc540v_register( UWORD baseAddress,

PLC540V_REGISTER_TYPE targetRegister,
UWORD *registerValue,
PLC540V_STATUS_TYPE *status);

void write_plc540v_register( UWORD baseAddress,

PLC540V_REGISTER_TYPE targetRegister,
UWORD registerValue,
PLC540V_STATUS_TYPE *status);

void plc540v_self_tested_ok( UWORD baseAddress,

PLC540V_STATUS_TYPE *status);

void poll_plc540v_until_response(ULONG vmeCmdBlkAddr,

VME_ADDRESS_MODIFIER_TYPE addrSpace,
PLC540V_STATUS_TYPE *status);

void plc540v_send_cmd( ULONG baseAddress,

ULONG vmeCmdBlkAddr,
VME_ADDRESS_MODIFIER_TYPE addrSpace,
PLC540V_STATUS_TYPE *status);

void plc540v_enable_shared_memory(ULONG baseAddress,ULONG vmeSharedRAMAddr,

PLC540V_STATUS_TYPE *status);

void plc540v_disable_shared_memory(ULONG baseAddress,

ULONG vmeSharedRAMAddr,
PLC540V_STATUS_TYPE *status);

#endif

#include <mem.h>
#include ”epc_obm.h”
#include ”epc_err.h”
#include ”busmgr.h”
#include ”common.h”

/***************************************************************************/
/************************* PRIVATE DEFINITIONS ****************************/
/***************************************************************************/
/* The manufacturer id for our PLC-5/40V. */
#define kPLC540V_MANUFACTURE_ID 0x0CFEC

/* The device type for our PLC-5/40V. */
#define kPLC540V_DEVICE_TYPE 0x7FE8

/* Minimum and Maximum base addresses for the PLC-5/40V’s */
#define kPLC540V_MINIMUM_BASE_ADDRESS 0xFC00
#define kPLC540V_MAXIMUM_BASE_ADDRESS 0xFDC0

/* The size (in kBytes) of the global memory on the PLC-5/40V. */
#define kPLC540V_GLOBAL_MEMORY_SIZE 0x0040

/* The PLC-5/40V status bits */
#define kPLC540V_READY 0x0008
#define kPLC540V_PASSED 0x0004

/* Timeout value for waiting for the PLC-5/40V to complete a command. */
#define kTIMEOUT_COUNT 16384

/* Mask for the command control register’s write ready bit. */
#define kCMDCTRL_WRDY 0x8000

COMMON.C

Advertising