00001
00002
00003 #ifndef SCTPIXELROD_TIMMODULE_H
00004 #define SCTPIXELROD_TIMMODULE_H
00005
00049 #include "TimDefine.h"
00050 #include "processor.h"
00051 #include "VmeInterface.h"
00052 #include "VmePort.h"
00053 #include "VmeModule.h"
00054 #include "BaseException.h"
00055
00056 namespace SctPixelRod {
00057
00058
00059
00061
00067 class TimException : public BaseException {
00068
00069 public:
00070
00071 TimException( std::string descriptor, int data1, int data2 );
00072 int getData1() { return m_data1; };
00073 int getData2() { return m_data2; };
00074 virtual void what( std::ostream & );
00075
00076 private:
00077
00078 int m_data1;
00079 int m_data2;
00080 };
00081
00082
00083
00085
00092 class TimModule : public VmeModule {
00093
00094 public:
00095
00096
00097
00098
00099 TimModule( UINT32 baseAddr, UINT32 mapSize, VmeInterface & ourInterface );
00100
00101 virtual ~TimModule();
00102
00103
00104
00105 UINT32 getFirmware() { return m_firmware; };
00106 UINT32 getSerialNumber() { return m_serialNumber; };
00107 VmePort* getVmePort() { return m_vmePort; };
00108
00109
00110
00111 void initialize();
00112 void reset() throw (TimException &);
00113 void status();
00114
00115 UINT32 fetchL1ID();
00116 UINT16 fetchTimID();
00117
00118 void intTrigStart( const double frequency );
00119 void intTrigStart( const TimMaskFrequency frequency );
00120 void intTrigStop();
00121
00122 void issueCommand( const TimBitCommand mask );
00123 void issueVCAL( const UINT8 pipelineDelay );
00124
00125 void loadBitClear( const TimRegister addr, const UINT16 mask );
00126 void loadBitSet( const TimRegister addr, const UINT16 mask );
00127 void loadByteHi( const TimRegister addr, const UINT8 byte );
00128 void loadByteLo( const TimRegister addr, const UINT8 byte );
00129 void loadFrequencyFECR( const double frequency );
00130 void loadFrequencyTrig( const double frequency );
00131
00132 void msleep( const double milliSecs );
00133
00134 UINT16 regFetch( const TimRegister addr );
00136
00137 void regLoad( const TimRegister addr, const UINT16 data );
00139 int regTimeout( const TimRegister addr, const int mask1, const int mask2,
00140 const int timeout );
00141
00142 void seqFetch( const UINT16 size, UINT16 buffer[] );
00143 void seqLoad( const UINT16 size, const UINT16 buffer[] );
00144 void seqRun( const UINT16 size );
00145
00146 void setupTTC();
00147 void setupVME();
00148
00149 void statusPrint( std::ostream& os );
00150
00151 UINT16 vmeFetch( const UINT32 addr )
00152 throw (VmeException &);
00153
00154 void vmeLoad( const UINT32 addr, const UINT16 data )
00155 throw (VmeException &);
00156
00157 private:
00158
00159 UINT32 m_firmware;
00160 UINT32 m_serialNumber;
00161 VmePort* m_vmePort;
00162
00163 };
00164
00165 }
00166
00167
00168
00170
00171 namespace std {
00172
00173 ostream& operator<<( ostream& os, SctPixelRod::TimModule& tim );
00174
00175 }
00176
00177 #endif // SCTPIXELROD_TIMMODULE_H