QPPortInterface.hh

00001 /*
00002  * APOLLO: A complete DAQ and Online Data Analysis Framework for Cuore
00003  * 
00004  * A.Giachero Created 28/6/6 <Andrea.Giachero@ge.infn.it>
00005  * From original library designed in Milano by C. Arnaboldi
00006  *
00007  * $Id: QEleInterface.hh 404 2006-11-10 23:40:40Z giacher $
00008  * $Revision: 404 $
00009  *
00010  * Header file for C library for Electronic interface
00011  *
00012  */
00013 
00014 #ifndef _FE_INTERFACE_HH_
00015 #define _FE_INTERFACE_HH_
00016 
00017 
00018 // Apollo Includes
00019 //#include "QPPortLowLevel.hh"
00020 #include "QPPortUserLevel.hh"
00021 #include "QEleChannel.hh"
00022 
00023 //using namespace QLowLib;
00024 
00025 using namespace QUserLib;
00026 
00027 namespace QEleLib {
00028 
00029  
00030   // Communication channels definitions 
00031   enum QEleCommChannels_t 
00032   {
00033     FenChannel  = 0,
00034     RelChannel  = 0,
00035     BesChannel  = 1,
00036     PulsChannel = 2,
00037     MemChannel  = 3
00038   };
00039 
00040 
00041   // I2C devices address 
00042   enum QEleI2CAdress_t 
00043   {
00044     FenDevicesAddress  = 0x10,   
00045     BesDevicesAddress  = 0x20,
00046     PulsDevicesAddress = 0x60,
00047     MemDevicesAddress  = 0xA0
00048   };
00049 
00050 
00051   // Error Code
00052   enum QEleErrorsCode_t 
00053   {
00054     Generic_Error_1             = ((16+1)<<8),          // See subfunction for detail  
00055     Front_End_W_Error           = ((16+2)<<8),          // Front-end error
00056     Backplane_Relay_W_Error     = ((16+3)<<8),          // Beckplane Relay error 
00057     Bessel_Trigger_W_Error      = ((16+4)<<8),          // Bessel-Trigger error  
00058     Pulser_Att_W_Error          = ((16+5)<<8),          // Pulser output attenuator error
00059     Pulser_Status_W_Error       = ((16+6)<<8),          // Pulser control error 
00060     Error_group_7W              = ((16+7)<<8),      
00061     Error_group_8W              = ((16+8)<<8),      
00062     Generic_Error_2             = ((32+1)<<8),          // See subfunction for detail   
00063     Front_End_R_Error           = ((32+2)<<8),          // Front-end error
00064     Backplane_Relay_R_Error     = ((32+3)<<8),          // Rele error
00065     Bessel_Trigger_R_Error      = ((32+4)<<8),          // Bessel-Trigger error
00066     Pulser_Att_R_Error          = ((32+5)<<8),          // Pulser output attenuator error
00067     Pulser_Status_R_Error       = ((32+6)<<8),          // Pulser control error 
00068     Error_group_7R              = ((32+7)<<8),  
00069     Error_group_8R              = ((32+8)<<8)  
00070   };
00071 
00072   //
00073 
00074 
00075   // Note: if error is from byte not ack, at the error value will be added 128 (in absolute value )
00076 
00077   /*
00078   // Structure for Front-Ends & bessels addressing
00079   struct QEleAddress 
00080   {
00081     int Board;         // (12bit)
00082     int Channel;       // Front-End --> Channel = 0,1  -  Bessel --> Channel = 0,1,3;
00083     int Controller;    // Controller (crate) Address
00084     int Slot;          // Slot Number, Front-End --> Slot = 0,1,..,11
00085                        //              Bessel    --> Slot = 0,1,..,15         
00086   };
00087 
00088   */
00089 
00090   // PPort Init Function 
00091   int Init(unsigned long PPortAddress);
00092 
00093   // PPort Close
00094   int Close();
00095   
00096   
00097   // FRONT END FUNCTIONS
00098   // Writes the "by" byte in the register "nb" of Front-End addressed by "Add"
00099   int writeFrontEnd(const QEleAddress &Add, int nB, char by);                
00100   
00101   // Reads the "by byte" from register "nb" of Front-End addressed by "Add"                       i
00102   int readFrontEnd(const QEleAddress &Add, int nB, char& by);               
00103   
00104   
00105   // BESSELS FUNCTIONS
00106   // Writes the "by" byte in the register of Bessel addressed by "Add"
00107   int writeBessel(const QEleAddress &Add, char by);
00108   
00109   // Reads the "by" byte from register of Bessel addressed by "add"                        
00110   int readBessel(const QEleAddress &Add, char& by);                        
00111   
00112   
00113   // RELAYS FUNCTIONS
00114   // Writes the relays status "by" in the Crate Controller addressed by "Controller" 
00115   int writeRele(int Controller, char by);
00116   
00117   // Reads the relays status "by" from Crate Controller addressed by "Controller"
00118   int readRele(int Controller, char& by);                                  
00119   
00120   
00121   // PULSER FUNCTIONS
00122   // Writes attenuation status "Byte0" in the Pulser Group addressed by "Add"
00123   int writePulserAtten(int Add,char Byte3);
00124   
00125   // Writes the pulses duration "Time" in the Pulser Group addressed by "Add"
00126   // writes also the status bytes "Byte1" and "Byte2"                               
00127   int writePulserStatus(int Add,char Time,char Byte1, char Byte2);
00128   
00129   // Reads the attenuation status "by" from Pulser Group addressed by "Add"
00130   int readPulserAtten(int Add,char& by);
00131   
00132   // Reads the pulses duration "Time" from Pulser Group addressed by "Add"
00133   // reads also the status bytes "Byte1" and "Byte2"                            
00134   int readPulserStatus(int Add, char& Time,char& Byte1, char& Byte2); 
00135   
00136   // FE Error Handler: err --> error code, sstr --> error message                        
00137   int IO_ErrorDecode(int err, char* sstr);  
00138   
00139 };
00140 
00141 #endif //_FE_INTERFACE_HH_

Generated on Tue Nov 16 10:49:54 2010 for CUORE Software by  doxygen 1.5.6