/* File: drvV1495.h * Author: Hovanes Egiyan, Jefferson Lab * Date: 27-Aug-2012 * * Purpose: * This module provides the driver support for the asyn device support layer * for the Coincidence Reference Design V1495 module. * * Acknowledgements: * This driver module is based on SIS38XX driver by Mark Rivers. * To understand the functions refer to CAEN Technical Manual * Mod. V1495 General Purpose VME Board Revision #13 07/16/12 * */ #ifndef _DRV_V1495CR_H_ #define _DRV_V1495CR_H_ /************/ /* Includes */ /************/ #include #include #include #include #include #include /* EPICS includes */ #include #include #include #include #include #include #include #include #include #include #include #include #include extern "C" { #include "jvme.h" } extern "C" { #include "v1495.h" #include "v1495_cr.h" } #include #include /***************/ /* Definitions */ /***************/ // General board-related parameters #define V1495CRGeoAddressString "V1495CR_GEO_ADDRESS" #define V1495CRResetModuleString "V1495CR_RESET_MODULE" #define V1495CRFirmwareString "V1495CR_FIRMWARE" #define V1495CRScratch16String "V1495CR_SCRATCH_16" #define V1495CRScratch32String "V1495CR_SCRATCH_32" // Coincidence Reference Design Parameters #define V1495CRStatusAString "V1495CR_STATUS_A" #define V1495CRStatusBString "V1495CR_STATUS_B" #define V1495CRStatusCString "V1495CR_STATUS_C" #define V1495CRMaskAString "V1495CR_MASK_A" #define V1495CRMaskBString "V1495CR_MASK_B" #define V1495CRMaskCString "V1495CR_MASK_C" #define V1495CRGateWidthString "V1495CR_GATE_WIDTH" #define V1495CRControlCString "V1495CR_C_CONTROL" #define V1495CRModeString "V1495CR_MODE" #define V1495CRScratchString "V1495CR_SCRATCH" #define V1495CRControlGString "V1495CR_G_CONTROL" #define V1495CRControlDString "V1495CR_D_CONTROL" #define V1495CRDataDString "V1495CR_D_DATA" #define V1495CRControlEString "V1495CR_E_CONTROL" #define V1495CRDataEString "V1495CR_E_DATA" #define V1495CRControlFString "V1495CR_F_CONTROL" #define V1495CRDataFString "V1495CR_F_DATA" #define V1495CRRevisionString "V1495CR_REVISION" #define V1495CRControlPDLString "V1495CR_PDL_CONTROL" #define V1495CRDataPDLString "V1495CR_PDL_DATA" #define V1495CRIDCodeDString "V1495CR_D_IDCODE" #define V1495CRIDCodeEString "V1495CR_E_IDCODE" #define V1495CRIDCodeFString "V1495CR_F_IDCODE" /* typedef enum { */ /* EventStartScaler, */ /* EventStartMCA, */ /* EventISR1, */ /* EventISR2, */ /* EventISR3, */ /* EventISR4 */ /* } V1495CREventType_t; */ // C-function with global scope that calls the member function void readRegisters( void *drvPvt ); class drvV1495CR : public asynPortDriver { public: // Constructor drvV1495CR( const char *portName, char* baseAddr ); // These are the methods we override from asynPortDriver virtual asynStatus writeUInt32Digital( asynUser *pasynUser, epicsUInt32 value, epicsUInt32 mask ); virtual asynStatus writeInt32 ( asynUser *pasynUser, epicsInt32 value); void report( FILE *fp, int details ); // Returns the base address value inline char* GetBaseAddress() const { return bAddr_; } // This is the main function for reading. It is executed // in a separate thread and fills the values. void readRegisters(); protected: #define FIRST_V1495CR_PARAM V1495CRGeoAddress_ int V1495CRGeoAddress_; int V1495CRResetModule_; int V1495CRFirmware_; int V1495CRScratch16_; int V1495CRScratch32_; # int V1495CRStatusA_; int V1495CRStatusB_; int V1495CRStatusC_; int V1495CRMaskA_; int V1495CRMaskB_; int V1495CRMaskC_; int V1495CRGateWidth_; int V1495CRControlC_; int V1495CRMode_; int V1495CRScratch_; int V1495CRControlG_; int V1495CRControlD_; int V1495CRDataD_; int V1495CRControlE_; int V1495CRDataE_; int V1495CRControlF_; int V1495CRDataF_; int V1495CRRevision_; int V1495CRControlPDL_; int V1495CRDataPDL_; int V1495CRIDCodeD_; int V1495CRIDCodeE_; int V1495CRIDCodeF_; #define LAST_V1495CR_PARAM V1495CRIDCodeF_ bool exists_; char* bAddr_; // V1495CREventType_t eventType_; epicsEventId eventId_; // epicsMutexId regsLockId_; }; #define NUM_V1495CR_PARAMS (&LAST_V1495CR_PARAM - &FIRST_V1495CR_PARAM + 1) /***********************/ /* Function prototypes */ /***********************/ /* External functions */ /* iocsh functions */ extern "C" { char* drvV1495CRConfig( const char *portName, int baseAddr ); epicsUInt16 drvV1495CRGetScratch( int baseAddress ); epicsUInt16 drvV1495CRSetScratch( int baseAddress, epicsUInt16 val ); } #endif