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