\hypertarget{gCAL_8c}{
\section{g\-CAL.c File Reference}
\label{gCAL_8c}\index{gCAL.c@{gCAL.c}}
}
Implements command/response for the off board calorimeter subsystem.  


{\tt \#include $<$string.h$>$}\par
{\tt \#include \char`\"{}gt\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}g\-CAL\_\-p.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{gCAL_8c_a0}{set\-Acc\-Desc\-CAL} (\hyperlink{struct__gtem}{gtem\-Handle} gt, unsigned short gcrc\-Addr, unsigned short gcfe\-Target, unsigned short gcfe\-Addr, unsigned short func, unsigned short reg, \hyperlink{union__accDescCAL}{acc\-Desc\-CAL} $\ast$ad)
\begin{CompactList}\small\item\em initializes an access descriptor for either a GCRC or GCFE \item\end{CompactList}\item 
void \hyperlink{gCAL_8c_a1}{pack\-Payload\-CAL} (\hyperlink{struct__gtem}{gtem\-Handle} gt, unsigned int cal\-Cmd\-Header, unsigned int cal\-AD, unsigned int value, unsigned int $\ast$payload)
\begin{CompactList}\small\item\em Packs the cal\-Cmd\-Header, cal\-AD and value into the 64-bit payload. \item\end{CompactList}\item 
int \hyperlink{gCAL_8c_a2}{\_\-CALcmd} (\hyperlink{struct__gtem}{gtem\-Handle} gt, unsigned short tem\-Addr, unsigned short gccc\-Addr, unsigned short gcrc\-Addr, unsigned short ext, unsigned short gcfe\-Addr, unsigned short func, unsigned short opcode)
\begin{CompactList}\small\item\em Sends a dataless command to the destination. \item\end{CompactList}\item 
int \hyperlink{gCAL_8c_a3}{\_\-CALload} (\hyperlink{struct__gtem}{gtem\-Handle} gt, unsigned short tem\-Addr, unsigned short gccc\-Addr, unsigned short gcrc\-Addr, unsigned short ext, unsigned short gcfe\-Addr, unsigned short func, unsigned short reg, unsigned short value)
\begin{CompactList}\small\item\em Loads a register with value. \item\end{CompactList}\item 
int \hyperlink{gCAL_8c_a4}{\_\-CALread} (\hyperlink{struct__gtem}{gtem\-Handle} gt, unsigned short tem\-Addr, unsigned short gccc\-Addr, unsigned short gcrc\-Addr, unsigned short ext, unsigned short gcfe\-Addr, unsigned short func, unsigned short reg, unsigned short $\ast$val)
\begin{CompactList}\small\item\em Reads a register returing value in {\em val\/}. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Implements command/response for the off board calorimeter subsystem. 

\begin{Desc}
\item[Author:]Curt Brune -- \href{mailto:curt@slac.stanford.edu}{\tt curt@slac.stanford.edu} \end{Desc}


\subsection{Function Documentation}
\hypertarget{gCAL_8c_a2}{
\index{gCAL.c@{g\-CAL.c}!_CALcmd@{\_\-CALcmd}}
\index{_CALcmd@{\_\-CALcmd}!gCAL.c@{g\-CAL.c}}
\subsubsection[\_\-CALcmd]{\setlength{\rightskip}{0pt plus 5cm}int \_\-CALcmd (\hyperlink{struct__gtem}{gtem\-Handle} {\em gt}, unsigned short {\em tem\-Addr}, unsigned short {\em gccc\-Addr}, unsigned short {\em gcrc\-Addr}, unsigned short {\em ext}, unsigned short {\em gcfe\-Addr}, unsigned short {\em func}, unsigned short {\em opcode})}}
\label{gCAL_8c_a2}


Sends a dataless command to the destination. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em gt}]gtem\-Handle for TEM \item[{\em tem\-Addr}]TEM address \item[{\em gccc\-Addr}]GCCC address \item[{\em gcrc\-Addr}]GCRC address \item[{\em ext}]set for GCFE access \item[{\em gcfe\-Addr}]GCFE address \item[{\em func}]function code to send \item[{\em opcode}]opcode of command to send \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]G\_\-OK on success \end{Desc}
\hypertarget{gCAL_8c_a3}{
\index{gCAL.c@{g\-CAL.c}!_CALload@{\_\-CALload}}
\index{_CALload@{\_\-CALload}!gCAL.c@{g\-CAL.c}}
\subsubsection[\_\-CALload]{\setlength{\rightskip}{0pt plus 5cm}int \_\-CALload (\hyperlink{struct__gtem}{gtem\-Handle} {\em gt}, unsigned short {\em tem\-Addr}, unsigned short {\em gccc\-Addr}, unsigned short {\em gcrc\-Addr}, unsigned short {\em ext}, unsigned short {\em gcfe\-Addr}, unsigned short {\em func}, unsigned short {\em reg}, unsigned short {\em value})}}
\label{gCAL_8c_a3}


Loads a register with value. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em gt}]gtem\-Handle for TEM \item[{\em tem\-Addr}]TEM address \item[{\em gccc\-Addr}]GCCC address \item[{\em gcrc\-Addr}]GCRC address \item[{\em ext}]set for GCFE access \item[{\em gcfe\-Addr}]GCFE address \item[{\em func}]function code to send \item[{\em reg}]register of GCRC to load \item[{\em value}]16-bit value to load into CAL register \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]G\_\-OK on success\end{Desc}
Loads the GCRC/GCFE register specified by {\em gcrc\-Addr\/}, {\em gcfe\-Addr\/}, {\em reg\/} with {\em value\/}. \hypertarget{gCAL_8c_a4}{
\index{gCAL.c@{g\-CAL.c}!_CALread@{\_\-CALread}}
\index{_CALread@{\_\-CALread}!gCAL.c@{g\-CAL.c}}
\subsubsection[\_\-CALread]{\setlength{\rightskip}{0pt plus 5cm}int \_\-CALread (\hyperlink{struct__gtem}{gtem\-Handle} {\em gt}, unsigned short {\em tem\-Addr}, unsigned short {\em gccc\-Addr}, unsigned short {\em gcrc\-Addr}, unsigned short {\em ext}, unsigned short {\em gcfe\-Addr}, unsigned short {\em func}, unsigned short {\em reg}, unsigned short $\ast$ {\em val})}}
\label{gCAL_8c_a4}


Reads a register returing value in {\em val\/}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em gt}]gtem\-Handle for TEM \item[{\em tem\-Addr}]tem\-Addrination of command \item[{\em gccc\-Addr}]GCCC address \item[{\em gcrc\-Addr}]GCRC address \item[{\em ext}]set for GCFE access \item[{\em gcfe\-Addr}]GCFE address \item[{\em func}]function code to send \item[{\em reg}]register of GCRC to read \item[{\em val}]pointer to storage to hold the response of the read command \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]G\_\-OK on success\end{Desc}
Reads the GCRC/GCFE register specified by {\em gcrc\-Addr\/}, {\em gcfe\-Addr\/}, {\em reg\/}.

The following error codes are returned:

\begin{itemize}
\item GERR\_\-LATP\_\-HEADER\_\-PARITY \item GERR\_\-LATP\_\-CELL\_\-PARITY \item GERR\_\-LATP\_\-TRUNCATE \item GCAL\_\-ERR\_\-SUMMARY \item GCAL\_\-ERR\_\-PARITY \end{itemize}
\hypertarget{gCAL_8c_a1}{
\index{gCAL.c@{g\-CAL.c}!packPayloadCAL@{packPayloadCAL}}
\index{packPayloadCAL@{packPayloadCAL}!gCAL.c@{g\-CAL.c}}
\subsubsection[packPayloadCAL]{\setlength{\rightskip}{0pt plus 5cm}void pack\-Payload\-CAL (\hyperlink{struct__gtem}{gtem\-Handle} {\em gt}, unsigned int {\em cal\-Cmd\-Header}, unsigned int {\em cal\-AD}, unsigned int {\em value}, unsigned int $\ast$ {\em payload})}}
\label{gCAL_8c_a1}


Packs the cal\-Cmd\-Header, cal\-AD and value into the 64-bit payload. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em gt}]gtem\-Handle for TEM \item[{\em cal\-Cmd\-Header}]32-bit CAL command header word \item[{\em cal\-AD}]32-bit CAL access descriptor word \item[{\em value}]32-bit value to load into CAL register \item[{\em payload}]pointer to 64-bits of pre-allocated storage \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]void\end{Desc}
Packs the bits of {\em cal\-Cmd\-Header\/}, {\em cal\-AD\/} and {\em value\/} into the 64-bits pointed to by {\em payload\/}. The packing is specific to \char`\"{}off board\char`\"{} registers for the GCRC and GCFE. \hypertarget{gCAL_8c_a0}{
\index{gCAL.c@{g\-CAL.c}!setAccDescCAL@{setAccDescCAL}}
\index{setAccDescCAL@{setAccDescCAL}!gCAL.c@{g\-CAL.c}}
\subsubsection[setAccDescCAL]{\setlength{\rightskip}{0pt plus 5cm}static void set\-Acc\-Desc\-CAL (\hyperlink{struct__gtem}{gtem\-Handle} {\em gt}, unsigned short {\em gcrc\-Addr}, unsigned short {\em ext}, unsigned short {\em gcfe\-Addr}, unsigned short {\em func}, unsigned short {\em reg}, \hyperlink{union__accDescCAL}{acc\-Desc\-CAL} $\ast$ {\em ad})\hspace{0.3cm}{\tt  \mbox{[}static\mbox{]}}}}
\label{gCAL_8c_a0}


initializes an access descriptor for either a GCRC or GCFE 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em gt}]gtem\-Handle for TEM \item[{\em ad}]pointer to CAL access descriptor \item[{\em ext}]set for GCFE commands \item[{\em gcrc\-Addr}]GCRC address \item[{\em gcfe\-Addr}]GCFE address \item[{\em func}]CAL fucntion code \item[{\em reg}]register of CAL object \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]G\_\-OK on void\end{Desc}
Sets a calorimeter access descriptor, destined for either GCRC or GCFE. 