JLab Pipeline TD Library  3v6.1
Initialization/Configuration

Functions

STATUS tdInit (UINT32 addr, UINT32 addr_inc, int nfind, int iFlag)
 Initialize JLAB TD Library. More...
 
void tdInitPortNames ()
 Initialize portName array with default names in the form: Slot%2d - Portd. More...
 
int tdSetPortName (int id, int iport, char *name)
 Rename a specified port to a specified 20 character string. More...
 
int tdLoadPortNames (char *filename)
 Load the Port Names as specified in a file. More...
 
int tdSetBlockLevel (int id, unsigned int blockLevel)
 Set the number of events per block. More...
 
int tdGSetBlockLevel (unsigned int blockLevel)
 Set the block level for all initialized TDs. More...
 
int tdSetBlockBufferLevel (int id, unsigned int level)
 Set the block buffer level for the number of blocks in the system that need to be read out. More...
 
int tdGSetBlockBufferLevel (unsigned int level)
 Set the block buffer level for the number of blocks in the system that need to be read out for all initialized TDs. More...
 
int tdEnableFiber (int id, unsigned int fiber)
 Enable Fiber transceiver. More...
 
int tdDisableFiber (int id, unsigned int fiber)
 Disable Fiber transceiver. More...
 
int tdSetFiberMask (int id, unsigned int fibermask)
 Enable/Disable fiber ports according to specified mask. More...
 
int tdSetBusySource (int id, unsigned int sourcemask, int rFlag)
 Set the busy source with a specified sourcemask. More...
 
int tdSetTriggerLock (int id, int enable)
 Set the the trigger lock mode for the specified TD. More...
 
int tdGSetTriggerLock (int enable)
 Set the the trigger lock mode for all initialized TDs. More...
 
int tdGetTriggerLock (int id)
 Get the current setting of the trigger lock mode for the specified TD. More...
 
int tdSetTriggerSource (int id, int trigmask)
 Set trigger sources with specified trigmask. More...
 
int tdResetSlaveConfig (int id)
 Reset the configuration of TI Slaves on the TD. More...
 
int tdAddSlave (int id, unsigned int fiber)
 Add and configure a TI Slave for the TD. More...
 
int tdRemoveSlave (int id, unsigned int fiber)
 Remove a TI Slave for the TD. More...
 
int tdAddSlaveMask (int id, unsigned int fibermask)
 Add and configure TI Slaves by using a mask for the TD. More...
 
int tdAutoAlignSync (int id)
 Auto Align Sync Delay. More...
 
int tdLatchTimers (int id)
 Latch the Busy and Live Timers. More...
 
int tdEnableSyncResetRequest (int id, unsigned int portMask)
 Configure which ports (and self) to enable response of a SyncReset request. More...
 
int tdTriggerReadyReset (int id)
 Reset the triggers enabled status bits of TI Slaves. More...
 
int tdSetPortNamesFromCrateID (int id)
 Set the port names for the specified TD from the received Crate IDs from the TI Slaves. More...
 
void tdGSetPortNamesFromCrateID ()
 Set the port names for all initialized TD from the received Crate IDs from the TI Slaves. More...
 
int tdResetMGT (int id)
 Reset the MGT. More...
 
int tdResetMGTRx (int id)
 Reset the MGT Rx CDR. More...
 
int tdSetOutputPort (int id, unsigned int set1, unsigned int set2, unsigned int set3, unsigned int set4)
 Set (or unset) high level for the output ports on the front panel labelled as O#1-4. More...
 

Detailed Description

Function Documentation

◆ tdAddSlave()

int tdAddSlave ( int  id,
unsigned int  fiber 
)

Add and configure a TI Slave for the TD.

This routine should be used by the TD to configure HFBR port and BUSY sources.

Parameters
idSlot number
fiberThe fiber port of the TD that is connected to the slave
Returns
OK if successful, ERROR otherwise

References TD_BUSY_HFBR1, tdEnableFiber(), tdID, tdSetBusySource(), and tdSlaveMask.

Referenced by tdAddSlaveMask().

◆ tdAddSlaveMask()

int tdAddSlaveMask ( int  id,
unsigned int  fibermask 
)

Add and configure TI Slaves by using a mask for the TD.

This routine should be used by the TD to configure HFBR ports and BUSY sources.

Parameters
idSlot number
fibermaskThe fiber port mask of the TDs that are connected to the slaves. bit 0 - port 1... bit 7 - port 8
Returns
OK if successful, ERROR otherwise

References tdAddSlave(), and tdID.

◆ tdAutoAlignSync()

int tdAutoAlignSync ( int  id)

Auto Align Sync Delay.

This routine is called in tiInit

Parameters
idSlot number
Returns
OK if successful, ERROR otherwise

References TD_A24RegStruct::reset, TD_RESET_AUTOALIGN_P0_SYNC, TD_RESET_IODELAY, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdInit().

◆ tdDisableFiber()

int tdDisableFiber ( int  id,
unsigned int  fiber 
)

Disable Fiber transceiver.

Parameters
idSlot number
fiberinteger indicative of the transceiver to disable
Returns
OK if successful, ERROR otherwise.

References tdID, TDLOCK, and TDUNLOCK.

◆ tdEnableFiber()

int tdEnableFiber ( int  id,
unsigned int  fiber 
)

Enable Fiber transceiver.

Note: All Fiber are enabled by default (no harm, except for 1-2W power usage)

Parameters
idSlot number
fiberinteger indicative of the transceiver to enable
Returns
OK if successful, ERROR otherwise.

References tdID, TDLOCK, and TDUNLOCK.

Referenced by tdAddSlave().

◆ tdEnableSyncResetRequest()

int tdEnableSyncResetRequest ( int  id,
unsigned int  portMask 
)

Configure which ports (and self) to enable response of a SyncReset request.

Parameters
idSlot number
portMaskMask of ports to enable (port 1 = bit 0)
self1 to enable self, 0 to disable
Returns
OK if successful, otherwise ERROR

References TD_A24RegStruct::rocEnable, TD_ROCENABLE_MASK, tdID, TDLOCK, and TDUNLOCK.

◆ tdGetTriggerLock()

int tdGetTriggerLock ( int  id)

Get the current setting of the trigger lock mode for the specified TD.

Parameters
idSlot number
Returns
1 if enabled, 0 if disabled, ERROR otherwise.

References TD_A24RegStruct::busy, TD_BUSY_TRIGGER_LOCK, tdID, TDLOCK, and TDUNLOCK.

◆ tdGSetBlockBufferLevel()

int tdGSetBlockBufferLevel ( unsigned int  level)

Set the block buffer level for the number of blocks in the system that need to be read out for all initialized TDs.

If this buffer level is full, the TD will go BUSY. The BUSY is released as soon as the number of buffers in the system drops below this level.

Parameters
level
  • 0: No Buffer Limit - Pipeline mode
  • 1: One Block Limit - "ROC LOCK" mode
  • 2-65535: "Buffered" mode.
Returns
OK if successful, otherwise ERROR

References nTD, tdID, and tdSetBlockBufferLevel().

◆ tdGSetBlockLevel()

int tdGSetBlockLevel ( unsigned int  blockLevel)

Set the block level for all initialized TDs.

Parameters
blockLevelBlock Level
Returns
OK if successful, ERROR otherwise

References nTD, tdID, and tdSetBlockLevel().

◆ tdGSetPortNamesFromCrateID()

void tdGSetPortNamesFromCrateID ( )

Set the port names for all initialized TD from the received Crate IDs from the TI Slaves.

Returns
OK if successful, otherwise ERROR;

References nTD, tdSetPortNamesFromCrateID(), and tdSlot().

◆ tdGSetTriggerLock()

int tdGSetTriggerLock ( int  enable)

Set the the trigger lock mode for all initialized TDs.

Parameters
enableEnable flag 0: Disable !0: Enable
Returns
OK if successful, ERROR otherwise.

References TD_A24RegStruct::busy, nTD, TD_BUSY_TRIGGER_LOCK, TDLOCK, tdSlot(), and TDUNLOCK.

◆ tdInit()

STATUS tdInit ( UINT32  addr,
UINT32  addr_inc,
int  nfind,
int  iFlag 
)

Initialize JLAB TD Library.

Parameters
addr
  • A24 VME Address of the TD
addr_inc
  • Amount to increment addr to find the next TD
nfind
  • Number of times to increment
iFlag- Initialization mask
  • 0: Exit before board initialization (just map structure pointer)
  • 1: RFU
  • 2: Ignore firmware check
  • 3: Use tdAddrList instead of addr and addr_inc for VME addresses
Returns
OK if successful, otherwise ERROR.

References TD_A24RegStruct::boardID, nTD, TD_BOARDID_GEOADR_MASK, TD_BOARDID_TYPE_MASK, TD_BOARDID_TYPE_TD, TD_FIRMWARE_ID_MASK, TD_FIRMWARE_MAJOR_VERSION_MASK, TD_FIRMWARE_TYPE_MASK, TD_FIRWMARE_MINOR_VERSION_MASK, TD_INIT_NO_INIT, TD_INIT_SKIP_FIRMWARE_CHECK, TD_INIT_USE_ADDR_LIST, TD_SUPPORTED_FIRMWARE, TD_SUPPORTED_TYPE, TD_SYNC_P0, TD_TRIGSRC_LOOPBACK, TD_TRIGSRC_P0, tdA24Offset, tdAddrList, tdAutoAlignSync(), tdGetFirmwareVersion(), tdID, tdInitPortNames(), tdResetMGT(), tdSetBlockBufferLevel(), tdSetBlockLevel(), tdSetBusySource(), tdSetFiberMask(), tdSetSyncSource(), tdSetTriggerSource(), tdSlaveMask, and tdTriggerReadyReset().

◆ tdInitPortNames()

void tdInitPortNames ( )

Initialize portName array with default names in the form: Slot%2d - Portd.

  • This routine is called in tdInit(...)

References TD_MAX_FIBER_PORTS, and TD_MAX_VME_SLOTS.

Referenced by tdInit().

◆ tdLatchTimers()

int tdLatchTimers ( int  id)

Latch the Busy and Live Timers.

This routine should be called prior to a call to tdGetLiveTime and tdGetBusyTime

Parameters
idSlot number
See also
tdGetLiveTime
tdGetBusyTime
Returns
OK if successful, ERROR otherwise

References TD_A24RegStruct::reset, TD_RESET_LATCH_TIMERS, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdStatus().

◆ tdLoadPortNames()

int tdLoadPortNames ( char *  filename)

Load the Port Names as specified in a file.

Format must be: Slot Port Name e.g. 3 2 ROC5 3 3 ROC10

Parameters
filenameName of input file
Returns
OK if successful, otherwise ERROR.

References TD_MAX_PORTNAME_CHARS, and tdSetPortName().

◆ tdRemoveSlave()

int tdRemoveSlave ( int  id,
unsigned int  fiber 
)

Remove a TI Slave for the TD.

Parameters
idSlot number
fiberThe fiber port of the TD to remove.
Returns
OK if successful, ERROR otherwise

References TD_A24RegStruct::busy, TD_A24RegStruct::fiber, TD_BUSY_HFBR1, tdID, TDLOCK, tdSlaveMask, and TDUNLOCK.

◆ tdResetMGT()

int tdResetMGT ( int  id)

Reset the MGT.

Parameters
idSlot number

References TD_A24RegStruct::reset, TD_RESET_MGT, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdInit().

◆ tdResetMGTRx()

int tdResetMGTRx ( int  id)

Reset the MGT Rx CDR.

Parameters
idSlot number

References TD_A24RegStruct::reset, TD_RESET_MGT_RX_RESET, tdID, TDLOCK, and TDUNLOCK.

◆ tdResetSlaveConfig()

int tdResetSlaveConfig ( int  id)

Reset the configuration of TI Slaves on the TD.

This routine removes all slaves and resets the fiber port busys.

Parameters
idSlot number
Returns
OK if successful, ERROR otherwise

References TD_A24RegStruct::busy, TD_BUSY_HFBR_MASK, tdID, TDLOCK, tdSlaveMask, and TDUNLOCK.

◆ tdSetBlockBufferLevel()

int tdSetBlockBufferLevel ( int  id,
unsigned int  level 
)

Set the block buffer level for the number of blocks in the system that need to be read out.

If this buffer level is full, the TD will go BUSY. The BUSY is released as soon as the number of buffers in the system drops below this level.

Parameters
idSlot number
level
  • 0: No Buffer Limit - Pipeline mode
  • 1: One Block Limit - "ROC LOCK" mode
  • 2-65535: "Buffered" mode.
Returns
OK if successful, otherwise ERROR

References TD_A24RegStruct::blockBuffer, TD_BLOCKBUFFER_BUFFERLEVEL_MASK, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdGSetBlockBufferLevel(), and tdInit().

◆ tdSetBlockLevel()

int tdSetBlockLevel ( int  id,
unsigned int  blockLevel 
)

Set the number of events per block.

Parameters
idSlot number
blockLevelBlock Level
Returns
OK if successful, ERROR otherwise

References TD_A24RegStruct::blocklevel, TD_BLOCKLEVEL_MASK, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdGSetBlockLevel(), and tdInit().

◆ tdSetBusySource()

int tdSetBusySource ( int  id,
unsigned int  sourcemask,
int  rFlag 
)

Set the busy source with a specified sourcemask.

Parameters
idSlot number
sourcemaskbits:
  • N: FIXME: FILL THIS IN
rFlag- decision to reset the global source flags
  • 0: Keep prior busy source settings and set new "sourcemask"
  • 1: Reset, using only that specified with "sourcemask"
Returns
OK if successful, ERROR otherwise.

References TD_A24RegStruct::busy, TD_BUSY_SOURCEMASK, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdAddSlave(), and tdInit().

◆ tdSetFiberMask()

int tdSetFiberMask ( int  id,
unsigned int  fibermask 
)

Enable/Disable fiber ports according to specified mask.

Parameters
idSlot number
fibermaskmask indicative of the transceivers to enable/disable
Returns
OK if successful, ERROR otherwise.

References TD_A24RegStruct::fiber, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdInit().

◆ tdSetOutputPort()

int tdSetOutputPort ( int  id,
unsigned int  set1,
unsigned int  set2,
unsigned int  set3,
unsigned int  set4 
)

Set (or unset) high level for the output ports on the front panel labelled as O#1-4.

Parameters
set1O#1
set2O#2
set3O#3
set4O#4
Returns
OK if successful, otherwise ERROR

References TD_A24RegStruct::output, tdID, TDLOCK, and TDUNLOCK.

◆ tdSetPortName()

int tdSetPortName ( int  id,
int  iport,
char *  name 
)

Rename a specified port to a specified 20 character string.

Parameters
idSlot number
iportPort Number
nameString to assign to port
Returns
OK if successful, otherwise ERROR.

References TD_MAX_FIBER_PORTS, TD_MAX_PORTNAME_CHARS, TD_MAX_VME_SLOTS, and tdID.

Referenced by tdLoadPortNames(), and tdSetPortNamesFromCrateID().

◆ tdSetPortNamesFromCrateID()

int tdSetPortNamesFromCrateID ( int  id)

Set the port names for the specified TD from the received Crate IDs from the TI Slaves.

Parameters
idSlot number
Returns
OK if successful, otherwise ERROR;

References tdGetCrateID(), tdID, and tdSetPortName().

Referenced by tdGSetPortNamesFromCrateID().

◆ tdSetTriggerLock()

int tdSetTriggerLock ( int  id,
int  enable 
)

Set the the trigger lock mode for the specified TD.

Parameters
idSlot number
enableEnable flag 0: Disable !0: Enable
Returns
OK if successful, ERROR otherwise.

References TD_A24RegStruct::busy, TD_BUSY_TRIGGER_LOCK, tdID, TDLOCK, and TDUNLOCK.

◆ tdSetTriggerSource()

int tdSetTriggerSource ( int  id,
int  trigmask 
)

Set trigger sources with specified trigmask.

Parameters
idSlot number
trigmaskbits:
  • 0: P0
  • 1: HFBR #1
  • 2: TI Master Loopback
  • 3: Front Panel (TRG) Input
  • 4: VME Trigger
  • 5: Front Panel TS Inputs
  • 6: TS (rev 2) Input
  • 7: Random Trigger
  • 8: FP/Ext/GTP
  • 9: P2 Busy
Returns
OK if successful, ERROR otherwise

References TD_TRIGSRC_SOURCEMASK, tdID, TDLOCK, TDUNLOCK, and TD_A24RegStruct::trigsrc.

Referenced by tdInit().

◆ tdTriggerReadyReset()

int tdTriggerReadyReset ( int  id)

Reset the triggers enabled status bits of TI Slaves.

Parameters
idSlot number
Returns
OK if successful, otherwise ERROR

References TD_A24RegStruct::reset, TD_A24RegStruct::sync, TD_A24RegStruct::syncCommand, TD_RESET_MGT_RX_RESET, TD_SYNC_LOOPBACK, TD_SYNC_SOURCEMASK, TD_SYNCCOMMAND_TRIGGER_READY_RESET, tdID, TDLOCK, and TDUNLOCK.

Referenced by tdInit().