Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

SctPixelRod::TimModule Class Reference

TimModule: A derived class for VME TIM modules. More...

#include <TimModule.h>

Inheritance diagram for SctPixelRod::TimModule::

VmeModule List of all members.

Public Methods

 TimModule (UINT32 baseAddr, UINT32 mapSize, VmeInterface &ourInterface)
 This is the only constructor to use. More...

virtual ~TimModule ()
UINT32 getFirmware ()
UINT32 getSerialNumber ()
VmePort * getVmePort ()
void initialize ()
void reset ()
void status ()
UINT32 fetchL1ID ()
 Read trigger number. More...

UINT16 fetchTimID ()
 Read TIM ID register. More...

void intTrigStart (const TimMaskFrequency frequency)
 Internal Trigger. More...

void intTrigStop ()
 Stop Internal Trigger. More...

void issueCommand (const TimBitCommand mask)
 Issue TIM command. More...

void issueVCAL (const int pipelineDelay)
 Issue VCAL + L1A command. More...

void loadBitClear (const TimRegister addr, const int mask)
 Clear bit. More...

void loadBitSet (const TimRegister addr, const int mask)
 Set bit. More...

void loadByteHi (const TimRegister addr, const UINT8 byte)
 Upper byte. More...

void loadByteLo (const TimRegister addr, const UINT8 byte)
 Lower byte. More...

UINT16 regFetch (const TimRegister addr)
 Read from a 16-bit VME register. More...

void regLoad (const TimRegister addr, const UINT16 data)
 Write to a 16-bit VME register. More...

void seqFetch (const int size, UINT16 buffer[])
 Read sequencer. More...

void seqLoad (const int size, const UINT16 buffer[])
 Load sequencer. More...

void seqRun (const int size)
 Run sequencer. More...

UINT16 vmeFetch (const UINT32 addr) throw (VmeException &)
 Read from a 16-bit VME register. More...

void vmeLoad (const UINT32 addr, const UINT16 data) throw (VmeException &)
 Write to a 16-bit VME register. More...


Private Attributes

UINT32 m_firmware
 Firmware version number. More...

UINT32 m_serialNumber
 Board serial number. More...

VmePort * m_vmePort
 VME Port handle. More...


Detailed Description

TimModule: A derived class for VME TIM modules.

This is the implementation of a TIM class derived from the VmeModule base class. It should be the sole interface for VME communication with TIM.

Contributors: John Lane <jbl@hep.ucl.ac.uk> - originator

Definition at line 67 of file TimModule.h.


Constructor & Destructor Documentation

SctPixelRod::TimModule::TimModule UINT32    baseAddr,
UINT32    mapSize,
VmeInterface &    vme
 

This is the only constructor to use.

Objects of this class cannot be copied or assigned. This could lead to VME conflicts.

Definition at line 51 of file TimModule.cxx.

00051                                                                           :
00052            VmeModule( baseAddr, mapSize, vme ) {
00053 
00054   m_serialNumber = 0xFFFFFFFF;  // Set in initialize
00055 
00056   if (&vme == 0) throw TimException( "TimModule has no VmeInterface", 0, 0 );
00057 
00058   try {
00059     m_vmePort = new VmePort( baseAddr, mapSize, VmeInterface::A32, vme );
00060 
00061     m_vmePort->setExceptionTrapping( true );
00062   }
00063   catch (bad_alloc) {
00064     throw TimException( "TimModule caught bad_alloc", 0, 0 );
00065   }
00066   catch (VmeException x) {
00067     throw TimException( "TimModule caught VmeException",
00068                         x.getErrorClass(), x.getErrorCode() );
00069   }
00070 }

SctPixelRod::TimModule::~TimModule   [virtual]
 

This deletes all its VME Ports.

Definition at line 77 of file TimModule.cxx.

00077                       {
00078 
00079   delete m_vmePort;
00080   m_vmePort = 0;
00081 }


Member Function Documentation

UINT32 SctPixelRod::TimModule::fetchL1ID  
 

Read trigger number.

This method reads the last TIM L1ID value.

Definition at line 135 of file TimModule.cxx.

Referenced by status().

00135                             {
00136 
00137   const UINT32 lo = regFetch( TIM_REG_TRIGGER_IDLO );
00138   const UINT32 hi = regFetch( TIM_REG_TRIGGER_IDHI );
00139   UINT32 l1id;
00140 
00141   if (m_firmware < 9) l1id = (lo & 0x0FFF) + ((hi & 0x0FFF) << 12);
00142   else                l1id = (lo & 0xFFFF) + ((hi & 0x00FF) << 16);
00143   return l1id;
00144 }

UINT16 SctPixelRod::TimModule::fetchTimID  
 

Read TIM ID register.

This method reads the TIM ID register.

Definition at line 151 of file TimModule.cxx.

Referenced by initialize().

00151                              {
00152 
00153   const UINT16 timID = regFetch( TIM_REG_TIM_ID );
00154 
00155   m_serialNumber = timID & 0xFF;
00156   m_firmware     = timID >> 8;
00157   return timID;
00158 }

UINT32 SctPixelRod::TimModule::getFirmware   [inline]
 

Definition at line 80 of file TimModule.h.

00080 { return m_firmware; };

UINT32 SctPixelRod::TimModule::getSerialNumber   [inline]
 

Definition at line 81 of file TimModule.h.

00081 { return m_serialNumber; };

VmePort* SctPixelRod::TimModule::getVmePort   [inline]
 

Definition at line 82 of file TimModule.h.

00082 { return m_vmePort; };

void SctPixelRod::TimModule::initialize  
 

This method configures the TIM into its initialized state.

Definition at line 92 of file TimModule.cxx.

00092                            {
00093 
00094   // enable serial output streams
00095   regLoad( TIM_REG_RUN_ENABLES, TIM_BIT_EN_ID | TIM_BIT_EN_TYPE );
00096   regLoad( TIM_REG_COMMAND, 0 );                    // ensure stand-alone mode
00097   regLoad( TIM_REG_TRIGGER_BCID, TIM_BCID_OFFSET << 12 );  // set BCID offset
00098   fetchTimID();                                          // read serial number
00099 }

void SctPixelRod::TimModule::intTrigStart const TimMaskFrequency    frequency
 

Internal Trigger.

This method Enables Internal Triggers with the given repeat frequency.

Definition at line 165 of file TimModule.cxx.

00165                                                                {
00166 
00167   loadByteLo( TIM_REG_FREQUENCY, frequency );
00168   loadBitSet( TIM_REG_ENABLES, TIM_BIT_EN_INT_TRIG );
00169 }

void SctPixelRod::TimModule::intTrigStop void   
 

Stop Internal Trigger.

This method stops Internal Triggers.

Definition at line 176 of file TimModule.cxx.

00176                                 { //*** void
00177 
00178   loadBitClear( TIM_REG_ENABLES, TIM_BIT_EN_INT_TRIG );
00179 }

void SctPixelRod::TimModule::issueCommand const TimBitCommand    mask
 

Issue TIM command.

This method issues a TIM command edge-mode bit - experimental!

Definition at line 186 of file TimModule.cxx.

Referenced by issueVCAL().

00186                                                        {
00187 
00188   if (mask >  TIM_VSPA) loadBitClear( TIM_REG_COMMAND, mask );
00189   loadBitSet( TIM_REG_COMMAND, mask );
00190   if (mask >  TIM_VSPA) loadBitClear( TIM_REG_COMMAND, mask );
00191 }

void SctPixelRod::TimModule::issueVCAL const int    pipelineDelay
 

Issue VCAL + L1A command.

This method issues a VME CAL command followed by an L1A, after the given pipeline delay.

Definition at line 199 of file TimModule.cxx.

00199                                                    {
00200 
00201   loadByteLo(   TIM_REG_DELAY, pipelineDelay );
00202   issueCommand( TIM_VCAL );
00203 }

void SctPixelRod::TimModule::loadBitClear const TimRegister    addr,
const int    mask
 

Clear bit.

This method clears the bits set in a 16-bit bit mask into a VME register, leaving the other bits unchanged.

Definition at line 223 of file TimModule.cxx.

Referenced by intTrigStop(), and issueCommand().

00223                                                                      {
00224 
00225   UINT16 value = vmeFetch( addr );
00226   vmeLoad( addr, value & ~mask );
00227 }

void SctPixelRod::TimModule::loadBitSet const TimRegister    addr,
const int    mask
 

Set bit.

This method writes the bits set in a 16-bit bit mask into a VME register, leaving the other bits unchanged.

Definition at line 211 of file TimModule.cxx.

Referenced by intTrigStart(), and issueCommand().

00211                                                                    {
00212 
00213   UINT16 value = vmeFetch( addr );
00214   vmeLoad( addr, value | mask );
00215 }

void SctPixelRod::TimModule::loadByteHi const TimRegister    addr,
const UINT8    byte
 

Upper byte.

This method writes a byte into the upper half of a 16-bit VME register, leaving the other byte unchanged.

Definition at line 235 of file TimModule.cxx.

00235                                                                      {
00236 
00237   UINT16 value = vmeFetch( addr );
00238   vmeLoad( addr, (value & 0x00FF) | (byte << 8) );
00239 }

void SctPixelRod::TimModule::loadByteLo const TimRegister    addr,
const UINT8    byte
 

Lower byte.

This method writes a byte into the lower half of a 16-bit VME register, leaving the other byte unchanged.

Definition at line 247 of file TimModule.cxx.

Referenced by intTrigStart(), and issueVCAL().

00247                                                                      {
00248 
00249   UINT16 value = vmeFetch( addr );
00250   vmeLoad( addr, (value & 0xFF00) | byte );
00251 }

UINT16 SctPixelRod::TimModule::regFetch const TimRegister    addr
 

Read from a 16-bit VME register.

This method reads a 16-bit value from a VME register.

Definition at line 258 of file TimModule.cxx.

Referenced by fetchL1ID(), fetchTimID(), and status().

00258                                                    {
00259 
00260   UINT16 data = vmeFetch( addr );
00261   return data;
00262 }

void SctPixelRod::TimModule::regLoad const TimRegister    addr,
const UINT16    data
 

Write to a 16-bit VME register.

This method writes a 16-bit value into a VME register.

Definition at line 269 of file TimModule.cxx.

Referenced by initialize(), reset(), and seqRun().

00269                                                                    {
00270 
00271   vmeLoad( addr, data );
00272 }

void SctPixelRod::TimModule::reset  
 

This method issues a reset to the TIM.

Definition at line 106 of file TimModule.cxx.

00106                       {
00107 
00108   regLoad( TIM_REG_COMMAND, TIM_BIT_VRESET );
00109 }

void SctPixelRod::TimModule::seqFetch const int    size,
UINT16    buffer[]
 

Read sequencer.

This method reads the Sequencer memory into a buffer.

Definition at line 293 of file TimModule.cxx.

00293                                                           {
00294 
00295   for (int i = 0; i < size; i++) {
00296     buffer[i] = vmeFetch( TIM_SEQ_ADDR + i*2 );
00297   }
00298 }

void SctPixelRod::TimModule::seqLoad const int    size,
const UINT16    buffer[]
 

Load sequencer.

This method writes a buffer into the Sequencer memory.

Definition at line 305 of file TimModule.cxx.

00305                                                                {
00306 
00307   UINT16 data;
00308   for (int i = 0; i < size; i++) {
00309     data = buffer[i];
00310     vmeLoad( TIM_SEQ_ADDR + i*2, data );
00311   }
00312 }

void SctPixelRod::TimModule::seqRun const int    size
 

Run sequencer.

This method starts the Sequencer executing.

Definition at line 279 of file TimModule.cxx.

00279                                        {
00280 
00281   regLoad( TIM_REG_SEQ_END,     size - 1 );
00282   regLoad( TIM_REG_SEQ_CONTROL, TIM_BIT_SEQ_RESET );
00283   regLoad( TIM_REG_SEQ_CONTROL, 0 );
00284   regLoad( TIM_REG_SEQ_CONTROL, TIM_BIT_SEQ_GO | TIM_BIT_SEQ_EN_ALL );
00285   // all outputs enabled
00286 }

void SctPixelRod::TimModule::status  
 

This method reports the status of the TIM. For now, it simply prints to standard output.

Definition at line 117 of file TimModule.cxx.

00117                        {
00118 
00119   cout << "status" << endl;
00120 
00121   cout << " Serial Number: " << m_serialNumber;
00122   cout << " Version: "       << m_firmware;
00123   cout << endl;
00124   hex(cout);
00125   cout << " L1ID: "   << fetchL1ID();
00126   cout << " BCID: "   << regFetch( TIM_REG_TRIGGER_BCID );
00127   cout << " status: " << regFetch( TIM_REG_STATUS );
00128   cout << endl;
00129 }

UINT16 SctPixelRod::TimModule::vmeFetch const UINT32    addr throw (VmeException &)
 

Read from a 16-bit VME register.

This method reads a 16-bit value from a VME register.

Definition at line 319 of file TimModule.cxx.

Referenced by loadBitClear(), loadBitSet(), loadByteHi(), loadByteLo(), regFetch(), and seqFetch().

00320                                          {
00321 
00322   UINT16 data = 0;
00323   try {
00324     data = m_vmePort->read16( addr );
00325   }
00326   catch (VmeException & vmeFailed) {
00327     // Leave critical section before re-throwing the error
00328     throw vmeFailed;
00329   }
00330   return data;
00331 }

void SctPixelRod::TimModule::vmeLoad const UINT32    addr,
const UINT16    data
throw (VmeException &)
 

Write to a 16-bit VME register.

This method writes a 16-bit value into a VME register.

Definition at line 338 of file TimModule.cxx.

Referenced by loadBitClear(), loadBitSet(), loadByteHi(), loadByteLo(), regLoad(), and seqLoad().

00339                                         {
00340 
00341   try {
00342     m_vmePort->write16( addr, data );
00343 //debug  throw VmeException(VmeException::BUS_ERROR, 1, m_vmePort);
00344   }
00345   catch (VmeException & vmeFailed) {
00346     // Leave critical section before re-throwing the error
00347     throw vmeFailed;
00348   }
00349 }


Member Data Documentation

UINT32 SctPixelRod::TimModule::m_firmware [private]
 

Firmware version number.

Definition at line 122 of file TimModule.h.

UINT32 SctPixelRod::TimModule::m_serialNumber [private]
 

Board serial number.

Definition at line 123 of file TimModule.h.

VmePort* SctPixelRod::TimModule::m_vmePort [private]
 

VME Port handle.

Definition at line 124 of file TimModule.h.


The documentation for this class was generated from the following files:
Generated on Mon Mar 3 11:16:19 2003 for SCTPixelDAQ by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001