Table of Contents Previous Chapter
fepCtl performs high-level control functions within the FEPs, namely the interception of science commands from the BEP and their subsequent execution. Low level commands (memory read, write, and execute) are handled within the FEP IO Library (36-53223 B) routines (see Section 38.0) and are essentially transparent to the command controller and science modules.
The FEP Controller provides the following features:
FIGURE 170. FEP controller subroutines and their calling hierarchy
The FEP Controller module contains the main FEP command processing loop, along with various external functions for frequently used FEP operations. Its stack contains a single copy of the FEPparm structure, whose address is passed to all FEP modules and functions. Thus if, for instance, fepCtl calls fepSciTimed to conduct a timed exposure science run, and fepSciTimed itself calls fepHandleCmd to process an incoming BEP command, it is fepSciTimed's responsibility to ensure that it passes to fepHandleCmd the same pointer to FEPparm that it was itself given.
A brief description of the functions within this module is as follows:
FEPparm
structure on its stack and passes its address to all lower level science routines which can therefore use it as a substitute for static
storage. By convention, this address parameter is called fp in all FEP modules. After calling FIOinit and fepInit, the code cycles endlessly over calls to FIOgetNextCmd. A TRUE
return value signifies that a science-mode command has been received from the BEP, and the appropriate subroutine is called. The BEP itself will wait for the FEP to reply before sending another command. Finally, whether or not a command is processed, a call to FIOtouchWatchdog resets the watchdog timer, and the loop repeats.
FEPbiasRec
type code in fp->tp, and calls the appropriate bias function.
BEP_FEP_CMD_FIDPIX
command is received from the FEP. It removes any previously defined fiducial pixels, saves the addresses of new ones in fp->fidpix and purposely trashes the corresponding bits of the bias parity plane.
VSYNC
signal. It is global since it is only called from other FEP science modules.
FEPbiasRec
, FEPstatus
, FEPexpRec
, and FEPexpEndRec
structures within the FEPparm
structure.
Table 38 lists those FEPparm fields that are referenced within the FEP command controller module. They are defined in fepCtl.h and always addressed by a pointer parameter named fp:TABLE 38. Global FEPparm fields used by the Command Controller
----------------------------------------------------------------------------------------- FEPparm Variable Description Substructure Name-----------------------------------------------------------------------------------------
Latest command received from BEP, and the FEP's reply bepCmd
args
Command/reply contentslen
Command/reply length in fullwordstype
Command/reply type code (see fepBep.h)Bias calibration parameters
br
bias0[4]
Average overclock values of each output node for the first data frame used for bias calibrationbiassum
Checksum of bias0 values, initialized to 0xffffffff unless valid bias parameters are extracted from I-cacheex
FEPexpRec exposure record
expnum Current exposure frame
timestamp Current frame's arrival time
type
Initialized to FEP_EXPOSURE_REC
FEPexpEndRec end-of-exposure record exend
type
Initialized to FEP_EXPOSURE_END_REC
FEP status reported to BEP fepStatus
biasflag
TRUE
if a valid bias map exists, elseFALSE
mode
Initialized to zeroparityplane
Address of the start of the bias parity planebias0[4] Initialized to bias0[4], if bias valid, otherwise zeroes
Flag bits defined in fepCtl.h
flags
FP_SUSPEND
BEP has sent BEP_FEP_CMD_SUSPENDFP_TERMINATE
BEP has sent BEP_FEP_CMD_STOPExposure parameter block
tp
btype
Initialized to FEP_NO_BIAS (see fepBep.h)ncols
Number of pixels per output nodequadcode
Output node clocking mode (see fepBep.h)type
Initialized to FEP_NO_PARM (see fepBep.h)fidpix[MAX_FID_PIX]
Row and column addresses of fiducial pixels.
nfidpix
Number of fiducial pixels to be reported in timed-exposure event detecting modes, set by the most recent call to fepCreateFidPix.
nextexpnum
Next possible frame number to be processed, set by a call to fepEnableNextFrame -----------------------------------------------------------------------------------------
The fepCtl loop receives a positive return code from a call to FIOgetNextCmd, signifying that a command has been received from the BEP and is sitting in the BEP-to-FEP mailbox. The command type is copied to fp->fepStatus.mode and examined to determine the action to be taken, as shown in Table 39.
Parameter loads (BEP_FEP_CMD_PARAM) and status requests (BEP_FEP_CMD_STATUS) are handled entirely within the fepCtl module and have no immediate external consequence. Commands to start science runs (BEP_FEP_CMD_TIMED and BEP_FEP_CMD_CCLK) and bias calibrations (BEP_FEP_CMD_BIAS) cause the corresponding science modules to be invoked. The remaining commands---BEP_FEP_CMD_STOP to terminate a running command, and BEP_FEP_CMD_SUSPEND and BEP_FEP_CMD_RESUME to temporarily suspend and restart a command---have no meaning since no command is running. fepCtl therefore responds by calling fepNackCmd to indicate to the BEP that this was the case.
Note that if fepCtl calls another module to execute the command, it is the responsibility of the called function to make a prompt call to either fepAckCmd or fepNackCmd to tell the BEP whether the command was accepted or rejected.
TABLE 39. FEP responses to BEP commands received in IDLE mode
----------------------------------------------------------------------------------------- Value of fp->bepCmd.type(a) Function Called Description----------------------------------------------------------------------------------------- BEP_FEP_CMD_BIAS fepBias
Start a bias calibration BEP_FEP_CMD_CCLKfepSciCClk
Start a continuously clocked science run BEP_FEP_CMD_FIDPIXfepCreateFidPix
Load zero or more fiducial pixel addresses into fp->fidpix. BEP_FEP_CMD_PARAMfepLoadParm
Load and check a new FEP parameter block BEP_FEP_CMD_RESUMEfepNackCmd
Signal the BEP that the command is inap propriate in IDLE mode BEP_FEP_CMD_STATUSfepHandleCmd
Return the current FEP software status BEP_FEP_CMD_STOPfepNackCmd
Signal the BEP that the command is inap propriate in IDLE mode BEP_FEP_CMD_SUSPENDfepNackCmd
Signal the BEP that the command is inap propriate in IDLE mode BEP_FEP_CMD_TIMEDfepSciTimed
Start a timed exposure science run None of the abovefepNackCmd
Signal the BEP that the command is not understood -----------------------------------------------------------------------------------------
The "high-level" science processing routines---fepSciTimed, fepSciCClk, and their corresponding bias calculation routines, fepTimedBias, and fepCClkBias---should make frequent calls to FIOgetNextCmd to determine whether a command has been received from the BEP. When this function returns TRUE
, it indicates that a high-level command has been received via the BEP-FEP mailbox.(1) The science routine should immediately call fepHandleCmd, which uses the value of fp->bepCmd.type to determine the action to take, as shown in Table 40:
TABLE 40. FEP responses to BEP commands received during a science or bias run
---------------------------------------------------------------------------------------- Value of fp->bepCmd.type Function Called Description---------------------------------------------------------------------------------------- BEP_FEP_CMD_BIAS fepNackCmd
This command is unanticipated while a sci ence or bias run is in progress. BEP_FEP_CMD_CCLKfepNackCmd
This command is unanticipated while a sci ence or bias run is in progress. BEP_FEP_CMD_FIDPIXfepNackCmd
This command is unanticipated while a sci ence or bias run is in progress. BEP_FEP_CMD_PARAMfepNackCmd
This command is unanticipated while a sci ence or bias run is in progress. BEP_FEP_CMD_RESUMEfepAckCmd
Signal that processing is to be resumed by clearing the FP_SUSPEND bit in fp->flags. BEP_FEP_CMD_STATUSFIOwriteCmdReply
CallFIOwriteCmdReply
directly to reply to the BEP, passing as argument the current fp->fepStatus structure. BEP_FEP_CMD_STOPfepAckCmd
Signal that the run is to be terminated by setting the FP_TERMINATE bit in fp- >flags. BEP_FEP_CMD_SUSPENDfepAckCmd
Signal that processing is to be temporarily suspended by setting the FP_SUSPEND bit in fp->flags. The suspension is per formed entirely by the science process. BEP_FEP_CMD_TIMEDfepNackCmd
This command is unanticipated while a sci ence or bias run is in progress. Any other valuefepNackCmd
- ----------------------------------------------------------------------------------------
CMD_EXECUTE_MEM
command to branch to the fepCtl entry point. This function starts out by calling FIOinit to initialize the low-level library functions, and fepInit to initialize fields in fepCtl's automatic FEPparm structure, as shown in Section 40.4.
FEPparm *fp
unsigned *ptr
unsigned wordcnt
FEPparm *fp
FALSE
, it indicates that a command has been received from the BEP, and FIOgetNextCmd will be called to process it. If FIOgetNextCmd returns TRUE
, this was a high-level command and fepHandleCmd is then called to give it further processing. Once any command is processed, fepAppendRingBuf resumes its calls to FIOappendBlock, not returning until all wordcnt words have been copied to the ring buffer.
FEPparm *fp
TABLE 41. Selection of Bias Calibration Function
-------------------------------------------------------------------------------------- fp->tp.type fp->tp.btype Function Comments value value called-------------------------------------------------------------------------------------- FEP_TIMED_PARM_RAW FEP_BIAS_1 fepTimedBias
Start a timed-exposure bias FEP_TIMED_PARM_HIST FEP_BIAS_2 calibration FEP_TIMED_PARM_3x3 FEP_TIMED_PARM_5x5 FEP_NO_BIASfepAckCmd
No bias calibration required OtherfepNackCmd
Unexpected btype value FEP_CCLK_PARM_RAW FEP_BIAS_1fepCClkBias
Start a continuously clocked FEP_CCLK_PARM_1x3 FEP_BIAS_2 bias calibration FEP_NO_BIASfepAckCmd
No bias calibration required OtherfepNackCmd
Unexpected btype value Any other value, including AnyfepNackCmd
Unexpected type value FEP_NO_PARM --------------------------------------------------------------------------------------
FEPparm *fp
FEP_CMD_ERR_PARM_LEN
to the BEP if illegal. It then determines whether the bias map is valid (is fp->fepStatus.biasflag true?). If not, it returns FEP_CMD_ERR_NO_BIAS
to the BEP.
FEP_CMD_NOERR
return code to the BEP.
FEPparm *fp
VSYNC
code. This is done with a call to fioWriteImPulseReg(IPULSE_ARMNXTACQ)
, sandwiched between calls to FIOgetExpInfo
. If the exposure number is found to have changed between these calls, it implies that a VSYNC code was encountered. Since the software has no way of knowing whether the VSYNC was received before or after the pulse register was updated, the call to fioWriteImPulseReg
will be issued a second time, causing a frame to be skipped.
fp->ex.expnum
contains the current value of the exposure counter, fp->ex.timestamp
contains the corresponding latched clock time, and fp->nextexpnum = fp->ex.expnum + 1
.
FEPparm *fp
TRUE
, indicating that a BEP command has been received. The responses are determined by the bepCmd.type value and are listed in Table 40 on page 1145. In each case, a reply is sent to the BEP: usually either positive acknowledgment (fepAckCmd) or negative acknowledgment (fepNackCmd), or, in response to a BEP_FEP_CMD_STATUS request, FIOwriteCmdReply is called to return the contents of fp->fepStatus in the reply argument list.
FIOgetBiasConfig
. If br.biassum
is consistent with the bias0
array, it is assumed that the bias map itself is still usable, so fepStatus.biasflag
is set TRUE
. Otherwise, it is set FALSE
and br.biassum
is initialized to the "impossible" value 0xffffffff
.
TABLE 42. FEPparm variables Initialized by fepInit
----------------------------------------------------------------- Variable Initial Value----------------------------------------------------------------- br.biassum
0xffffffff
unless the value copied from I-cache was consistent with the values of br.bias0[] also copied from I-cache.ex.type
FEP_EXPOSURE_REC
exend.type
FEP_EXPOSURE_END_REC
fepStatus.mode
0
fepStatus.biasflag
TRUE
if br.biassum is valid, otherwise FALSE.fepStatus.parityplane
FIOgetBiasParityPlanePtr() valuefepStatus.bias0[]
br.bias0[] if br.biassum is valid, otherwise zeroes.flags
0
nfidpix
0
tp.type
FEP_NO_PARM -----------------------------------------------------------------
FEPparm *fp
TABLE 43. FEPparm variables that are tested by fepLoadParm
---------------------------------------------- Variable Name Validity Test---------------------------------------------- btype
Any legal fepBiasType valuencols
Even and within the range 2-256noclk
Even and within the range 0-32nrows
Within the range 1-1024quadcode
legal fepQuadCode valuetype
legal fepParmType value ----------------------------------------------
FEPparm *fp
fepCmdRetCode errno
errno
, and (d) calling FIOwriteCmdReply to send the reply back to the BEP. errno
values are tabulated in fepBep.h.
fepQuadCode quadcode
unsigned ncols
TABLE 44. FEP hardware register configuration for CCD output clocking modes
------------------------------------------------------------------------ Value of quadcode FEP Img FEP Address Offset Registers Control Register Offset0 Offset1 Offset2 Offset3------------------------------------------------------------------------ FEP_QUAD_ABCD 0x2a 0 2*ncols--1 2*ncols 4*ncols--1 FEP_QUAD_AC
0x00 0 2*ncols - - FEP_QUAD_BD
0x1a 2*ncols--1 4*ncols--1 - - ------------------------------------------------------------------------