Main Page   Interface   Data Structures   File List   Data Fields   Globals  

BFM.c File Reference

Balloon Flight (VME) Modules, Implementation. More...

#include <bstring.h>
#include "BBC/SPIN.h"
#include "BTU/TEM_ids.h"
#include "BTU/TEM.h"
#include "BFU/BFM.h"

Data Structures

struct  _BFM_dsc
 Captures all information about the TEMs and FPGAs. More...

struct  _BFM_opStatus
 Captures the status of a given operation. More...


Typedefs

typedef enum _BFM_opId BFM_opId
 Typedef for enum _BFM_opId.

typedef enum _BFM_opMsk BFM_opMsk
 Typedef for enum _BFM_opMsk.

typedef _BFM_opStatus BFM_opStatus
 Typedef for struct _BFM_opStatus.


Enumerations

enum  _BFM_opId {
  BFM_C_OP_TEMS_ADD = 0,
  BFM_C_OP_FPGAS_ADD = 1,
  BFM_C_OP_TEMS_PROBE = 2,
  BFM_C_OP_TEMS_PRESET = 3,
  BFM_C_OP_FPGAS_LOAD = 4,
  BFM_C_OP_TEMS_RESET = 5,
  BFM_C_OP_TEMS_READY = 6,
  BFM_C_OP_CNT = 7
}
 Enumerates the list of possible operations. More...

enum  _BFM_opMsk {
  BFM_M_OP_TEMS_ADD = (1 << BFM_C_OP_TEMS_ADD),
  BFM_M_OP_FPGAS_ADD = (1 << BFM_C_OP_FPGAS_ADD),
  BFM_M_OP_TEMS_PROBE = (1 << BFM_C_OP_TEMS_PROBE),
  BFM_M_OP_TEMS_PRESET = (1 << BFM_C_OP_TEMS_PRESET),
  BFM_M_OP_FPGAS_LOAD = (1 << BFM_C_OP_FPGAS_LOAD),
  BFM_M_OP_TEMS_RESET = (1 << BFM_C_OP_TEMS_RESET),
  BFM_M_OP_TEMS_READY = (1 << BFM_C_OP_TEMS_READY),
  BFM_M_OP_MSK = (1 << BFM_C_OP_CNT) - 1
}
 Enumerates the list of possible operations as masks.


Functions

unsigned int setStatus (BFM_opStatus *opSts, BFM_opId opId, BFM_opTarget opTarget, unsigned int targetSet, unsigned int failures)
 Internal routine to complete the operations status block. More...

BFM_dscBFM_get (void)
 Returns a piece of memory that either is the TEM data base or can be filled in to be the TEM data base. More...

unsigned int BFM_describe (BFM_dsc *bfm, unsigned int requestTems, const unsigned vmeAdrs[TEM_C_CNT], const struct _TEM_temDsc *const temDscs[TEM_C_CNT], const struct _FPGA_ttcHdr *const fpgaTtcs[TEM_C_FPGA_CNT], const struct _TEM_fpgaDsc *const fpgaDscs[TEM_C_FPGA_CNT])
 Workhorse routine to describe the properties of a collection TEMs/FPGAs. More...

unsigned int BFM_initialize (BFM_dsc *bfm)
 Initializes the TEMs making them ready for use. More...

unsigned int BFM_opsAttempted (const BFM_dsc *bfm)
 Returns a bit mask of all operations attempted on any TEM/FPGA. More...

unsigned int BFM_opErrors (const BFM_dsc *bfm)
 Returns a bit mask of all failed operations attempted on any TEM/FPGA. More...

void BFM_opReport (const BFM_dsc *bfm, unsigned int operations, BFM_opReporter reporter, void *parameter)
 Reports on the success or failure of various operations. More...

unsigned int BFM_fpgasL1tCounterClear (BFM_dsc *bfm, unsigned int fpgaList)
 Clears the L1t event counter. More...

unsigned int BFM_fpgasL1tTimerClear (BFM_dsc *bfm, unsigned int fpgaList)
 Clears the L1t timer. More...

unsigned int BFM_fpgasBistWrite (const BFM_dsc *bfm, unsigned int fpgaList, unsigned int bistList)
 Writes the self test mode for the specified list of fpgas. More...

unsigned int BFM_fpgasHfullClrWrite (const BFM_dsc *bfm, unsigned int fpgaList, unsigned int hfullList)
 Writes the FIFO Half Full Auto Clear mode for the specified list of FPGAS. More...

unsigned int BFM_fpgasHfullEnbWrite (const BFM_dsc *bfm, unsigned int fpgaList, unsigned int hfullList)
 Writes the FIFO Half Full Enable mode for the specified list of fpgas. More...

unsigned int BFM_fpgasLoaded (const BFM_dsc *bfm)
 Returns a list of the FPGAs that were successfully loaded. More...

unsigned int BFM_fpgasLogicClear (BFM_dsc *bfm, unsigned int fpgaList)
 Toggles the FPGA Logic Clear bit for the specified list of FPGAs. More...

unsigned int BFM_fpgasTemsGet (const BFM_dsc *bfm, unsigned int fpgaList)
 Returns the list of the TEMSs associated with the specified list of FPGAs. More...

unsigned int BFM_temsFpgasGet (const BFM_dsc *bfm, unsigned int temList)
 Returns the list of the FPGAs associated with the specified list of TEMs. More...

const struct _TEM_fpga * BFM_fpgas (const BFM_dsc *bfm)
 Returns a pointer to the FPGA database. More...

unsigned int BFM_fpgasRdoBsyMinMaxWrite (const BFM_dsc *bfm, unsigned int fpgaList, unsigned int modeList)
 Writes the readout min/max mode for the specified list of fpgas. More...

unsigned int BFM_fpgasRdoModeWrite (const BFM_dsc *bfm, unsigned int fpgaList, unsigned int modeList)
 Writes the readout mode for the specified list of fpgas. More...

const struct _TEM_tem * BFM_tems (const BFM_dsc *bfm)
 Returns a pointer to the TEM database. More...

unsigned int BFM_temsFifosReset (const BFM_dsc *bfm, unsigned int temList)
 Resets all the FIFOs on a TEM. More...

unsigned int BFM_temsPresent (const BFM_dsc *bfm)
 Returns a list of the TEMs that are present in the system. More...

unsigned int BFM_temsReadied (const BFM_dsc *bfm)
 Returns a list of the TEMs that are in the ready state. More...

unsigned int BFM_temsScopeBitClear (BFM_dsc *bfm, unsigned int temList)
 Clears the scope bit on the specified TEMs. More...

unsigned int BFM_temsScopeBitSet (BFM_dsc *bfm, unsigned int temList)
 Sets the scope bit on the specified TEMs. More...

unsigned int BFM_temsScopeBitToggle (BFM_dsc *bfm, unsigned int temList)
 Toggles the scope bit on the specified TEMs. More...

const unsigned int * BFM_vmeAdrsByTem (const BFM_dsc *bfm)
 Returns an array, indexed by TEM, of the TEMs VME addresses. More...

const unsigned int * BFM_vmeAdrsByFpga (const BFM_dsc *bfm)
 Returns an array, indexed by FPGA, of the TEMs VME addresses. More...

volatile unsigned int *const * BFM_lclAdrsByTem (const BFM_dsc *bfm)
 Returns an array, indexed by TEM, of the TEMs local addresses. More...

volatile unsigned int *const * BFM_lclAdrsByFpga (const BFM_dsc *bfm)
 Returns an array, indexed by FPGA, of the TEMs local addresses. More...


Detailed Description

Balloon Flight (VME) Modules, Implementation.

Author:
JJRussell - russell@slac.stanford.edu

Enumeration Type Documentation

enum _BFM_opId
 

Enumerates the list of possible operations.

Enumeration values:
BFM_C_OP_TEMS_ADD  Add a TEM to the list of known TEMs
BFM_C_OP_FPGAS_ADD  Add a FPGA to the list of known FPGAs
BFM_C_OP_TEMS_PROBE  Probe VME bus to check TEM presence
BFM_C_OP_TEMS_PRESET  TEMs => known state, before load
BFM_C_OP_FPGAS_LOAD  Loads the FPGAs on a TEM board
BFM_C_OP_TEMS_RESET  TEMS => nto a known state, after load
BFM_C_OP_TEMS_READY  Readies a TEM for use
BFM_C_OP_CNT  A count of the total number of ops


Function Documentation

unsigned int BFM_describe BFM_dsc   bfm,
unsigned int    requestTems,
const unsigned    vmeAdrs[TEM_C_CNT],
const struct _TEM_temDsc *const    temDscs[TEM_C_CNT],
const struct _FPGA_ttcHdr *const    fpgaTtcs[TEM_C_FPGA_CNT],
const struct _TEM_fpgaDsc *const    fpgaDscs[TEM_C_FPGA_CNT]
 

Workhorse routine to describe the properties of a collection TEMs/FPGAs.

Parameters:
bfm:  Handle of the Balloon Flight Tems description.
requestTems:  The list of requested TEMs, specified as a bit mask.
vmeAdrs:  An array of the VME addresses associated with each TEM.
temDscs:  An array of pointers to the TEM descriptors.
fpgaTtcs:  An array of pointers to the FPGA download data. This data must be in the form of TTC data structures.
fpgaDscs:  An array of pointers to the FPGA descriptors.
Returns:
The list of TEMs which where improperly described. Currently this can only be due to an internal inconsistency, ie a programming bug.
Describes an instance the Balloon Flight Tems (BFM) This routine defines a BFM to be composed of the specified TEMs. The remaining parameters are necessary to fully define the database.

These parameters all are specified as arrays of either TEM_C_CNT or TEM_C_FPGA_CNT. In all cases, if the set requested TEMs does not include a particular TEM, then the information about that TEM or its associated FPGAs need not be specified. In short, if one only wants the CAL, then you only need specify the information relevant for the CAL TEM and its FPGA.

The operations are basically beign. The only operation to actually touch a TEM is a VME bus probe to check on its presence.

const struct _TEM_fpga * BFM_fpgas const BFM_dsc   bfm
 

Returns a pointer to the FPGA database.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
A pointer to the FPGA database.
The return value can be provides assess to the TEM_fpgasXXXX routines.

unsigned int BFM_fpgasBistWrite const BFM_dsc   bfm,
unsigned int    fpgaList,
unsigned int    bistList
 

Writes the self test mode for the specified list of fpgas.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to write the self test
bistList  The value of the self-test bit, expressed as a bit list by fpga.
Returns:
The list of FPGAs which were requested to write, but not supported.

unsigned int BFM_fpgasHfullClrWrite const BFM_dsc   bfm,
unsigned int    fpgaList,
unsigned int    hfullList
 

Writes the FIFO Half Full Auto Clear mode for the specified list of FPGAS.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to write FIFO Half Full Auto Clear mode.
bistList  The value of the FIFO Half Full Enable Auto Clear mode bit, expressed as a bit list by FPGA.
Returns:
The list of FPGAs which were requested to write, but not supported.

unsigned int BFM_fpgasHfullEnbWrite const BFM_dsc   bfm,
unsigned int    fpgaList,
unsigned int    hfullList
 

Writes the FIFO Half Full Enable mode for the specified list of fpgas.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to write FIFO Half Full Enable mode.
bistList  The value of the FIFO Half Full Enable mode bit, expressed as a bit list by FPGA.
Returns:
The list of FPGAs which were requested to write, but not supported.

unsigned int BFM_fpgasL1tCounterClear BFM_dsc   bfm,
unsigned int    fpgaList
 

Clears the L1t event counter.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to clear.

unsigned int BFM_fpgasL1tTimerClear BFM_dsc   bfm,
unsigned int    fpgaList
 

Clears the L1t timer.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to clear.

unsigned int BFM_fpgasLoaded const BFM_dsc   bfm
 

Returns a list of the FPGAs that were successfully loaded.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
A list, expressed as a bit mask, of that FPGAs were successfully loaded.

unsigned int BFM_fpgasLogicClear BFM_dsc   bfm,
unsigned int    fpgaList
 

Toggles the FPGA Logic Clear bit for the specified list of FPGAs.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of FPGAs.
Returns:
A list, expressed as a bit mask, of FPGAs which failed to clear.

unsigned int BFM_fpgasRdoBsyMinMaxWrite const BFM_dsc   bfm,
unsigned int    fpgaList,
unsigned int    modeList
 

Writes the readout min/max mode for the specified list of fpgas.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to write the readout min/max mode
modeList  The value of the readout, expressed as a bit list by FPGA.
Returns:
The list of FPGAs which where requested to set, but not supported.

unsigned int BFM_fpgasRdoModeWrite const BFM_dsc   bfm,
unsigned int    fpgaList,
unsigned int    modeList
 

Writes the readout mode for the specified list of fpgas.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of fpgas to write the readout mode
modeList  The value of the readout, expressed as a bit list by FPGA.
Returns:
The list of FPGAs which where requested to set, but not supported.

unsigned int BFM_fpgasTemsGet const BFM_dsc   bfm,
unsigned int    fpgaList
 

Returns the list of the TEMSs associated with the specified list of FPGAs.

Parameters:
bfm  The description of the Balloon Flight Tems.
fpgaList  The list of FPGAs.
Returns:
A list, expressed as a bit mask, of TEMs associated with the specified list of FPGAs.

BFM_dsc * BFM_get void   
 

Returns a piece of memory that either is the TEM data base or can be filled in to be the TEM data base.

Returns:
A handle to the TEM data base.
Given that there is only one set of TEMs/FPGAs, there is only one copy of the database needs to be maintained. Typical usage would be to first do an BFM_get, then BFG_describe. After initialization, one can either hold on to the handle or fetch it back with another call to BFG_get(). Note, however, that all routines require this handle as the first argument.

unsigned int BFM_initialize BFM_dsc   bfm
 

Initializes the TEMs making them ready for use.

Parameters:
bfm  The description of the Balloon Flight TEMs. This was previously setup with a call to BFM_describe.
Returns:
0 if successful, a bit mask representing any phase of the setup that failed. See below for further details.
Initializes the BFM. All TEMs and FPGAs are prepared for data taking. This involves downloading the correct FPGA code and preparing the TEMs themselves for data taking. It does NOT include setting up any detector specific FPGA registers nor does it involve setting up the detector front-end hardware.

Each TEM is initialized as far as possible. If a failure occurs, the return value is marked with a bit noting a failure of some TEM at this phase. Said another way, the return value is really a summary error mask, indicating which operations had at least on failure associated with it. The user can then interrogate the BFM for specifics about exactly what failed at each phase. (See BFM_opReport for instance).

volatile unsigned int BFM_lclAdrsByFpga const BFM_dsc   bfm
 

Returns an array, indexed by FPGA, of the TEMs local addresses.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
An array, indexed by FPGA, of the TEMs local addresses

volatile unsigned int BFM_lclAdrsByTem const BFM_dsc   bfm
 

Returns an array, indexed by TEM, of the TEMs local addresses.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
An array, indexed by TEM, of the TEMs local addresses

unsigned int BFM_opErrors const BFM_dsc   bfm
 

Returns a bit mask of all failed operations attempted on any TEM/FPGA.

Parameters:
bfm  The description of the Balloon Flight TEMs.
Returns:
A bit mask of all failed operations attempted on any TEM/FPGA.
This is meant to provide a quick piece of summary error information. If An error has occurred, BFM_opReport() can be used to pin down the exact error.

void BFM_opReport const BFM_dsc   bfm,
unsigned int    operations,
BFM_opReporter    reporter,
void *    parameter
 

Reports on the success or failure of various operations.

Parameters:
bfm  The description of the Balloon Flight Tems.
operations  The list of operations, expressed as a bit mask, to report on.
reporter  A user supplied callback routine to handle the status reporting. This routine is called back once per operation. See the description of the BFM_opeReporter for details on the callback usage
parameter  A context parameter passed transparently through to the user provided callback routine.
This routine allows the user to report the status of all TEMs and FPGAs in a manner consistent with his application, ie, it does not just dump the output to the screen. See BFM_opPrint for an example of how to code a callback routine.

unsigned int BFM_opsAttempted const BFM_dsc   bfm
 

Returns a bit mask of all operations attempted on any TEM/FPGA.

Parameters:
bfm  The description of the Balloon Flight TEMs.
Returns:
A bit mask of all operations attempted on any TEM/FPGA.

const struct _TEM_fpga * BFM_tems const BFM_dsc   bfm
 

Returns a pointer to the TEM database.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
A pointer to the TEM database.
The return value can be provides assess to the TEM_temsXXXX routines.

unsigned int BFM_temsFifosReset const BFM_dsc   bfm,
unsigned int    temList
 

Resets all the FIFOs on a TEM.

Parameters:
bfm  The description of the Balloon Flight Tems.
temList  The list to TEMs to reset the FIFOs on.
Returns:
A list, expressed as a bit mask, of that TEMs that failed to have there FIFOs reset.

unsigned int BFM_temsFpgasGet const BFM_dsc   bfm,
unsigned int    temList
 

Returns the list of the FPGAs associated with the specified list of TEMs.

Parameters:
bfm  The description of the Balloon Flight Tems.
temList  The list of TEMs.
Returns:
A list, expressed as a bit mask, of FPGAs associated with the specified list of TEMs.

unsigned int BFM_temsPresent const BFM_dsc   bfm
 

Returns a list of the TEMs that are present in the system.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
A list, expressed as a bit mask, of that TEMs that are present in the system.
This routine can be used, after BFM_describe() has been called, to learn which TEMs are physically present on the VME bus.

unsigned int BFM_temsReadied const BFM_dsc   bfm
 

Returns a list of the TEMs that are in the ready state.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
A list, expressed as a bit mask, of that TEMs that are in the ready state. This routine can be used, after BFM_initialize() has been called, to learn which TEMs are in the ready state. TEMs in the ready state have had their FPGAs successfully loaded and are ready to be setup for data taking.

unsigned int BFM_temsScopeBitClear BFM_dsc   bfm,
unsigned int    temList
 

Clears the scope bit on the specified TEMs.

Parameters:
bfm  The description of the Balloon Flight Tems.
temList  The list to TEMs to clear the scope bit on.
Returns:
A list, expressed as a bit mask, of that TEMs that failed to have their scope bit cleared.

unsigned int BFM_temsScopeBitSet BFM_dsc   bfm,
unsigned int    temList
 

Sets the scope bit on the specified TEMs.

Parameters:
bfm  The description of the Balloon Flight Tems.
temList  The list to TEMs to clear the scope bit on.
Returns:
A list, expressed as a bit mask, of that TEMs that failed to have their scope bit set.

unsigned int BFM_temsScopeBitToggle BFM_dsc   bfm,
unsigned int    temList
 

Toggles the scope bit on the specified TEMs.

Parameters:
bfm  The description of the Balloon Flight Tems.
temList  The list to TEMs to toggle the scope bit on.
Returns:
A list, expressed as a bit mask, of that TEMs that failed to have their scope bit toggled.

unsigned int BFM_vmeAdrsByFpga const BFM_dsc   bfm
 

Returns an array, indexed by FPGA, of the TEMs VME addresses.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
An array, indexed by FPGA, of the TEMs VME addresses

unsigned int BFM_vmeAdrsByTem const BFM_dsc   bfm
 

Returns an array, indexed by TEM, of the TEMs VME addresses.

Parameters:
bfm  The description of the Balloon Flight Tems.
Returns:
An array, indexed by TEM, of the TEMs VME addresses

unsigned int setStatus BFM_opStatus   opSts,
BFM_opId    opId,
BFM_opTarget    opTarget,
unsigned int    successes,
unsigned int    failures
[inline, static]
 

Internal routine to complete the operations status block.

Parameters:
opSts  The operation status block to complete.
opId  The operation id number.
opTarget  The target type of the operation (TEM or FPGA).
targetSet  The target set, expressed as a bit mask, that the operation was attempted on.
failures  The target set, expressed as a bit mask, that the operations failed on.
Returns:
Either 0, if no failures, or the operation id expressed as a bit mask. This is used to generate summary information.


Generated on Tue Mar 5 17:55:29 2002 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002