\hypertarget{BFR_8c}{
\section{BFR.c File Reference}
\label{BFR_8c}\index{BFR.c@{BFR.c}}
}
Balloon Flight Readout, Implementation. 


{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$sem\-Lib.h$>$}\par
{\tt \#include \char`\"{}BBC/BUG.h\char`\"{}}\par
{\tt \#include \char`\"{}BBC/BSWP.ih\char`\"{}}\par
{\tt \#include \char`\"{}BBC/IVTE.ih\char`\"{}}\par
{\tt \#include \char`\"{}BBC/RNG.h\char`\"{}}\par
{\tt \#include \char`\"{}BBC/SPIN.ih\char`\"{}}\par
{\tt \#include \char`\"{}BVME/VME.h\char`\"{}}\par
{\tt \#include \char`\"{}BVME/UNIV.h\char`\"{}}\par
{\tt \#include \char`\"{}BVME/UNIV\_\-print.h\char`\"{}}\par
{\tt \#include \char`\"{}BFU/BFA.h\char`\"{}}\par
{\tt \#include \char`\"{}BFU/BFR.h\char`\"{}}\par
{\tt \#include \char`\"{}BFU/BFU\_\-file\-Dsc.h\char`\"{}}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{struct__BFR__lst}{\_\-BFR\_\-lst}
\begin{CompactList}\small\item\em List head for the various readout types.\item\end{CompactList}\item 
struct \hyperlink{struct__BFR__rod}{\_\-BFR\_\-rod}
\begin{CompactList}\small\item\em Describes and controls an object to be readout.\item\end{CompactList}\item 
struct \hyperlink{struct__BFR__roi}{\_\-BFR\_\-roi}
\begin{CompactList}\small\item\em Defines a readout image.\item\end{CompactList}\item 
struct \hyperlink{struct__BFR__rop}{\_\-BFR\_\-rop}
\begin{CompactList}\small\item\em Defines a readout program.\item\end{CompactList}\item 
struct \hyperlink{struct__BFR__ros}{\_\-BFR\_\-ros}
\begin{CompactList}\small\item\em Describes the synchronization structure.\item\end{CompactList}\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{BFR_8c_a0}{
\index{BFR_K_RO_MAX@{BFR\_\-K\_\-RO\_\-MAX}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_K_RO_MAX@{BFR\_\-K\_\-RO\_\-MAX}}
\#define \hyperlink{BFR_8c_a0}{BFR\_\-K\_\-RO\_\-MAX}\ 32}
\label{BFR_8c_a0}

\begin{CompactList}\small\item\em The maximum number of types of readout.\item\end{CompactList}\item 
\hypertarget{BFR_8c_a1}{
\index{BFR_K_MAX_FIFO_CNT@{BFR\_\-K\_\-MAX\_\-FIFO\_\-CNT}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_K_MAX_FIFO_CNT@{BFR\_\-K\_\-MAX\_\-FIFO\_\-CNT}}
\#define \hyperlink{BFR_8c_a1}{BFR\_\-K\_\-MAX\_\-FIFO\_\-CNT}\ 4096}
\label{BFR_8c_a1}

\begin{CompactList}\small\item\em Maximum number events in the FIFO.\item\end{CompactList}\item 
\#define \hyperlink{BFR_8c_a2}{DCTL\_\-SUP}
\begin{CompactList}\small\item\em DMA control word for SUPERVISOR mode BLT.\item\end{CompactList}\item 
\#define \hyperlink{BFR_8c_a3}{DCTL\_\-USR}
\begin{CompactList}\small\item\em DMA control word for USER mode BLT.\item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef \hyperlink{struct__BFR__rod}{\_\-BFR\_\-rod} \hyperlink{BFR_8c_a4}{BFR\_\-rod}
\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFR__rod}{\_\-BFR\_\-rod}.\item\end{CompactList}\item 
\hypertarget{BFR_8c_a5}{
\index{BFR_ros@{BFR\_\-ros}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_ros@{BFR\_\-ros}}
typedef \hyperlink{struct__BFR__ros}{\_\-BFR\_\-ros} \hyperlink{BFR_8c_a5}{BFR\_\-ros}}
\label{BFR_8c_a5}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFR__ros}{\_\-BFR\_\-ros}.\item\end{CompactList}\item 
\hypertarget{BFR_8c_a6}{
\index{BFR_lst@{BFR\_\-lst}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_lst@{BFR\_\-lst}}
typedef \hyperlink{struct__BFR__lst}{\_\-BFR\_\-lst} \hyperlink{BFR_8c_a6}{BFR\_\-lst}}
\label{BFR_8c_a6}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFR__lst}{\_\-BFR\_\-lst}.\item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{BFR_8c_a7}{dma\_\-service} (\hyperlink{BFR_8c_a5}{BFR\_\-ros} $\ast$dma\_\-synch)
\begin{CompactList}\small\item\em Services a DMA completion interrupt.\item\end{CompactList}\item 
int \hyperlink{BFR_8c_a8}{cnt\_\-bits} (unsigned int word)
\begin{CompactList}\small\item\em Simple internal routine to count the bits in a 32 bit word.\item\end{CompactList}\item 
int \hyperlink{BFR_8c_a9}{get\_\-input\_\-position} (const \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} $\ast$input\_\-order, unsigned int ro\_\-list, \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} which)
\begin{CompactList}\small\item\em Returns a number representing which input record this corresponds to.\item\end{CompactList}\item 
UNIV\_\-dcp $\ast$ \hyperlink{BFR_8c_a10}{bind1\_\-indirect} (UNIV\_\-dcp $\ast$dcpp, const \hyperlink{BFR_8c_a4}{BFR\_\-rod} $\ast$rod, int nread)
\begin{CompactList}\small\item\em Completes the binding of indirect readout descriptors.\item\end{CompactList}\item 
UNIV\_\-dcp $\ast$ \hyperlink{BFR_8c_a11}{bind1\_\-direct} (UNIV\_\-dcp $\ast$dcpp, \hyperlink{BFU__fileDsc_8h_a2}{BFU\_\-file\-Dsc} $\ast$dsc, \hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi, const \hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$rop, int nread)
\begin{CompactList}\small\item\em Binds all the readouts.\item\end{CompactList}\item 
\hypertarget{BFR_8c_a12}{
\index{BFR_rop_sizeof@{BFR\_\-rop\_\-sizeof}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_rop_sizeof@{BFR\_\-rop\_\-sizeof}}
int {\bf BFR\_\-rop\_\-sizeof} (int rod\_\-max)}
\label{BFR_8c_a12}

\item 
\hypertarget{BFR_8c_a13}{
\index{BFR_rop_get@{BFR\_\-rop\_\-get}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_rop_get@{BFR\_\-rop\_\-get}}
\hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$ {\bf BFR\_\-rop\_\-get} (int rod\_\-max)}
\label{BFR_8c_a13}

\item 
\hypertarget{BFR_8c_a14}{
\index{BFR_rop_init@{BFR\_\-rop\_\-init}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_rop_init@{BFR\_\-rop\_\-init}}
\hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$ {\bf BFR\_\-rop\_\-init} (\hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$rop, unsigned int hdr\_\-id, int rod\_\-max, unsigned int tlr\_\-id, int sum\_\-cnt, int sum\_\-size)}
\label{BFR_8c_a14}

\item 
\hypertarget{BFR_8c_a15}{
\index{BFR_rod_add@{BFR\_\-rod\_\-add}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_rod_add@{BFR\_\-rod\_\-add}}
int {\bf BFR\_\-rod\_\-add} (\hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$rop, int input, \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} rid, unsigned int id, int size, unsigned int data\_\-fifo, unsigned int size\_\-fifo, \hyperlink{BFR_8h_a3}{BFR\_\-rd\-Rtn} rd\-Rtn, void $\ast$rd\-Prm)}
\label{BFR_8c_a15}

\item 
\hypertarget{BFR_8c_a16}{
\index{BFR_rop_configure@{BFR\_\-rop\_\-configure}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_rop_configure@{BFR\_\-rop\_\-configure}}
const \hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$ {\bf BFR\_\-rop\_\-configure} (unsigned int hdr\_\-id, unsigned int ro\_\-list, unsigned int tlr\_\-id, int sum\_\-cnt, int sum\_\-size, const \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} $\ast$output\_\-order, const \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} $\ast$input\_\-order, const unsigned int $\ast$ivte\_\-ids, const int $\ast$data\_\-sizes, const unsigned int $\ast$tem\_\-vmes, const int $\ast$data\_\-fifos, const int $\ast$size\_\-fifos, const \hyperlink{BFR_8h_a3}{BFR\_\-rd\-Rtn} $\ast$rd\-Rtns, void $\ast$const $\ast$rd\-Prms)}
\label{BFR_8c_a16}

\item 
\hypertarget{BFR_8c_a17}{
\index{BFR_rop_print@{BFR\_\-rop\_\-print}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_rop_print@{BFR\_\-rop\_\-print}}
void {\bf BFR\_\-rop\_\-print} (const \hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$rop)}
\label{BFR_8c_a17}

\item 
\hypertarget{BFR_8c_a18}{
\index{BFR_roi_construct@{BFR\_\-roi\_\-construct}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_construct@{BFR\_\-roi\_\-construct}}
\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$ {\bf BFR\_\-roi\_\-construct} (const \hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$rop)}
\label{BFR_8c_a18}

\item 
\hypertarget{BFR_8c_a19}{
\index{BFR_roi_bind0@{BFR\_\-roi\_\-bind0}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_bind0@{BFR\_\-roi\_\-bind0}}
int {\bf BFR\_\-roi\_\-bind0} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi, int nread, unsigned int sequence)}
\label{BFR_8c_a19}

\item 
\hypertarget{BFR_8c_a20}{
\index{BFR_roi_read0@{BFR\_\-roi\_\-read0}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_read0@{BFR\_\-roi\_\-read0}}
int {\bf BFR\_\-roi\_\-read0} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi)}
\label{BFR_8c_a20}

\item 
\hypertarget{BFR_8c_a21}{
\index{BFR_roi_pend0@{BFR\_\-roi\_\-pend0}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_pend0@{BFR\_\-roi\_\-pend0}}
int {\bf BFR\_\-roi\_\-pend0} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi)}
\label{BFR_8c_a21}

\item 
\hypertarget{BFR_8c_a22}{
\index{BFR_roi_bind1@{BFR\_\-roi\_\-bind1}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_bind1@{BFR\_\-roi\_\-bind1}}
int {\bf BFR\_\-roi\_\-bind1} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi, struct \hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb} $\ast$acb)}
\label{BFR_8c_a22}

\item 
\hypertarget{BFR_8c_a23}{
\index{BFR_roi_read1@{BFR\_\-roi\_\-read1}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_read1@{BFR\_\-roi\_\-read1}}
int {\bf BFR\_\-roi\_\-read1} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi)}
\label{BFR_8c_a23}

\item 
\hypertarget{BFR_8c_a24}{
\index{BFR_roi_pend1@{BFR\_\-roi\_\-pend1}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_pend1@{BFR\_\-roi\_\-pend1}}
int {\bf BFR\_\-roi\_\-pend1} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi)}
\label{BFR_8c_a24}

\item 
\hypertarget{BFR_8c_a25}{
\index{BFR_roi_copy1@{BFR\_\-roi\_\-copy1}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_copy1@{BFR\_\-roi\_\-copy1}}
int {\bf BFR\_\-roi\_\-copy1} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi, struct \hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb} $\ast$acb)}
\label{BFR_8c_a25}

\item 
\hypertarget{BFR_8c_a26}{
\index{BFR_roi_finish@{BFR\_\-roi\_\-finish}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_finish@{BFR\_\-roi\_\-finish}}
int {\bf BFR\_\-roi\_\-finish} (\hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi, struct \hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb} $\ast$acb)}
\label{BFR_8c_a26}

\item 
\hypertarget{BFR_8c_a27}{
\index{BFR_roi_evtDscGet@{BFR\_\-roi\_\-evtDscGet}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_evtDscGet@{BFR\_\-roi\_\-evt\-Dsc\-Get}}
\hyperlink{struct__BFU__fileDsc}{\_\-BFU\_\-file\-Dsc} $\ast$ {\bf BFR\_\-roi\_\-evt\-Dsc\-Get} (const \hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi)}
\label{BFR_8c_a27}

\item 
\hypertarget{BFR_8c_a28}{
\index{BFR_roi_print@{BFR\_\-roi\_\-print}!BFR.c@{BFR.c}}\index{BFR.c@{BFR.c}!BFR_roi_print@{BFR\_\-roi\_\-print}}
void {\bf BFR\_\-roi\_\-print} (const \hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$roi)}
\label{BFR_8c_a28}

\end{CompactItemize}


\subsection{Detailed Description}
Balloon Flight Readout, Implementation.



\begin{Desc}
\item[Author: ]\par
JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}


\subsection{Define Documentation}
\hypertarget{BFR_8c_a2}{
\index{BFR.c@{BFR.c}!DCTL_SUP@{DCTL\_\-SUP}}
\index{DCTL_SUP@{DCTL\_\-SUP}!BFR.c@{BFR.c}}
\subsubsection[DCTL\_\-SUP]{\setlength{\rightskip}{0pt plus 5cm}\#define DCTL\_\-SUP}}
\label{BFR_8c_a2}


{\bf Value:}

\footnotesize\begin{verbatim}(UNIV_K_DCTL_VDW_32      | \
                     UNIV_K_DCTL_VAS_A32     | \
                     UNIV_K_DCTL_PGM_DATA    | \
                     UNIV_K_DCTL_SUPER_SUPER | \
                     UNIV_K_DCTL_VCT_BLT     | \
                     UNIV_K_DCTL_LD64EN )\end{verbatim}\normalsize 
DMA control word for SUPERVISOR mode BLT.

\hypertarget{BFR_8c_a3}{
\index{BFR.c@{BFR.c}!DCTL_USR@{DCTL\_\-USR}}
\index{DCTL_USR@{DCTL\_\-USR}!BFR.c@{BFR.c}}
\subsubsection[DCTL\_\-USR]{\setlength{\rightskip}{0pt plus 5cm}\#define DCTL\_\-USR}}
\label{BFR_8c_a3}


{\bf Value:}

\footnotesize\begin{verbatim}(UNIV_K_DCTL_VDW_32      | \
                     UNIV_K_DCTL_VAS_A32     | \
                     UNIV_K_DCTL_PGM_DATA    | \
                     UNIV_K_DCTL_SUPER_USER  | \
                     UNIV_K_DCTL_VCT_BLT     | \
                     UNIV_K_DCTL_LD64EN )\end{verbatim}\normalsize 
DMA control word for USER mode BLT.



\subsection{Typedef Documentation}
\hypertarget{BFR_8c_a4}{
\index{BFR.c@{BFR.c}!BFR_rod@{BFR\_\-rod}}
\index{BFR_rod@{BFR\_\-rod}!BFR.c@{BFR.c}}
\subsubsection[BFR\_\-rod]{\setlength{\rightskip}{0pt plus 5cm}BFR\_\-rod}}
\label{BFR_8c_a4}


Typedef for struct \hyperlink{struct__BFR__rod}{\_\-BFR\_\-rod}.



 Readouts come in a various types. The are classified by whether they are direct or indirect, fixed or variable and USER or SUPERVISOR VME assess mode.

The {\em direct} or {\em indirect} refers to whether the data from a FIFO can be read direcly into the readout memory or whether it first needs to be read into a holding array and then copied into the readout memory. This occurs, for example, if the data from the FIFO needs to be processed. The L1T FIFO is an example of this. Because its FIFO is only byte-wide, 4 bytes must be packed into a 32-bit quantity before it is placed into the readout memory.

The {\em fixed} or {\em variable} refers to whether the data from a FIFO is fixed length or variable length. All variable length data must have a supporting FIFO which holds the actual length of each event. Currently only the TKR data is variable length.

Finally a FIFO may be assessed either in VME USER mode or VME SUPERVISOR mode. Currently only the L1T FIFO is assessed in VME SUPERVISOR mode. 

\subsection{Function Documentation}
\hypertarget{BFR_8c_a11}{
\index{BFR.c@{BFR.c}!bind1_direct@{bind1\_\-direct}}
\index{bind1_direct@{bind1\_\-direct}!BFR.c@{BFR.c}}
\subsubsection[bind1\_\-direct]{\setlength{\rightskip}{0pt plus 5cm}UNIV\_\-dcp $\ast$ bind1\_\-direct (UNIV\_\-dcp $\ast$ {\em dcpp}, \hyperlink{BFU__fileDsc_8h_a2}{BFU\_\-file\-Dsc} $\ast$ {\em dsc}, \hyperlink{BFR_8h_a5}{BFR\_\-roi} $\ast$ {\em roi}, const \hyperlink{BFR_8h_a4}{BFR\_\-rop} $\ast$ {\em rop}, int {\em nread})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{BFR_8c_a11}


Binds all the readouts.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
dcpp}]Pointer to the next DMA command packet to be filled in. \item[{\em 
dsc}]Pointer to the event descriptor which describes these events. The memory must have already been allocated. \item[{\em 
roi}]Pointer to the readout image. This contains various parameters which are relevant to this particular readout sequence. \item[{\em 
rop}]Pointer to the readout program. This contains various parameters which only depend only on the source of the readouts (ie which things are being readout), not one the destination, (ie where they are being readout to). \item[{\em 
nread}]The number of events to read out \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Pointer to the next DMA packet to be filled in.\end{Desc}
Binds all the readouts. Two operations occur in this routine.



\footnotesize\begin{verbatim}
     1. The header/directories for all data read are constructed. 
     2. The DMA packets for all directly read records (both the fixed
        direct and the variable direct) are completed.

        NOTE: Direct readouts are those which have their data read directly
              into the output data structure records.
   \end{verbatim}\normalsize 
 \hypertarget{BFR_8c_a10}{
\index{BFR.c@{BFR.c}!bind1_indirect@{bind1\_\-indirect}}
\index{bind1_indirect@{bind1\_\-indirect}!BFR.c@{BFR.c}}
\subsubsection[bind1\_\-indirect]{\setlength{\rightskip}{0pt plus 5cm}UNIV\_\-dcp $\ast$ bind1\_\-indirect (UNIV\_\-dcp $\ast$ {\em dcpp}, const \hyperlink{BFR_8c_a4}{BFR\_\-rod} $\ast$ {\em rod}, int {\em nread})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{BFR_8c_a10}


Completes the binding of indirect readout descriptors.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
dcpp}]Pointer to the array of DMA command packets \item[{\em 
rod}]Pointer to the first element in the linked list of indirect readout descriptors. \item[{\em 
nread}]The number of events to be read out. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Pointer to the next DMA command packet to be filled.\end{Desc}
Completes the binding of indirect readout descriptors. These readout descriptors cannot be read directly into the output data record, but must be first read into a piece of memory, then copied to their final resting place. This is generally because the data fifo is not 32 bits wide and the data needs to be compacted from the readin width into 32 bit wide quantities.

Two fields of the dma command packets must be modified



\footnotesize\begin{verbatim}
       1. The transfer count, since this depends on the number of events
          to be read.
       2. The DONE and TERMINATION bits must be cleared.
   \end{verbatim}\normalsize 


The data itself is read into a fixed location, stored with the readout image. \hypertarget{BFR_8c_a8}{
\index{BFR.c@{BFR.c}!cnt_bits@{cnt\_\-bits}}
\index{cnt_bits@{cnt\_\-bits}!BFR.c@{BFR.c}}
\subsubsection[cnt\_\-bits]{\setlength{\rightskip}{0pt plus 5cm}int cnt\_\-bits (unsigned int {\em word})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{BFR_8c_a8}


Simple internal routine to count the bits in a 32 bit word.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
word}]The word to count the bits in. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
The number of set bits in this word\end{Desc}
Simple internal routine to count the bits in a 32 bit word. This is only a convenience routine and is not meant for high-performance usage. \hypertarget{BFR_8c_a7}{
\index{BFR.c@{BFR.c}!dma_service@{dma\_\-service}}
\index{dma_service@{dma\_\-service}!BFR.c@{BFR.c}}
\subsubsection[dma\_\-service]{\setlength{\rightskip}{0pt plus 5cm}void dma\_\-service (\hyperlink{BFR_8c_a5}{BFR\_\-ros} $\ast$ {\em dma\_\-synch})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{BFR_8c_a7}


Services a DMA completion interrupt.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
dma\_\-synch}]The DMA synchronization structure\end{description}
\end{Desc}
This routine handles the interrupts from the UNIVERSE II Tundra. This routine does very little, counting the number of interrupts received, purely for diagnostic reasons, and recording the reason for the interrupt. \hypertarget{BFR_8c_a9}{
\index{BFR.c@{BFR.c}!get_input_position@{get\_\-input\_\-position}}
\index{get_input_position@{get\_\-input\_\-position}!BFR.c@{BFR.c}}
\subsubsection[get\_\-input\_\-position]{\setlength{\rightskip}{0pt plus 5cm}int get\_\-input\_\-position (const \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} $\ast$ {\em input\_\-order}, unsigned int {\em ro\_\-list}, \hyperlink{BFR__ids_8h_a0}{BFR\_\-id} {\em target\_\-id})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{BFR_8c_a9}


Returns a number representing which input record this corresponds to.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
input\_\-order}]An array of BFR readout ids, giving the desired readout order. \item[{\em 
ro\_\-list}]The list of all active BFR readout ids. \item[{\em 
target\_\-id}]The target BFR readout id. This is the one we wish to know its relative order in the readout list. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
An integer representing the relative order of the target BFR readout id in the readout list.\end{Desc}
Returns a number representing which input record this corresponds to. A list, in the desired input order is scanned. This list would be fine to use as is, if all records types where to be included. However, since not all records types are always readout, the numbers must be compressed to form a dense list. See the example in the code. 