\hypertarget{gACD_8c}{
\section{g\-ACD.c File Reference}
\label{gACD_8c}\index{gACD.c@{gACD.c}}
}
Implements command/response for off board ACD modules.  


{\tt \#include $<$string.h$>$}\par
{\tt \#include \char`\"{}ga\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}g\-AEM\_\-p.h\char`\"{}}\par
{\tt \#include \char`\"{}g\-ACD\_\-p.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{gACD_8c_a0}{set\-AEMext\-AD} (\hyperlink{struct__gaem}{gaem\-Handle} ga, unsigned short type, unsigned short addr, unsigned short func, unsigned short opcode, unsigned short value, \hyperlink{union__aemExtAD}{aem\-Ext\-AD} $\ast$ad)
\item 
void \hyperlink{gACD_8c_a1}{pack\-Payload\-ACD} (\hyperlink{struct__gaem}{gaem\-Handle} ga, \hyperlink{union__cmdHeaderLATp}{cmd\-Header\-LATp} ch, \hyperlink{union__aemExtAD}{aem\-Ext\-AD} ad, unsigned int $\ast$payload)
\begin{CompactList}\small\item\em Packs {\em ch\/} and {\em ad\/} into the 64-bit payload. \item\end{CompactList}\item 
int \hyperlink{gACD_8c_a2}{\_\-\_\-ACDcmd} (\hyperlink{struct__gaem}{gaem\-Handle} ga, unsigned short type, unsigned short garc\-Addr, unsigned short func\-Block, unsigned short func, unsigned short func\-Opcode, unsigned int value)
\begin{CompactList}\small\item\em Generic routine for sending response-less commands to GARC. \item\end{CompactList}\item 
int \hyperlink{gACD_8c_a3}{\_\-\_\-ACDread} (\hyperlink{struct__gaem}{gaem\-Handle} ga, unsigned short type, unsigned short garc\-Addr, unsigned short func\-Block, unsigned short func, unsigned short func\-Opcode, unsigned int $\ast$value)
\begin{CompactList}\small\item\em Generic routine for reading GARC/GAFE registers. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Implements command/response for off board ACD modules. 

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


\subsection{Function Documentation}
\hypertarget{gACD_8c_a2}{
\index{gACD.c@{g\-ACD.c}!__ACDcmd@{\_\-\_\-ACDcmd}}
\index{__ACDcmd@{\_\-\_\-ACDcmd}!gACD.c@{g\-ACD.c}}
\subsubsection[\_\-\_\-ACDcmd]{\setlength{\rightskip}{0pt plus 5cm}int \_\-\_\-ACDcmd (\hyperlink{struct__gaem}{gaem\-Handle} {\em ga}, unsigned short {\em type}, unsigned short {\em garc\-Addr}, unsigned short {\em func\-Block}, unsigned short {\em func}, unsigned short {\em func\-Opcode}, unsigned int {\em value})}}
\label{gACD_8c_a2}


Generic routine for sending response-less commands to GARC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ga}]gaem\-Handle for AEM \item[{\em type}]single bit indicating GARC/GAFE \item[{\em garc\-Addr}]GARC address of command \item[{\em func\-Block}]GARC function block code \item[{\em func}]command/response function code \item[{\em func\-Opcode}]fucntion opcode for GARC function block \item[{\em value}]16-bit value to load into GARC register \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]G\_\-OK on success\end{Desc}
Common subroutine for sending dataless commands and loading GARC registers. The {\em func\/} parameter indicates a \char`\"{}dataless\char`\"{} or \char`\"{}load\char`\"{} command. \hypertarget{gACD_8c_a3}{
\index{gACD.c@{g\-ACD.c}!__ACDread@{\_\-\_\-ACDread}}
\index{__ACDread@{\_\-\_\-ACDread}!gACD.c@{g\-ACD.c}}
\subsubsection[\_\-\_\-ACDread]{\setlength{\rightskip}{0pt plus 5cm}int \_\-\_\-ACDread (\hyperlink{struct__gaem}{gaem\-Handle} {\em ga}, unsigned short {\em type}, unsigned short {\em garc\-Addr}, unsigned short {\em func\-Block}, unsigned short {\em func}, unsigned short {\em func\-Opcode}, unsigned int $\ast$ {\em value})}}
\label{gACD_8c_a3}


Generic routine for reading GARC/GAFE registers. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ga}]gaem\-Handle for AEM \item[{\em type}]single bit indicating GARC/GAFE \item[{\em garc\-Addr}]GARC address of command \item[{\em func\-Block}]GARC function block code \item[{\em func}]command/response function code \item[{\em func\-Opcode}]fucntion opcode for GARC function block \item[{\em value}]pointer to hold 16-bit register value \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]G\_\-OK on success\end{Desc}
Common subroutine for reading GARC/GAFE registers. \hypertarget{gACD_8c_a1}{
\index{gACD.c@{g\-ACD.c}!packPayloadACD@{packPayloadACD}}
\index{packPayloadACD@{packPayloadACD}!gACD.c@{g\-ACD.c}}
\subsubsection[packPayloadACD]{\setlength{\rightskip}{0pt plus 5cm}void pack\-Payload\-ACD (\hyperlink{struct__gaem}{gaem\-Handle} {\em ga}, \hyperlink{union__cmdHeaderLATp}{cmd\-Header\-LATp} {\em ch}, \hyperlink{union__aemExtAD}{aem\-Ext\-AD} {\em ad}, unsigned int $\ast$ {\em payload})}}
\label{gACD_8c_a1}


Packs {\em ch\/} and {\em ad\/} into the 64-bit payload. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ga}]gaem\-Handle for AEM \item[{\em ch}]9-bit command header word (in MSB) \item[{\em ad}]32-bit external access descriptor word \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 ch\/} and {\em ad\/} into the 64-bits pointed to by {\em payload\/}. The packing is specific to external \char`\"{}off board\char`\"{} registers for the GARC and GAFE.

The format of the bits goes as:

9 bit AEM command header + 1 start bit + 32 bit ext AD + 1 command parity bit \hypertarget{gACD_8c_a0}{
\index{gACD.c@{g\-ACD.c}!setAEMextAD@{setAEMextAD}}
\index{setAEMextAD@{setAEMextAD}!gACD.c@{g\-ACD.c}}
\subsubsection[setAEMextAD]{\setlength{\rightskip}{0pt plus 5cm}void set\-AEMext\-AD (\hyperlink{struct__gaem}{gaem\-Handle} {\em ga}, unsigned short {\em type}, unsigned short {\em addr}, unsigned short {\em func}, unsigned short {\em opcode}, unsigned short {\em value}, \hyperlink{union__aemExtAD}{aem\-Ext\-AD} $\ast$ {\em ad})}}
\label{gACD_8c_a0}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em ga}]GAEM driver handle previously allocated \item[{\em type}]single bit indicating GARC/GAFE \item[{\em addr}]GARC function block or GAFE address \item[{\em func}]read, write or dataless command \item[{\em opcode}]GARC function code or GAFE register \item[{\em value}]16-bit payload for write commands \item[{\em ad}]pointer to storage for access descriptor \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]void \end{Desc}
