Main Page   Interface   Data Structures   File List   Data Fields   Globals  

BFT.c File Reference

Balloon Flight Trigger, Implementation. More...

#include <string.h>
#include <taskLib.h>
#include "BBC/SPIN.h"
#include "BBC/INT.ih"
#include "BTU/TEM_temInt.h"
#include "BFU/BFM.h"
#include "BFU/BFT.h"

Data Structures

struct  _BFT_trg
 Structure to contain information related to triggering. More...


Defines

#define BFT_M_NEVTS_HALF_FULL   0x4000
 The bit mask for the FIFO HALF FULL sticky bit.

#define BFT_M_NEVTS_COUNT   0x07ff
 The bit mask for projecting out the number of events. Each TEM implements a different maximum number, but the width of the nevents field is always 11 bits,.


Functions

int BFT_cyclicTrigger (const BFT_trg *bft, int cyclicCnt, unsigned int cyclicTime, int burstCnt, unsigned int burstTime)
 Issues a burst of triggers at a periodic rate. More...

int BFT_burstTrigger (const BFT_trg *bft, unsigned int trgCnt, unsigned int trgDelay)
 Issues trgCnt triggers at a time interval of trgDelay. More...

int BFT_configure (BFT_trg *bft, const struct _BFM_dsc *bfm, unsigned int temList, unsigned int l1tEnb, unsigned int treqEnb, unsigned int cpuTreqEnb, unsigned int extTreqEnb, unsigned int l1tIn, unsigned int l1tOut, unsigned int hfullEnb, unsigned int hfullClr, unsigned int l1tTmr)
 Configures the triggering environment. \oaram bft The trigger control structure. More...

BFT_trgBFT_get (void)
 Gets a pointer to the trigger control block. More...

int BFT_globalL1tArm (const BFT_trg *bft)
 Arms the global trigger. More...

int BFT_globalL1tDisarm (const BFT_trg *bft)
 Disarms the global trigger. More...

int BFT_globalL1tDisable (const BFT_trg *bft)
 Disables the global trigger. More...

int BFT_globalL1tEnable (const BFT_trg *bft)
 Enables the global trigger. More...

unsigned int BFT_init (BFT_trg *bft, const struct _BFM_dsc *bfm, unsigned int temList)
 Initializes the trigger control structures. More...

unsigned int BFT_temsCpuBsyWrite (const BFT_trg *bft, unsigned int temList, unsigned int cpuBsy)
 Writes the CPU BSY bit for the select TEMs. More...

unsigned int BFT_temsGblL1tArmWrite (const BFT_trg *bft, unsigned int temList, unsigned int gblL1tArm)
 Writes the Global L1t Arm for the selected TEMs. More...

unsigned int BFT_temsGblL1tEnbWrite (const BFT_trg *bft, unsigned int temList, unsigned int gblL1tEnb)
 Writes the Global L1t Enable for the selected TEMs. More...

unsigned int BFT_temsL1tEnbWrite (const BFT_trg *bft, unsigned int temList, unsigned int l1tEnb)
 Writes the L1T ENABLE bit for the select TEMs. More...

unsigned int BFT_temsL1tTmrWrite (const BFT_trg *bft, unsigned int temList, unsigned int l1tTmr)
 Writes the L1T TMR bit for the select TEMs. More...

unsigned int BFT_temsExtTreqEnbWrite (const BFT_trg *bft, unsigned int temList, unsigned int treqEnb)
 Writes the EXT TREQ ENABLE bit for the select TEMs. More...

unsigned int BFT_temsL1tInWrite (const BFT_trg *bft, unsigned int temList, unsigned int l1tIn)
 Writes the L1T IN mask for the select TEMs. More...

unsigned int BFT_temsL1tOutWrite (const BFT_trg *bft, unsigned int temList, unsigned int l1tOut)
 Writes the L1T OUT mask for the select TEMs. More...

unsigned int BFT_temsTreqEnbWrite (const BFT_trg *bft, unsigned int temList, unsigned int treqEnb)
 Writes the TREQ ENABLE bit for the select TEMs. More...

int BFT_trgTemSet (BFT_trg *bft, TEM_temId temId)
 Sets the TEM to do self-triggering. More...

unsigned int BFT_nominate (unsigned int temList, const unsigned int *priorityList)
 Nominates a TEM to be able to generate triggers. More...

int BFT_throttleClr (const BFT_trg *bft, unsigned int temList, const int *thresholds)
 Relieves the FIFO HALF throttling on TEMs that have occupancies that dip below a specified level. More...


Variables

const unsigned int Bft_TriggerPriorityList [TEM_C_CNT]
 Any array of TEM ids, arranged by priority of perference of which TEM to use as the CPU trigger generator. More...


Detailed Description

Balloon Flight Trigger, Implementation.

Author:
JJRussell - russell@slac.stanford.edu

Function Documentation

int BFT_burstTrigger const BFT_trg   bft,
unsigned int    trgCnt,
unsigned int    trgDelay
 

Issues trgCnt triggers at a time interval of trgDelay.

Parameters:
bft  The trigger control structure.
trgCnt  The number of triggers to issue.
trgDelay  The time interval, expressed in PTU's to wait between each trigger.
The burst triggers are issued synchronously in a loop. Contrast this with the BFT_cyclicTrigger which primes a watchdog timer to issue its triggers.

int BFT_configure BFT_trg   bft,
const struct _BFM_dsc   bfm,
unsigned int    temList,
unsigned int    l1tEnb,
unsigned int    treqEnb,
unsigned int    cpuTreqEnb,
unsigned int    extTreqEnb,
unsigned int    l1tIn,
unsigned int    l1tOut,
unsigned int    hFullEnb,
unsigned int    hFullClr,
unsigned int    l1tTmr
 

Configures the triggering environment. \oaram bft The trigger control structure.

Parameters:
bfm  The module description structure.
temList  The list of TEMs to participate in the trigger.
l1tEnb  The list of TEMs which can generate an L1t.
treqEnb  The list of TEMS which will respond to an L1t.
cpuTreqEnb  A list of TEMs eligible to do the self triggering. More than TEM is selected, this routine will pick the 'best' candidate to do the triggering.
extTreqEnb  A list of TEMs to enable the external TREQ input.
l1tIn  The L1t In masks by TEM
l1tOut  The L1t Out masks by TEM
hfullEnb  The list of FPGAs to enable FIFO Half-Full Throttling on.
hfullClr  The list of FPGAs to enable FIFO Half-Full Throttling manual-clear on.
l1tTmr  The list of TEMs to enable the longer L1t timeout on.
Return values:
0, if  successful.
-2, if  list of self-triggering CPUs is inconsistent with whats available.
-3, if  the list is inconsistent with proper triggering.
>0, a  list of TEMs which could not be properly configured.
This is a convenience routine to configure the triggering environment. All the parameters which are lists of TEMs/FPGAs may be specified as -1, in which case a sensible default is chosen.

This routine does some autoconfiguring if inputs are set to -1.

If temList is specified as -1, then the list of READIED TEMs is used.

If cpuTreq = -1, then the best 'candidate' is chosen from the input list. The best candidate is 1. If only one TEM is chosen, then that's it. 2. If multiple TEMs are chosen, its the ACD if available. If the ACD is not available, then error.

If cpuTreq is a list of CPUs, the same rules apply, except in case 2, no error is returned, but no default self trigger is established.

If l1tEnb = -1, then the same rules apply as in the cpuTreq. If l1tEnb is a specific list, then you get what you chose.

int BFT_cyclicTrigger const BFT_trg   bft,
int    cyclicCnt,
unsigned int    cyclicTime,
int    burstCnt,
unsigned int    burstTime
 

Issues a burst of triggers at a periodic rate.

Parameters:
bft  The trigger control structure.
cyclicCnt  The number of bursts to send
cyclicTime  The number of VxWorks ticks to wait between bursts.
burstCnt  The number of triggers in each burst.
burstTime  The time interval, expressed in PTU's to wait between each trigger.
This function issues a burst of burstCnt triggers at a cyclic rate. The number of such bursts is controlled by cyclicCnt. The time between bursts is specified by cyclicTime and the interval between each trigger in the burst is determined by burstTime.

Warning:
Since the burst of triggers is controlled by spinning the CPU for the requisite amount of time, do not make the product of burstCnt burstTime too long, ie > ~1-5msecs.

BFT_trg * BFT_get void   
 

Gets a pointer to the trigger control block.

Returns:
The trigger control block.

unsigned int BFT_globalL1tArm const BFT_trg   bft
 

Arms the global trigger.

Parameters:
bft  The trigger control block.
Return values:
-1, there  is no global trigger 0, the previous state was disabled 1, the previous state was enabled.
If the system is being run is a single TEM mode, it is possible that there is no global trigger, hence the -1 return value. If there is a global trigger, the previous state (before modification) is returned.

unsigned int BFT_globalL1tDisable const BFT_trg   bft
 

Disables the global trigger.

Parameters:
bft  The trigger control block.
Return values:
-1, there  is no global trigger 0, the previous state was disabled 1, the previous state was enabled.
If the system is being run is a single TEM mode, it is possible that there is no global trigger, hence the -1 return value. If there is a global trigger, the previous state (before modification) is returned.

unsigned int BFT_globalL1tDisarm const BFT_trg   bft
 

Disarms the global trigger.

Parameters:
trg  The trigger control block.
Return values:
-1, there  is no global trigger. 0, the previous state was disabled 1, the previous state was enabled.
If the system is being run is a single TEM mode, it is possible that there is no global trigger, hence the -1 return value. If there is a global trigger, the previous state (before modification) is returned.

unsigned int BFT_globalL1tEnable const BFT_trg   bft
 

Enables the global trigger.

Parameters:
bft  The trigger control block.
Return values:
-1, there  is no global trigger 0, the previous state was disabled 1, the previous state was enabled.
If the system is being run is a single TEM mode, it is possible that there is no global trigger, hence the -1 return value. If there is a global trigger, the previous state (before modification) is returned.

unsigned int BFT_init BFT_trg   bft,
const struct _BFM_dsc   bfm,
unsigned int    temList
 

Initializes the trigger control structures.

Parameters:
bfm  The Balloon Flight Module Description
Returns:
List of TEMs that were requested, but were unable to participate in the trigger.
To be eligle to participate in the trigger, the TEM must be included in the configuration and present on the VME bus.

unsigned int BFT_nominate unsigned int    temList,
const unsigned int *    priorityList
 

Nominates a TEM to be able to generate triggers.

Parameters:
temList  The list of candidate TEMs to chose from.
Return values:
TEM_C_INV, if  no good candidate could be found.
The  TEM id, if a good candidate could be found.
Nominates a TEM to be the triggering TEM. The rules are easy. If there is only one TEM, that's the triggering TEM. If there is more than one TEM, then it must be the ACD. In the latter case, if the ACD is not in the configuration, then error.

unsigned int BFT_temsCpuBsyWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    cpuBsy
 

Writes the CPU BSY bit for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask, to write.
cpuBsys  The value to the CPU BSY bits, expressed as a bit mask.
Returns:
The TEMs for which the CPU BSY bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a CPU BSY mode or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temCpuBsySupported(), to get a list of the TEMs which support a CPU BSY. and BFM_temsReadied() to get a list of the TEMs which are active.

unsigned int BFT_temsExtTreqEnbWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    treqEnb
 

Writes the EXT TREQ ENABLE bit for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask, to write.
treqEnb  The value of the EXT TREQ ENABLE bits, expressed as a bit mask.
Returns:
The TEMs for which the EXT TREQ ENABLE bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a EXT TREQ ENABLE mode or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temsExtTreqEnbSupported(), to get a list of the TEMs which support a EXT TREQ ENABLE. and BFM_temsReadied() to get a list of the TEMs which are not active.

unsigned int BFT_temsGblL1tArmWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    gblL1tArm
 

Writes the Global L1t Arm for the selected TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask to write.
gblL1tArm  The value of the Global L1t Arm, expressed as a bit mask.
Returns:
The TEMs for which the GBL L1T ARM bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a GBL L1T ARM or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temsGblL1tArmSupported(), to get a list of the TEMs which support a GBL L1T ARM. and BFM_temsReadied() to get a list of the TEMs which are active.

unsigned int BFT_temsGblL1tEnbWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    gblL1tArm
 

Writes the Global L1t Enable for the selected TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask to write.
gblL1tEnb  The value of the Global L1t Enable, expressed as a bit mask.
Returns:
The TEMs for which the GBL L1T Enable bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a GBL L1T ENB or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temsGblL1tEnbSupported(), to get a list of the TEMs which support a L1T ENABLE. and BFM_temsReadied() to get a list of the TEMs which are active.

unsigned int BFT_temsL1tEnbWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    l1tEnbs
 

Writes the L1T ENABLE bit for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask, to write.
l1tEnbs  The value of the L1T ENABLE bits, expressed as a bit mask.
Returns:
The TEMs for which the L1T ENABLE bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a L1T ENABLE mode or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temsL1tEnbSupported(), to get a list of the TEMs which support a L1T ENABLE. and BFM_temsReadied() to get a list of the TEMs which are active.

unsigned int BFT_temsL1tInWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    l1tIn
 

Writes the L1T IN mask for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask to write.
l1tIn  The value of the L1T IN mask , expressed as a bit mask. 3 bits/per TEM. This limits the number of TEMs that can be supported to 10.
Returns:
The TEMs for which the TREQ ENABLE bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM is incapable of having the L1T IN mask written to it. Currently all TEMs support this functionality, so the only failure mode is if the TEM is not in the ready state. The user may call BFM_temsReadied() to determine this.

unsigned int BFT_temsL1tOutWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    l1tOut
 

Writes the L1T OUT mask for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask to write.
l1tOut  The value of the L1T OUT mask , expressed as a bit mask. 3 bits/per TEM. This limits the number of TEMs that can be supported to 10.
Returns:
The TEMs for which the TREQ OUT mask could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM is incapable of having the L1T OUT mask written to it. Currently all TEMs support this functionality, so the only failure mode is if the TEM is not in the ready state. The user may call BFM_temsReadied() to determine this.

unsigned int BFT_temsL1tTmrWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    l1tTmrs
 

Writes the L1T TMR bit for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask, to write.
l1tEnbs  The value of the L1T TMR bits, expressed as a bit mask.
Returns:
The TEMs for which the L1T TMR bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a L1T TMR mode or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temsL1tTmrSupported(), to get a list of the TEMs which support a L1T TMR. and BFM_temsReadied() to get a list of the TEMs which are not active.

unsigned int BFT_temsTreqEnbWrite const BFT_trg   bft,
unsigned int    temList,
unsigned int    treqEnb
 

Writes the TREQ ENABLE bit for the select TEMs.

Parameters:
bft  The trigger control block.
temList  The set of target TEMs, expressed as a bit mask, to write.
treqEnb  The value of the TREQ ENABLE bits, expressed as a bit mask.
Returns:
The TEMs for which the TREQ ENABLE bit could not be written. This is proper subset of temList.
A non-0 return value indicates either the TEM does not support a TREQ ENABLE mode or it is incapable of returning it. The most likely reason for the latter is that TEM is not loaded. One should call BFT_temsTreqEnbSupported(), to get a list of the TEMs which support a TREQ ENABLE. and BFM_temsReadied() to get a list of the TEMs which are not active.

BFT_throttleClr const BFT_trg   bft,
unsigned int    temList,
const int *    thresholds
 

Relieves the FIFO HALF throttling on TEMs that have occupancies that dip below a specified level.

Parameters:
bfm  The Balloon Flight Module Database handle.
temList  The list of TEMs to consider.
thresholds  The occupancy threshold array.
Returns:
A bit mask of which TEMs have had there half full throttle relieved.
The specified TEMs are scanned to determine which TEMs are in the fifo half full throttle mode. The current event occupancy of each such TEM is then checked against the its corresponding occupancy threshold. If the occupancy is below this threshold, the half full throttle is relieved.

Warning:
Unfortunately one cannot do the correct thing, which is compare against the actual FIFO byte occupancy. One is forced to try to convert occupancy in bytes to occupancy in event count. This conversion is straightforward and unambigious for those subsystems with a fixed length data, one merely multiples NEVTS * sizeof (data) to get a byte count. Howerver for those with variable length data, all one can do is take an estimate. This estimate will likely be based on either the average event size or the maximum. To the extent that these are similar, no real problem, setting the occupancy threshold is not an exacting task. But to the extent that there is a big spread between the two, well, life is hard...

int BFT_trgTemSet BFT_trg   bft,
TEM_temId    temId
 

Sets the TEM to do self-triggering.

Parameters:
bft  The trigger control block.
temId  The ID of the TEM
Return values:
0, if  successful
-1, if  the selected TEM is cannot do the self-triggering.
This routine selects the TEM can which can issue self-triggers. One and only one TEM should be selected to do this task. The only reason for failure is that the selected TEM either not in the system or it is in the proper state. It must have reached the READY state.


Variable Documentation

Bft_TriggerPriorityList
 

Initial value:

{
    TEM_C_LTC,
    TEM_C_CAL,
    TEM_C_TKR,
    TEM_C_ACD
}
Any array of TEM ids, arranged by priority of perference of which TEM to use as the CPU trigger generator.

The first TEM which appears in the list which is also a member of the active list is select as the TEM which generates a CPU trigger


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