GLAST/LAT > DAQ and FSW > FSW > Doxygen Index > TPG / V3-0-0

Constituent: tpg     Tag: mv2304


Interface   Data Structures   File List   Data Fields   Globals  

tpg.c File Reference

Trigger Pattern Generator command-line user interface. More...

#include "TPG/TPG_msgs.h"
#include "tpg_p.h"
#include "tpgmap.h"
#include "LEM/cli.h"
#include "MSG/MSG_pubdefs.h"
#include "MSG/MSG_msgs.h"
#include "MSG/MSG_printProc.h"
#include "PBS/PBS.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <taskLib.h>

Include dependency graph for tpg.c:

Include dependency graph

Defines

#define TPG_DEBUG_NONE   0x00000000
#define TPG_DEBUG_CLK_SEL   0x00000001
#define TPG_TIME_IN_CMD
#define INC_CNT_MAX   8

Functions

void TPGupdateCachedCnt (unsigned count)
unsigned TPGnBoards (TPG *this)
unsigned TPGgtbPresent (TPG *this, unsigned boardId)
TPGTPGnew (unsigned *brdAddr)
 Calls calloc to allocate memory for the struct and associated buffers then sets the buffer pointers to the correct offsets.

void TPGclear (TPG *this)
 Sets all the buffers to 0.

void TPGclearBuf (TPG *this, unsigned bufferId)
 Sets the buffer indicated by bufferId to 0.

unsigned TPGsetTEM (TPG *this, unsigned tem_id, unsigned trg, unsigned start, unsigned pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the channel and buffer indicated by tem_id and trg.

unsigned TPGsetVETO (TPG *this, unsigned free_id, unsigned veto_id, unsigned start, unsigned pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

unsigned TPGsetCNO (TPG *this, unsigned free_id, unsigned start, unsigned pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

unsigned TPGsetExtTrig (TPG *this, unsigned start, unsigned pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the external trigger buffer.

unsigned TPGsetTEMv (TPG *this, unsigned tem_id, unsigned trg, unsigned start, unsigned *pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the channel and buffer indicated by tem_id and trg.

unsigned TPGsetVETOv (TPG *this, unsigned free_id, unsigned veto_id, unsigned start, unsigned *pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

unsigned TPGsetCNOv (TPG *this, unsigned free_id, unsigned start, unsigned *pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

unsigned TPGsetExtTrigv (TPG *this, unsigned start, unsigned *pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into the external trigger buffer.

unsigned TPGdelay (TPG *this, int gtbId, int clkDelay)
unsigned TPGload (TPG *this, unsigned char *clkDelay)
 Use Programmed I/O to fill the COMM board FIFOs.

unsigned TPGarm (TPG *this, gtbTrig_t trig)
unsigned TPGgemStart (TPG *this)
unsigned TPGstartCmd (TPG *this)
unsigned TPGstartVME (TPG *this)
unsigned TPGstart (TPG *this)
 Start the playback.

unsigned TPGdumpTEM (TPG *this, unsigned start, unsigned len)
 Print out the bit patterns in the TEM buffer.

unsigned TPGdumpFREE (TPG *this, unsigned free_id, unsigned start, unsigned len)
 Print out the bit patterns in the free board.

unsigned TPGdumpCNO (TPG *this, unsigned start, unsigned len)
 Print out the bit patterns in the CNO buffer.

unsigned TPGdump (TPG *this, unsigned boardId, unsigned start, unsigned len)
 Print out the bit patterns in the requested board.

unsigned _checkBounds (unsigned start, unsigned pat_len, unsigned repetitions)
 Checks that the requested addition to the buffer does not exceed the boundaries.

void _setBits (unsigned *fifo, unsigned channel, unsigned start, unsigned pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into channel and in buffer indicated by board.

void _setSticky (unsigned *fifo, unsigned channel)
 Sets the last bit of channel in fifo.

void _clrSticky (unsigned *fifo, unsigned channel)
 Clears the last bit of channel in fifo.

void _setBitsv (unsigned *fifo, unsigned channel, unsigned start, unsigned *pattern, unsigned pat_len, unsigned repetitions)
 Places the pat_len LSBs of pattern into channel and in buffer indicated by board.

int TPGmsgInit (void)
 Starts a simple printf MSG processor.

unsigned TPGsetTEMsticky (TPG *this, unsigned tem_id, unsigned trg)
 Sets the last bit of the buffer, which will "stick" on the COMM I/O outputs.

unsigned TPGclrTEMsticky (TPG *this, unsigned tem_id, unsigned trg)
 Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

unsigned TPGsetVETOsticky (TPG *this, unsigned free_id, unsigned veto_id)
 Sets the last bit of the buffer, which will "stick" on the COMM I/O outputs.

unsigned TPGclrVETOsticky (TPG *this, unsigned free_id, unsigned veto_id)
 Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

unsigned TPGsetCNOsticky (TPG *this, unsigned free_id)
 Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

unsigned TPGclrCNOsticky (TPG *this, unsigned free_id)
 Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

void TPGfifoStatShow (TPG *this)
void TPGgtbTrigClk (TPG *this, int rising)
void TPGgtbSetupShow (TPG *this)
void TPGsetTimeInParms (TPG *this, int temStart, int temPat, int temLen, int temReps, int temInc, int freeStart, int freePat, int freeLen, int freeReps, int freeInc)
void TPGgtbTimeInDelayChan (TPG *this, int tem, int chan, int delay)
void TPGgtbTimeInCmd (TPG *this)
void TPGgtbHwCmdCheck (TPG *this, unsigned int pattern, int readback)
void TPGshow (TPG *this, unsigned detail)

Variables

unsigned TPG_BUSY = 0
unsigned TPG_TIAR = 1
unsigned TPG_CALHI = 2
unsigned TPG_CALLO = 3
unsigned TPG_N_TRG = 4
unsigned TPG_TEM_BOARD = -1
unsigned TPG_LASTWORD = TPG_BUFFER_DEPTH - sizeof(unsigned)
unsigned tpgDebug = TPG_DEBUG_NONE
unsigned tpgCachedCnt = 0
unsigned tpgFifoBugOffset = 2
int tpgTemPat = 0x80000003
int tpgFreePat = 0xa0000003
int tpgTemStart = 0
int tpgFreeStart = 0
int tpgTemLen = 32
int tpgFreeLen = 32
int tpgTemReps = 0
int tpgFreeReps = 0
int tpgTemInc = 0
int tpgFreeInc = 0
int tpgTemChanDelay [18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
int tpgFreeChanDelay [18] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

Detailed Description

Trigger Pattern Generator command-line user interface.

Author:
James Swain -- jswain@slac.stanford.edu

Function Documentation

unsigned _checkBounds unsigned  start,
unsigned  pat_len,
unsigned  repetitions
 

Checks that the requested addition to the buffer does not exceed the boundaries.

Parameters:
start Bit that this pattern begins at
pat_len length of pattern
repetitions Number of times to repeat the pattern in the buffer
Returns:
One of TPG_msgs, TPG_SUCCESS when all is well

void _clrSticky unsigned *  fifo,
unsigned  channel
 

Clears the last bit of channel in fifo.

Parameters:
fifo Array of unsigned representing the Playback FIFO of one COMM I/O board
channel Channel this pattern is destined for

void _setBits unsigned *  fifo,
unsigned  channel,
unsigned  start,
unsigned  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into channel and in buffer indicated by board.

Parameters:
fifo Array of unsigned representing the Playback FIFO of one COMM I/O board
channel Channel this pattern is destined for
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... 32
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth

void _setBitsv unsigned *  fifo,
unsigned  channel,
unsigned  start,
unsigned *  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into channel and in buffer indicated by board.

Parameters:
fifo Array of unsigned representing the Playback FIFO of one COMM I/O board
channel Channel this pattern is destined for
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... (32*1024)-1
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth

void _setSticky unsigned *  fifo,
unsigned  channel
 

Sets the last bit of channel in fifo.

Parameters:
fifo Array of unsigned representing the Playback FIFO of one COMM I/O board
channel Channel this pattern is destined for

void TPGclear TPG this  ) 
 

Sets all the buffers to 0.

Parameters:
this TPG structure to clear

void TPGclearBuf TPG this,
unsigned  bufferId
 

Sets the buffer indicated by bufferId to 0.

Parameters:
this TPG structure containing buffer to clear
bufferId ID of the buffer to clear

unsigned TPGclrCNOsticky TPG this,
unsigned  free_id
 

Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGclrTEMsticky TPG this,
unsigned  tem_id,
unsigned  trg
 

Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

Parameters:
this TPG structure being modified
tem_id TEM being targeted (gives channel range), 0 ... 3
trg TEM trg being targeted, (gives channel number), 0 ... 3
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGclrVETOsticky TPG this,
unsigned  free_id,
unsigned  veto_id
 

Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
veto_id VETO bit being targeted, (gives channel number), 0 ... 17
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGdump TPG this,
unsigned  boardId,
unsigned  start,
unsigned  len
 

Print out the bit patterns in the requested board.

Parameters:
this TPG struct to use to configure COMM I/O boards
boardId 0 ... N_TPG_BOARDS
start Line of the buffer to start dump
len Number of lines to dump
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

unsigned TPGdumpCNO TPG this,
unsigned  start,
unsigned  len
 

Print out the bit patterns in the CNO buffer.

Parameters:
this TPG struct to use to configure COMM I/O boards
start Line of the buffer to start dump
len Number of lines to dump
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGdumpFREE TPG this,
unsigned  free_id,
unsigned  start,
unsigned  len
 

Print out the bit patterns in the free board.

Parameters:
this TPG struct to use to configure COMM I/O boards
free_id FREE ID
start Line of the buffer to start dump
len Number of lines to dump
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGdumpTEM TPG this,
unsigned  start,
unsigned  len
 

Print out the bit patterns in the TEM buffer.

Parameters:
this TPG struct to use to configure COMM I/O boards
start Line of the buffer to start dump
len Number of lines to dump
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGload TPG this,
unsigned char *  clkDelay
 

Use Programmed I/O to fill the COMM board FIFOs.

Parameters:
this TPG struct to use to configure COMM I/O boards
clkDelay Argument no longer used, left for backward compatibility. Use TPGDelay().
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

int TPGmsgInit void   ) 
 

Starts a simple printf MSG processor.

Returns:
0 on success, -1 on failure

TPG * TPGnew unsigned *  brdAddr  ) 
 

Calls calloc to allocate memory for the struct and associated buffers then sets the buffer pointers to the correct offsets.

Parameters:
brdAddr Null terminated array of GTB (GEM Test Board) addresses
Returns:
Ptr to a new TPG structure containing ptrs to buffers and gnatHandles

unsigned TPGsetCNO TPG this,
unsigned  free_id,
unsigned  start,
unsigned  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... 32
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetCNOsticky TPG this,
unsigned  free_id
 

Clears the last bit of the buffer, which will "stick" on the COMM I/O outputs.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetCNOv TPG this,
unsigned  free_id,
unsigned  start,
unsigned *  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... (32*1024) - 1
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetExtTrig TPG this,
unsigned  start,
unsigned  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the external trigger buffer.

Parameters:
this TPG structure being modified
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... 32
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetExtTrigv TPG this,
unsigned  start,
unsigned *  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the external trigger buffer.

Parameters:
this TPG structure being modified
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... (32*1024) - 1
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetTEM TPG this,
unsigned  tem_id,
unsigned  trg,
unsigned  start,
unsigned  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the channel and buffer indicated by tem_id and trg.

Parameters:
this TPG structure being modified
tem_id TEM being targeted (gives channel range), 0 ... 3
trg TEM trg being targeted, (gives channel number), 0 ... 3
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... 32
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetTEMsticky TPG this,
unsigned  tem_id,
unsigned  trg
 

Sets the last bit of the buffer, which will "stick" on the COMM I/O outputs.

Parameters:
this TPG structure being modified
tem_id TEM being targeted (gives channel range), 0 ... 3
trg TEM trg being targeted, (gives channel number), 0 ... 3
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetTEMv TPG this,
unsigned  tem_id,
unsigned  trg,
unsigned  start,
unsigned *  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the channel and buffer indicated by tem_id and trg.

Parameters:
this TPG structure being modified
tem_id TEM being targeted (gives channel range), 0 ... 3
trg TEM trg being targeted, (gives channel number), 0 ... 3
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... (32*1024) - 1
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetVETO TPG this,
unsigned  free_id,
unsigned  veto_id,
unsigned  start,
unsigned  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
veto_id VETO bit being targeted, (gives channel number), 0 ... 17
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... 32
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetVETOsticky TPG this,
unsigned  free_id,
unsigned  veto_id
 

Sets the last bit of the buffer, which will "stick" on the COMM I/O outputs.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
veto_id VETO bit being targeted, (gives channel number), 0 ... 17
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGsetVETOv TPG this,
unsigned  free_id,
unsigned  veto_id,
unsigned  start,
unsigned *  pattern,
unsigned  pat_len,
unsigned  repetitions
 

Places the pat_len LSBs of pattern into the channel and buffer indicated by free_id and veto_id.

Parameters:
this TPG structure being modified
free_id FREE being targeted (gives tgt board), 0 ... 3
veto_id VETO bit being targeted, (gives channel number), 0 ... 17
start Start bit for the pattern, 0 ... (32*1024)-1
pattern Up to 32 bit pattern to use (LSB first)
pat_len Pattern length 1 ... (32*1024) - 1
repetitions Number of times to repeat the same pattern on this channel, use 0 to request as many reps as will fit in remaining FIFO depth
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.

Here is the call graph for this function:

unsigned TPGstart TPG this  ) 
 

Start the playback.

Parameters:
this TPG struct to use to configure COMM I/O boards
Returns:
One of TPG_msgs, TPG_SUCCESS if all goes well.


Variable Documentation

unsigned TPG_BUSY = 0
 

Channel number for the TEM BUSY signal

unsigned TPG_CALHI = 2
 

Channel number for the TEM CAL HE signal

unsigned TPG_CALLO = 3
 

Channel number for the TEM CAL LE signal

unsigned TPG_LASTWORD = TPG_BUFFER_DEPTH - sizeof(unsigned)
 

first bit of last word of a pattern

unsigned TPG_N_TRG = 4
 

Total number of TEM triggers

unsigned TPG_TIAR = 1
 

Channel number for the TEM Three-in-a-row signal


Generated on Thu Jun 23 22:00:44 2005 by doxygen 1.3.3