Library of Bus-Adapters
|
00001 #ifndef __CAENLinuxBusAdapter 00002 #define __CAENLinuxBusAdapter 00003 00004 #include <semaphore.h> 00005 #include <vector> 00006 #include <ostream> 00007 #include "CAENVMEtypes.h" 00008 #include "hal/IllegalValueException.hh" 00009 #include "hal/BusAdapterException.hh" 00010 #include "hal/UnsupportedException.hh" 00011 #include "hal/VMEBusAdapterInterface.hh" 00012 #include "hal/VMEAddressTable.hh" 00013 #include "hal/DeviceIdentifier.hh" 00014 #include "hal/CAENDeviceIdentifier.hh" 00015 00016 namespace HAL { 00017 00047 class CAENLinuxBusAdapter : public VMEBusAdapterInterface { 00048 public: 00049 00053 enum CAENModel{ V1718, V2718 }; 00054 enum CAENPCCard{ A2818, A3818 }; 00055 00079 CAENLinuxBusAdapter( CAENModel model, int unit = 0, int chain = 0, CAENPCCard pcCard = A2818 ) 00080 throw( BusAdapterException ); 00081 00082 virtual ~CAENLinuxBusAdapter() throw( BusAdapterException ); 00083 00091 void openDevice(const VMEAddressTable& VMEAddressTable, 00092 uint32_t vmeBaseaddress, 00093 DeviceIdentifier** deviceIdentifierPtr, 00094 uint32_t* baseAddressPtr, 00095 bool doSwapping) 00096 throw(BusAdapterException); 00097 00105 void openDevice(const VMEAddressTable& VMEAddressTable, 00106 std::vector<uint32_t> vmeBaseaddresses, 00107 DeviceIdentifier** deviceIdentifierPtr, 00108 std::vector<uint32_t>* baseAddressesPtr, 00109 bool doSwapping) 00110 throw(BusAdapterException); 00111 00115 void closeDevice( DeviceIdentifier* deviceIdentifier ) 00116 throw(); 00117 00118 void write( DeviceIdentifier* vmeDevice, 00119 uint32_t address, 00120 uint32_t addressModifier, 00121 uint32_t dataWidth, 00122 uint32_t data) 00123 throw( BusAdapterException ); 00124 00125 void read( DeviceIdentifier* vmeDevice, 00126 uint32_t address, 00127 uint32_t addressModifier, 00128 uint32_t dataWidth, 00129 uint32_t* result) 00130 throw( BusAdapterException ); 00131 00132 void writeBlock( DeviceIdentifier* deviceIdentifierPtr, 00133 uint32_t startAddress, 00134 uint32_t length, // in bytes 00135 uint32_t addressModifier, 00136 uint32_t dataWidth, 00137 char *buffer, 00138 HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT ) 00139 throw( BusAdapterException, UnsupportedException ); 00140 00141 void readBlock( DeviceIdentifier* deviceIdentifierPtr, 00142 uint32_t startAddress, 00143 uint32_t length, // in bytes 00144 uint32_t addressModifier, 00145 uint32_t dataWidth, 00146 char *buffer, 00147 HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT ) 00148 throw( BusAdapterException, UnsupportedException ); 00149 00153 void resetBus( ) 00154 throw( BusAdapterException ); 00155 00160 void readDisplay( std::ostream& os ) const 00161 throw( BusAdapterException ); 00162 00167 void readVersions( std::ostream& os ) const; 00168 00173 void enableIRQ( uint32_t mask ) const 00174 throw( BusAdapterException ); 00175 00180 void disableIRQ( uint32_t mask ) const 00181 throw( BusAdapterException ); 00182 00188 uint32_t checkIRQ( ) const 00189 throw( BusAdapterException ); 00190 00199 uint32_t waitIRQ( uint32_t mask, uint32_t timeoutMs ) const 00200 throw( BusAdapterException ); 00201 00205 void acknowledgeIRQ( uint32_t level, void* vector, uint32_t width ) const 00206 throw( BusAdapterException ); 00207 00208 private: 00209 00210 static int32_t handleVX718_[8][8]; 00211 static int32_t handleVX718UseCount_[8][8]; 00212 static sem_t * handleSemaphore_; 00213 int unit_; 00214 int chain_; 00215 char V1718FwRelease_[256]; 00216 char V2718FwRelease_[256]; 00217 char AX818FwRelease_[256]; 00218 char A2719FwRelease_[256]; 00219 char VMELibRelease_[256] ; 00220 CAENModel model_; 00221 CVBoardTypes pcCard_; 00222 std::string pcCardStr_; 00223 00224 }; 00225 00226 } /* namespace HAL */ 00227 00228 #endif /* __CAENLinuxBusAdapter */