sis3300.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 
00018 #ifndef __SIS3300_H
00019 #define __SIS3300_H
00020 
00021 #ifndef __SPECTRODAQ_H
00022 #include <spectrodaq.h>
00023 #define __SPECTRODAQ_H
00024 #endif
00025 
00026 
00027 #ifndef __STL_STRING
00028 #include <string>
00029 #define __STL_STRING
00030 #endif
00031 
00055 class CSIS3300 {
00056 public:
00057   typedef enum _ClockSource {
00058     Internal100Mhz = 0,
00059     Internal50Mhz  = 1,
00060     Internal25Mhz  = 2,
00061     Internal12_5Mhz= 3,
00062     Internal6_25Mhz= 4,
00063     Internal3_125Mhz=5,
00064     ExternalFp      =6,
00065     ExternalP2      =7 
00066   } ClockSource;                
00067   typedef enum _SampleSize {
00068     Sample128K     = 0,
00069     Sample16K      = 1,
00070     Sample4K       = 2,
00071     Sample2K       = 3,
00072     Sample1K       = 4,
00073     Sample512      = 5,
00074     Sample256      = 6,
00075     Sample128      = 7,
00076   } SampleSize; 
00077 
00078 private:
00079   unsigned long           m_nBase;            
00080   // Register pointers:
00081   volatile unsigned long* m_pCsrs;            
00082   volatile unsigned long* m_pEi1;             
00083   volatile unsigned long* m_pEi2;              
00084   volatile unsigned long* m_pEi3;             
00085   volatile unsigned long* m_pEi4;             
00086 
00087   volatile unsigned long* m_pModuleId;        
00088   volatile unsigned long* m_pCsr;             
00089   volatile unsigned long* m_pAcqReg;         
00090   volatile unsigned long* m_pResetKey;        
00091   volatile unsigned long* m_pStart;           
00092   volatile unsigned long* m_pStop;            
00093   volatile unsigned long* m_pEventConfig;    
00094   volatile unsigned long* m_pStartDelay;        
00095   volatile unsigned long* m_pStopDelay;       
00096   volatile unsigned long* m_pAddressReg1; 
00097   volatile unsigned long* m_pAddressReg2; 
00098   volatile unsigned long* m_pAddressReg3; 
00099   volatile unsigned long* m_pAddressReg4; 
00100   volatile unsigned long* m_pEventDirectory1;   
00101   volatile unsigned long* m_pEventDirectory2;   
00102   volatile unsigned long* m_pEventDirectory3;   
00103   volatile unsigned long* m_pEventDirectory4;   
00104   volatile unsigned long* m_pBank1Buffers[4];   
00105   volatile unsigned long* m_pThresholds[4]; 
00106 
00107   // State which determines how the module is set up:
00108  
00109   void*         m_nFd;          
00110   ClockSource m_eClock;             
00111   bool        m_fStartDelayEnabled; 
00112   unsigned int m_nStartDelayClocks; 
00113   bool        m_fStopDelayEnabled;  
00114   unsigned int m_nStopDelayClocks;
00115 
00116   bool       m_fGateMode;        
00117   bool       m_fRandomClock;     
00118   bool       m_fLemoStartStop;
00119   bool       m_fP2StartStop;
00120 
00121   bool       m_fHiRA_RCM;        
00122   bool       m_fStopTrigger;    
00123   SampleSize m_ePagesize;       
00124   unsigned int m_nPagesize;     
00125   bool       m_fPageWrap;       
00126   bool       m_fThresholdLt[8]; 
00127   unsigned int m_nThresholds[8];        
00128 
00129 
00130 
00131 
00132 
00133 public:
00134   // Constructors and other canonical member functions:
00135 
00136   CSIS3300(unsigned long nBaseAddress,
00137            unsigned int nCrate = 0);
00138 private:
00139   CSIS3300(const CSIS3300& rhs);
00140   CSIS3300& operator=(const CSIS3300& rhs);
00141   int      operator==(const CSIS3300& rhs);
00142 public:
00143   ~CSIS3300();
00144 
00145   // Selectors:
00146 public:
00147   unsigned long getBaseAddress() const {
00148     return m_nBase;
00149   }
00150   unsigned long getPageSize() const {
00151     return m_nPagesize;
00152   }
00153 
00154   volatile unsigned long* getAddressRegister1() {
00155     return m_pAddressReg1;
00156   }
00157    volatile unsigned long* getAddressRegister2() {
00158     return m_pAddressReg2;
00159   }
00160   volatile unsigned long* getAddressRegister3() {
00161     return m_pAddressReg3;
00162   }
00163   volatile unsigned long* getAddressRegister4() {
00164     return m_pAddressReg4;
00165   }
00172   volatile unsigned long* getModuleBase() { 
00173     return m_pCsrs;
00174   }
00181   volatile unsigned long* getCsr() {
00182     return m_pCsr;
00183   }
00185   unsigned long getStatusRegister() const {  
00186     return *m_pCsrs;
00187   }
00189   void setControlRegister(unsigned long value) {
00190     *m_pCsrs = value;
00191   }
00198   volatile const unsigned long* getModuleId() const{
00199     return m_pModuleId;
00200   }
00202   unsigned int getModelNumber() const {
00203     return (*m_pModuleId >> 16) & 0xffff;
00204   }
00206   unsigned int getFirmwareMajor() const {
00207     return (*m_pModuleId >> 8) & 0xff;
00208   }
00210   unsigned int getFirmwareMinor() const {
00211     return (*m_pModuleId) & 0xff;
00212   }
00213 
00215   volatile const unsigned long* getAcquisitionRegister() const {
00216     return m_pAcqReg;
00217   }
00221   volatile unsigned long* getResetKeyRegister() {
00222     return m_pResetKey;
00223   }
00224   volatile unsigned long* getStartKeyRegister() {
00225     return m_pStart;
00226   }
00227   volatile unsigned long* getEventConfigRegister() {
00228     return m_pEventConfig;
00229   }
00230   volatile unsigned long* getStartDelayRegister() {
00231     return m_pStartDelay;
00232   }
00233   volatile unsigned long* getStopDelayRegister() {
00234     return m_pStopDelay;
00235   }
00236   volatile unsigned long* getEventDirectory1() {
00237     return m_pEventDirectory1;
00238   }
00239 
00240   volatile unsigned long* getEventDirectory2() {
00241     return m_pEventDirectory2;
00242   }
00243   volatile unsigned long* getEventDirectory3() {
00244     return m_pEventDirectory3;
00245   }
00246   volatile unsigned long* getEventDirectory4() {
00247     return m_pEventDirectory4;
00248   }
00249   void* getFd() {
00250     return m_nFd;
00251   }
00252   // These functions really only make sense inside the class body.
00253   // they return VME addresses not process virtual addresses.
00254 private:
00255   volatile unsigned long getGroup1Address() {
00256     return getBaseAddress() + 0x400000;
00257   }
00258   volatile unsigned long getGroup2Address() {
00259     return getBaseAddress() + 0x480000;
00260   }
00261   volatile unsigned long getGroup3Address() {
00262     return getBaseAddress() + 0x500000;
00263   }
00264   volatile unsigned long getGroup4Address() {
00265     return getBaseAddress()+0x580000;
00266   }
00267 public:
00268 
00269   // Configuration functions:
00270  
00271   void Reset();                 
00272   void SetClock(ClockSource eSource);
00273   void SetStartDelay(bool Enable = false, unsigned int nClocks = 0);
00274   void SetStopDelay(bool Enable  = false, unsigned int nClocks = 0);
00275   void GateMode(bool Enable = false);
00276   void RandomClock(bool Enable = false);
00277   void LemoStartStop(bool Enable = false);
00278   void P2StartStop(bool   Enable = false);
00279   void HiRA_RCM(bool Enable = false);
00280   void TriggerOnStop(bool Enable=true);
00281   void SetSampleSize(SampleSize eSamples);
00282   void EnableWrap(bool Enable=true);
00283   unsigned int GetUserInput();
00284 
00285   void SetThresholds(bool* pLessThan,
00286                      unsigned int* pValues);
00287 
00288   // Configuration inquiry functions.
00289 
00290   CSIS3300::ClockSource  getCurrentClockSource();
00291   bool         isStartDelayEnabled();
00292   unsigned int getStartDelayClocks();
00293   bool         isStopDelayEnabled();
00294   unsigned int getStopDelayClocks();
00295   unsigned int getThresholdValue(unsigned int channel) const {
00296     return m_nThresholds[channel];
00297   }
00298   bool         isLtThreshold(unsigned int channel) const {
00299     return m_fThresholdLt[channel];
00300   }
00301   bool haveHiRAFirmware() const;
00302 
00303 
00304   //  Data taking functions. 
00305 public:
00306   void LightOn();
00307   void LightOff();
00308   void InitDaq();
00309   void Arm1();
00310   void Arm2();
00311   void DisArm1();
00312   void DisArm2();
00313   void StartSampling();
00314   void StopSampling();
00315   void EnableUserOut();
00316   void DisableUserOut();
00317   void StrobeUserOut(int time);
00318   bool WaitUntilDone(int timeout);
00319   unsigned long EventNumber(int bank);
00320 
00321   // New members to do I/O to ordinary buffers.
00322 
00323   unsigned int ReadGroup1(void* pBuffer);
00324   unsigned int ReadGroup2(void* pBuffer);
00325   unsigned int ReadGroup3(void* pBuffer);
00326   unsigned int ReadGroup4(void* pBuffer);
00327   unsigned int ReadAllGroups(void * pBuffer);
00328   //
00329   // Old style read to spectrodaq buffers.
00330   //
00331   unsigned int ReadGroup1(DAQWordBufferPtr& pBuffer);
00332   unsigned int ReadGroup2(DAQWordBufferPtr& pBuffer);
00333   unsigned int ReadGroup3(DAQWordBufferPtr& pBuffer);
00334   unsigned int ReadGroup4(DAQWordBufferPtr& pBuffer);
00335   unsigned int ReadAllGroups(DAQWordBufferPtr& pBuffer);
00336 
00337   void ClearDaq();
00338 protected:
00339   unsigned int ReadAGroup(DAQWordBufferPtr& pBuffer,
00340                           volatile unsigned long* pAddressReg1,
00341                           unsigned long pBase);
00342  
00344   //
00345   unsigned int ReadAGroup(void* pbuffer,
00346                           volatile unsigned long* pAddressReg1,
00347                           unsigned long           pBase);
00348 };
00349 
00350 
00351 
00352 #endif

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