CAENcard_767.h

Go to the documentation of this file.
00001 /*
00002     This software is Copyright by the Board of Trustees of Michigan
00003     State University (c) Copyright 2005.
00004 
00005     You may use this software under the terms of the GNU public license
00006     (GPL).  The terms of this license are described at:
00007 
00008      http://www.gnu.org/licenses/gpl.txt
00009 
00010      Author:
00011              Ron Fox
00012              NSCL
00013              Michigan State University
00014              East Lansing, MI 48824-1321
00015 */
00016 
00017 #ifndef CAENCARD_767_H
00018 #define CAENCARD_767_H
00019 
00020 #include <stdio.h>
00021 #include <sys/types.h>
00022 #include <sys/stat.h>
00023 #include <sys/mman.h>
00024 #include <errno.h>
00025 #include <fcntl.h>
00026 #include <unistd.h>
00027 #include <signal.h>
00028 #include <sys/ioctl.h>
00029 #include <VmeModule.h>
00030 
00031 
00032 #ifndef SPECTRODAQ_H
00033 
00034 #ifdef HAVE_STD_NAMESPACE
00035 using namespace std;
00036 #endif
00037 
00038 #include <spectrodaq.h>
00039 #endif
00040 
00041 //the number of cards in a VME crate
00042 #define VME_CRATE_SIZE   21
00043 
00044 //define the operating modes of the card object
00045 #define CAEN_MODE_UNINIT 0
00046 #define CAEN_MODE_GEO24  1
00047 #define CAEN_MODE_A32D16 2
00048 #define CAEN_MODE_MCST   4
00049 #define CAEN_MODE_CBLT   8
00050 
00051 //define the address spaces used to access the board.
00052 
00053 #define CAEN_GEO24       CVmeModule::geo
00054 #define CAEN_A32D16      CVmeModule::a32d32 /* No real distinction with d16. */
00055 
00056 
00057 //will be used to create a memory map for the card
00058 #define CAEN_767_CARD_MMAP_LEN 0x00002000
00059 
00060 //Constants used to determine the type of data being returned from the card
00061 #define CAEN_767_DATUM_TYPE    0x00600000
00062 #define CAEN_767_HEADER        0x00400000
00063 #define CAEN_767_DATA          0x00000000
00064 #define CAEN_767_FOOTER        0x00200000
00065 #define CAEN_767_INVALID       0x00600000
00066 
00067 //offsets (assuming short int units) for various registers
00068 #define CAEN_767_ADDR_GEO      0x0002
00069 #define CAEN_767_BIT_SET       0x0003
00070 #define CAEN_767_BIT_CLEAR     0x0004
00071 #define CAEN_767_INTERRUPT_LEVEL  0x0005
00072 #define CAEN_767_INTERRUPT_VECTOR 0x0006
00073 #define CAEN_767_STATUS_1      0x0007
00074 #define CAEN_767_CONTROL_1     0x0008
00075 #define CAEN_767_ADDR_32       0x0009
00076 #define CAEN_767_ADDR_24       0x000A
00077 #define CAEN_767_MCST_ADDR     0x000B
00078 #define CAEN_767_SS_RESET      0x000C
00079 #define CAEN_767_MCST_CONTROL  0x0010
00080 
00081 #define CAEN_767_STATUS_2      0x0024
00082 #define CAEN_767_CONTROL_2     0x0025
00083 #define CAEN_767_EVENT_COUNTER 0x0026
00084 #define CAEN_767_CLEAR_COUNTER 0x0027
00085 #define CAEN_767_OPCODE_STATUS 0x0028
00086 #define CAEN_767_OPCODE        0x0029
00087 #define CAEN_767_CLEAR         0x002A
00088 #define CAEN_767_TESTWORD_HIGH 0x002B
00089 #define CAEN_767_TESTWORD_LOW  0x002C
00090 #define CAEN_767_SOFT_TRIGGER  0x002D
00091 
00092 #define CAEN_767_MANUFACT_ID   0x0813
00093 #define CAEN_767_BOARD_ID      0x0819
00094 #define CAEN_767_REVISION_ID   0x0827
00095 
00096 // Bits in the edge info data:
00097 
00098 #define CAEN_767_EDGE_RISING   0x0001
00099 #define CAEN_767_EDGE_FALLING  0x0002
00100 #define CAEN_767_EDGE_BOTH     (CAEN_767_EDGE_RISING | CAEN_767_EDGE_FALLING)
00101 
00102 
00120 class CAENcard_767 {
00121 
00122 private:
00123   int slot;
00124   CVmeModule  *m_pSpace;
00125 
00126 
00127 /*************************begin public section*********************************/
00128 public:
00129   // Constructors and other canonical operations.
00130   
00131   CAENcard_767(int slotNum, int crateNum = 0,
00132                bool fisGeo = true, unsigned long nBase=0);
00133   CAENcard_767(const CAENcard_767& card);
00134   CAENcard_767& operator=(const CAENcard_767& card);
00135   ~CAENcard_767();
00136   
00137   
00138   int cardType();               
00139   int mfgId();                  
00140   void clearData();             
00141   int dataPresent();            
00142   
00143   
00144   int readEvent(void* buf);     
00145   int readEvent(DAQWordBuffer& wbuf, int offset); 
00146   int readEvent(DAQWordBufferPtr& wp); 
00147   int readEvent(DAQDWordBuffer& dwbuf, int offset); 
00148   int readEvent(DAQDWordBufferPtr& dwp); 
00149   
00150   int tempSetup();              
00151 
00152 
00153   int SetRisingEdgeStart() ;
00154   int SetFallingEdgeStart(); 
00155   int SetRisingEdgeAll();
00156   int SetFallingEdgeAll();
00157 
00158   int getStartEdge();           
00159   int getEdgeOdd();             
00160   int getEdgeEven();            
00161   unsigned short getSr2();
00162   // Utilities:
00163 
00164 protected:
00165   int slotInit(int slotNum, int crateNum,
00166                bool fGeo, unsigned long base); 
00167   int readEdgeConfiguration(unsigned short* values);
00168   int readOpcode(unsigned short int *value, int maxRetry); 
00169   int writeOpcode(unsigned short int value, int maxRetry); 
00170   int opcodeWait(int maxRetry);           
00171   void reset();                     
00172 };
00173 
00174 #endif

Generated on Wed Sep 17 08:38:09 2008 for NSCL Device support. by  doxygen 1.5.1