JLab Pipeline TD Library  3v6.1
tdLib.c File Reference

Macros

#define _GNU_SOURCE
 
#define TDLOCK   if(pthread_mutex_lock(&tdMutex)<0) perror("pthread_mutex_lock");
 
#define TDUNLOCK   if(pthread_mutex_unlock(&tdMutex)<0) perror("pthread_mutex_unlock");
 

Functions

STATUS tdInit (UINT32 addr, UINT32 addr_inc, int nfind, int iFlag)
 Initialize JLAB TD Library. More...
 
int tdSlot (unsigned int i)
 Convert an index into a slot number, where the index is the element of an array of TDs in the order in which they were initialized. More...
 
unsigned int tdSlotMask ()
 Return the VME Slot mask of initialized TDs. More...
 
int tdCheckAddresses ()
 Test of register map. More...
 
void tdStatus (int id, int pflag)
 Print some status information of the TD to standard out. 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 tdGetPortName (int id, int iport, char **name)
 Get the current specified port name. More...
 
int tdSavePortNames (char *filename)
 Save the current port names to a file (with file name: filename) More...
 
int tdLoadPortNames (char *filename)
 Load the Port Names as specified in a file. More...
 
void tdPrintPortNames ()
 Print the current port names to standard out. More...
 
void tdGStatus (int pflag)
 Print a summary of all configured TD modules and ports to standard out. 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 tdGetFirmwareVersion (int id)
 Get the Firmware Version. 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 tdSetSyncSource (int id, unsigned int sync)
 Set the Sync source mask. 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...
 
unsigned int tdGetSerialNumber (int id, char **rSN)
 Get the Module Serial Number. More...
 
int tdLatchTimers (int id)
 Latch the Busy and Live Timers. More...
 
unsigned int tdGetLiveTime (int id)
 Return the current "live" time of the module. More...
 
unsigned int tdGetBusyTime (int id)
 Return the current "busy" time of the module. More...
 
int tdEnableSyncResetRequest (int id, unsigned int portMask)
 Configure which ports (and self) to enable response of a SyncReset request. More...
 
int tdSyncResetRequestStatus (int id, int pflag)
 Status of SyncReset Request received bits. More...
 
int tdGetConnectedFiberMask (int id)
 Returns the mask of fiber channels that report a "connected" status from a TI. More...
 
int tdGetTrigSrcEnabledFiberMask (int id)
 Returns the mask of fiber channels that report a "connected" status from a TI has it's trigger source enabled. More...
 
int tdTriggerReadyReset (int id)
 Reset the triggers enabled status bits of TI Slaves. More...
 
int tdGetCrateID (int id, int port)
 Get the crate ID of the selected port. 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 tdGetPortTrigSrcEnabled (int id, int port)
 Get the trigger sources enabled bits of the selected port. More...
 
int tdGetSlaveBlocklevel (int id, int port)
 Get the blocklevel of the TI Slave on the selected port. More...
 
int tdResetMGT (int id)
 Reset the MGT. More...
 
int tdResetMGTRx (int id)
 Reset the MGT Rx CDR. More...
 
void tdSlaveStatus (int id, int pflag)
 Print a summary of all fiber port connections to potential TI Slaves. More...
 
unsigned int tdGetBlockStatus (int id, int port, int pflag)
 Obtain the status of blocks sent readout acknowledges received from the TI Slaves. More...
 
int tdGetBusyStatus (int id, int port, int pflag)
 
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...
 
unsigned int tdGetTrigCount (int id)
 Return the number of triggers received from the trigger supervisor. More...
 
unsigned int tdGetBusyCounter (int id, int busysrc)
 Return BUSY counter for specified Busy Source. More...
 
int tdPrintBusyCounters (int id)
 Print the BUSY counters for all busy sources. More...
 

Variables

pthread_mutex_t tdMutex = PTHREAD_MUTEX_INITIALIZER
 
int nTD = 0
 
volatile struct TD_A24RegStructTDp [MAX_VME_SLOTS+1]
 
int tdID [MAX_VME_SLOTS+1]
 
unsigned int tdAddrList [MAX_VME_SLOTS+1]
 
unsigned long tdA24Offset =0
 
int tdCrateID =0x59
 
int tdBlockLevel =0
 
int tdFiberLatencyOffset = 0xbf
 
unsigned int tdSlaveMask [MAX_VME_SLOTS+1]
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ TDLOCK

◆ TDUNLOCK

Function Documentation

◆ tdGetBusyStatus()

int tdGetBusyStatus ( int  id,
int  port,
int  pflag 
)

Variable Documentation

◆ nTD

◆ tdA24Offset

unsigned long tdA24Offset =0

Difference in CPU A24 Base and VME A24 Base

Referenced by tdInit(), tdSlaveStatus(), and tdStatus().

◆ tdAddrList

unsigned int tdAddrList[MAX_VME_SLOTS+1]

array of a24 addresses for TDs

Referenced by tdInit().

◆ tdBlockLevel

int tdBlockLevel =0

Block level for TD

◆ tdCrateID

int tdCrateID =0x59

Crate ID

◆ tdFiberLatencyOffset

int tdFiberLatencyOffset = 0xbf

Default offset for fiber latency

◆ tdID

◆ tdMutex

pthread_mutex_t tdMutex = PTHREAD_MUTEX_INITIALIZER

Mutex to guard TD read/writes

◆ TDp

volatile struct TD_A24RegStruct* TDp[MAX_VME_SLOTS+1]

pointer to TD memory map

◆ tdSlaveMask

unsigned int tdSlaveMask[MAX_VME_SLOTS+1]

TI Slaves (mask) to be used

Referenced by tdAddSlave(), tdGStatus(), tdInit(), tdRemoveSlave(), tdResetSlaveConfig(), tdSlaveStatus(), and tdStatus().