\hypertarget{encode_8c}{
\section{encode.c File Reference}
\label{encode_8c}\index{encode.c@{encode.c}}
}
Fill the payload of a command item with a LATp command. 

{\tt \#include \char`\"{}LEM/LEM\_\-msgs.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/encode.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM/encode\_\-macros.h\char`\"{}}\par
{\tt \#include \char`\"{}LEM\_\-DB/schema.h\char`\"{}}\par
{\tt \#include \char`\"{}MSG/MSG\_\-pubdefs.h\char`\"{}}\par
{\tt \#include $<$stdio.h$>$}\par


Include dependency graph for encode.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=275pt]{encode_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
static unsigned \hyperlink{encode_8c_a0}{get\-Wait} (\hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, unsigned addr0, unsigned addr1, unsigned addr2, unsigned addr3, unsigned reg\-Id)
\begin{CompactList}\small\item\em Select the appropriate LEM\_\-DB\_\-server function to call to get the stall/timeout for this register operation. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a1}{LEM\_\-set\_\-load\_\-to} (unsigned timeout)
\begin{CompactList}\small\item\em Retained for backward compatibility. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a2}{LEM\_\-set\_\-read\_\-to} (unsigned timeout)
\begin{CompactList}\small\item\em Retained for backward compatibility. \item\end{CompactList}\item 
unsigned \hyperlink{encode_8c_a3}{LEM\_\-get\_\-load\_\-to} (void)
\begin{CompactList}\small\item\em Retained for backward compatibility. \item\end{CompactList}\item 
unsigned \hyperlink{encode_8c_a4}{LEM\_\-get\_\-read\_\-to} (void)
\begin{CompactList}\small\item\em Retained for backward compatibility. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a5}{TEM\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the common controller block of a TEM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a6}{TIC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the TIC block of a TEM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a7}{CCC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned ccc, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at a CCC. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a8}{CRC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned ccc, unsigned crc, unsigned reg, unsigned short payload)
\begin{CompactList}\small\item\em Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at a CRC. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a9}{CFE\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned ccc, unsigned crc, unsigned cfe, unsigned reg, unsigned short payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at a CFE. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a10}{TCC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned tcc, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at a TCC. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a11}{TRC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned tcc, unsigned trc, unsigned reg, unsigned long long payload)
\begin{CompactList}\small\item\em Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at a TRC. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a12}{TFE\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned tcc, unsigned trc, unsigned tfe, unsigned reg, unsigned long long payload)
\begin{CompactList}\small\item\em Create a LATp Command targeted at a TFE. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a13}{TDC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned tcc, unsigned trc, unsigned tfe, unsigned long long payload)
\begin{CompactList}\small\item\em Create a LATp Command targeted at the DAC register of a TFE. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a14}{AEM\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at the common controller block of the AEM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a15}{AEM\_\-ENV\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned long long payload)
\begin{CompactList}\small\item\em Create a LATp Command targeted at the Environment block of the AEM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a16}{ARC\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned arc, unsigned reg, unsigned short payload)
\begin{CompactList}\small\item\em Create a LATp Command targeted at an ARC. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a17}{AFE\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned arc, unsigned afe, unsigned reg, unsigned short payload)
\begin{CompactList}\small\item\em Create a LATp Command targeted at an AFE. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a18}{PDU\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp Command targeted at the common controller of the PDU. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a19}{PDU\_\-ENV\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the environment block of the PDU. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a20}{CRU\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the CRU. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a21}{EBM\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the common controller block of the EBM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a22}{EBM\_\-STAT\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the statistics block of the EBM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a23}{GEM\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} function, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, \hyperlink{defs_8h_a422}{LEM\_\-REG\_\-BLK} blk, unsigned reg, unsigned payload)
\begin{CompactList}\small\item\em Create a LATp command targeted at the GEM. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a24}{LAM\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr)
\begin{CompactList}\small\item\em Create a look-at-me command. \item\end{CompactList}\item 
void \hyperlink{encode_8c_a25}{LAM\_\-LCB\_\-encode} (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$cmd, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} addr, unsigned value, unsigned enable\_\-mask)
\begin{CompactList}\small\item\em Create a look-at-me command targetted at an LCB. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Fill the payload of a command item with a LATp command. 

\begin{Desc}
\item[Author:]James Swain - \href{mailto:jswain@slac.stanford.edu}{\tt jswain@slac.stanford.edu}\end{Desc}
history 08 Oct 2004: Prepare for first public release. Add history block 12 Nov 2004: Moved definition of default timeout here from LEM/timeout.h 08 Dec 2004: Modified ARC and AFE encode functions (and comment) to use ACD\_\-CMD rather than CMD enums 27 Apr 2005: Doubled the default load stall to 100 (some AFE loads were failing apparently because the stall was too short. 21 Sep 2005: Added the TDC\_\-encode function to handle the TFE DAC register 08 Nov 2005: Outsource the determination of timeout and stall values to LEM\_\-DB. 10 Nov 2005: Restored the LEM\_\-set/get\_\-XXXX\_\-to functions as shells that just issue an error message

\subsection{Function Documentation}
\hypertarget{encode_8c_a14}{
\index{encode.c@{encode.c}!AEM_encode@{AEM\_\-encode}}
\index{AEM_encode@{AEM\_\-encode}!encode.c@{encode.c}}
\subsubsection[AEM\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void AEM\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a14}


Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at the common controller block of the AEM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical address of the AEM \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with the load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a15}{
\index{encode.c@{encode.c}!AEM_ENV_encode@{AEM\_\-ENV\_\-encode}}
\index{AEM_ENV_encode@{AEM\_\-ENV\_\-encode}!encode.c@{encode.c}}
\subsubsection[AEM\_\-ENV\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void AEM\_\-ENV\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned long long {\em payload})}}
\label{encode_8c_a15}


Create a LATp Command targeted at the Environment block of the AEM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the AEM \item[{\em reg}]should be the ID of the target register \item[{\em payload}]64 bits of data to send with the load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a17}{
\index{encode.c@{encode.c}!AFE_encode@{AFE\_\-encode}}
\index{AFE_encode@{AFE\_\-encode}!encode.c@{encode.c}}
\subsubsection[AFE\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void AFE\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em arc}, unsigned {\em afe}, unsigned {\em reg}, unsigned short {\em payload})}}
\label{encode_8c_a17}


Create a LATp Command targeted at an AFE. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of ACD\_\-CMD\_\-READ, ACD\_\-CMD\_\-LOAD, ACD\_\-CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the AEM \item[{\em arc}]should be the ID of the target ARC, or BCAST to broadcast to all the ARCs \item[{\em afe}]should be the ID of the target AFE, or BCAST to broadcast to all the AFEs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]16 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a16}{
\index{encode.c@{encode.c}!ARC_encode@{ARC\_\-encode}}
\index{ARC_encode@{ARC\_\-encode}!encode.c@{encode.c}}
\subsubsection[ARC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void ARC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em arc}, unsigned {\em reg}, unsigned short {\em payload})}}
\label{encode_8c_a16}


Create a LATp Command targeted at an ARC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of ACD\_\-CMD\_\-READ, ACD\_\-CMD\_\-LOAD, ACD\_\-CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the AEM \item[{\em arc}]should be the ID of the target ARC, or BCAST to broadcast to all the ARCs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]16 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a7}{
\index{encode.c@{encode.c}!CCC_encode@{CCC\_\-encode}}
\index{CCC_encode@{CCC\_\-encode}!encode.c@{encode.c}}
\subsubsection[CCC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void CCC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em ccc}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a7}


Create a LATp command targeted at a CCC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em ccc}]should be the ID of the target CCC, or BCAST to broadcast to all CCCs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a9}{
\index{encode.c@{encode.c}!CFE_encode@{CFE\_\-encode}}
\index{CFE_encode@{CFE\_\-encode}!encode.c@{encode.c}}
\subsubsection[CFE\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void CFE\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em ccc}, unsigned {\em crc}, unsigned {\em cfe}, unsigned {\em reg}, unsigned short {\em payload})}}
\label{encode_8c_a9}


Create a LATp command targeted at a CFE. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to packe \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em ccc}]should be the ID of the target CCC, or BCAST to broadcast to all CCCs \item[{\em crc}]should be the ID of the target CRC, or BCAST to broadcast to all CRCs \item[{\em cfe}]should be the ID of the target CFE, or BCAST to broadcast to all CFEs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]16 bits to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a8}{
\index{encode.c@{encode.c}!CRC_encode@{CRC\_\-encode}}
\index{CRC_encode@{CRC\_\-encode}!encode.c@{encode.c}}
\subsubsection[CRC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void CRC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em ccc}, unsigned {\em crc}, unsigned {\em reg}, unsigned short {\em payload})}}
\label{encode_8c_a8}


Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at a CRC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em ccc}]should be the ID of the target CCC, or BCAST to broadcast to all CCCs \item[{\em crc}]should be the ID of the target CRC, or BCAST to broadcast to all CRCs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]16 bits to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a20}{
\index{encode.c@{encode.c}!CRU_encode@{CRU\_\-encode}}
\index{CRU_encode@{CRU\_\-encode}!encode.c@{encode.c}}
\subsubsection[CRU\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void CRU\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a20}


Create a LATp command targeted at the CRU. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a21}{
\index{encode.c@{encode.c}!EBM_encode@{EBM\_\-encode}}
\index{EBM_encode@{EBM\_\-encode}!encode.c@{encode.c}}
\subsubsection[EBM\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void EBM\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a21}


Create a LATp command targeted at the common controller block of the EBM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the EBM \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a22}{
\index{encode.c@{encode.c}!EBM_STAT_encode@{EBM\_\-STAT\_\-encode}}
\index{EBM_STAT_encode@{EBM\_\-STAT\_\-encode}!encode.c@{encode.c}}
\subsubsection[EBM\_\-STAT\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void EBM\_\-STAT\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a22}


Create a LATp command targeted at the statistics block of the EBM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the EBM \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a23}{
\index{encode.c@{encode.c}!GEM_encode@{GEM\_\-encode}}
\index{GEM_encode@{GEM\_\-encode}!encode.c@{encode.c}}
\subsubsection[GEM\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void GEM\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, \hyperlink{defs_8h_a422}{LEM\_\-REG\_\-BLK} {\em blk}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a23}


Create a LATp command targeted at the GEM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the GEM \item[{\em blk}]should be the ID of the register block (one of the GEM\_\-BLK\_\-X from LEM\_\-REG\_\-BLK) \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a0}{
\index{encode.c@{encode.c}!getWait@{getWait}}
\index{getWait@{getWait}!encode.c@{encode.c}}
\subsubsection[getWait]{\setlength{\rightskip}{0pt plus 5cm}unsigned get\-Wait (\hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, unsigned {\em addr0}, unsigned {\em addr1}, unsigned {\em addr2}, unsigned {\em addr3}, unsigned {\em reg\-Id})\hspace{0.3cm}{\tt  \mbox{[}inline, static\mbox{]}}}}
\label{encode_8c_a0}


Select the appropriate LEM\_\-DB\_\-server function to call to get the stall/timeout for this register operation. 

\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em The}]timeout/stall time to insert into the command item \end{description}
\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em function}]One of CMD\_\-READ, CMD\_\-LOAD or CMD\_\-DATALESS \item[{\em addr0}]LATp node address \item[{\em addr1}]Second element in the register address (or -1) \item[{\em addr2}]Third element in the register address (or -1) \item[{\em addr3}]Fourth element in the register address (or -1) \item[{\em reg\-Id}]Register ID\end{description}
\end{Desc}
Note that the ARC and AFE dataless commands are identical to load commands, so use the load wait time rather than the dataless wait time.\hypertarget{encode_8c_a24}{
\index{encode.c@{encode.c}!LAM_encode@{LAM\_\-encode}}
\index{LAM_encode@{LAM\_\-encode}!encode.c@{encode.c}}
\subsubsection[LAM\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void LAM\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr})}}
\label{encode_8c_a24}


Create a look-at-me command. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em addr}]Logical LATp address of the target (usually the BCAST address)\end{description}
\end{Desc}
\hypertarget{encode_8c_a25}{
\index{encode.c@{encode.c}!LAM_LCB_encode@{LAM\_\-LCB\_\-encode}}
\index{LAM_LCB_encode@{LAM\_\-LCB\_\-encode}!encode.c@{encode.c}}
\subsubsection[LAM\_\-LCB\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void LAM\_\-LCB\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em value}, unsigned {\em enable\_\-mask})}}
\label{encode_8c_a25}


Create a look-at-me command targetted at an LCB. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em addr}]Logical LATp address of the target (usually the BCAST address) \item[{\em value}]Value to set the LATp CSR register to \item[{\em enable\_\-mask}]Enable mask for the register write\end{description}
\end{Desc}
\hypertarget{encode_8c_a3}{
\index{encode.c@{encode.c}!LEM_get_load_to@{LEM\_\-get\_\-load\_\-to}}
\index{LEM_get_load_to@{LEM\_\-get\_\-load\_\-to}!encode.c@{encode.c}}
\subsubsection[LEM\_\-get\_\-load\_\-to]{\setlength{\rightskip}{0pt plus 5cm}unsigned LEM\_\-get\_\-load\_\-to (void)}}
\label{encode_8c_a3}


Retained for backward compatibility. 

\begin{Desc}
\item[Returns:]0 \end{Desc}
\begin{Desc}
\item[Warning:]Function reports the error LCI\_\-NOIMPL and returns 0\end{Desc}
\hypertarget{encode_8c_a4}{
\index{encode.c@{encode.c}!LEM_get_read_to@{LEM\_\-get\_\-read\_\-to}}
\index{LEM_get_read_to@{LEM\_\-get\_\-read\_\-to}!encode.c@{encode.c}}
\subsubsection[LEM\_\-get\_\-read\_\-to]{\setlength{\rightskip}{0pt plus 5cm}unsigned LEM\_\-get\_\-read\_\-to (void)}}
\label{encode_8c_a4}


Retained for backward compatibility. 

\begin{Desc}
\item[Returns:]0 \end{Desc}
\begin{Desc}
\item[Warning:]Function reports the error LCI\_\-NOIMPL and returns 0\end{Desc}
\hypertarget{encode_8c_a1}{
\index{encode.c@{encode.c}!LEM_set_load_to@{LEM\_\-set\_\-load\_\-to}}
\index{LEM_set_load_to@{LEM\_\-set\_\-load\_\-to}!encode.c@{encode.c}}
\subsubsection[LEM\_\-set\_\-load\_\-to]{\setlength{\rightskip}{0pt plus 5cm}void LEM\_\-set\_\-load\_\-to (unsigned {\em timeout})}}
\label{encode_8c_a1}


Retained for backward compatibility. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em timeout}]Ignored \end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]Function just reports the error LCI\_\-NOIMPL\end{Desc}
\hypertarget{encode_8c_a2}{
\index{encode.c@{encode.c}!LEM_set_read_to@{LEM\_\-set\_\-read\_\-to}}
\index{LEM_set_read_to@{LEM\_\-set\_\-read\_\-to}!encode.c@{encode.c}}
\subsubsection[LEM\_\-set\_\-read\_\-to]{\setlength{\rightskip}{0pt plus 5cm}void LEM\_\-set\_\-read\_\-to (unsigned {\em timeout})}}
\label{encode_8c_a2}


Retained for backward compatibility. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em timeout}]Ignored \end{description}
\end{Desc}
\begin{Desc}
\item[Warning:]Function just reports the error LCI\_\-NOIMPL\end{Desc}
\hypertarget{encode_8c_a18}{
\index{encode.c@{encode.c}!PDU_encode@{PDU\_\-encode}}
\index{PDU_encode@{PDU\_\-encode}!encode.c@{encode.c}}
\subsubsection[PDU\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void PDU\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a18}


Create a LATp Command targeted at the common controller of the PDU. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a19}{
\index{encode.c@{encode.c}!PDU_ENV_encode@{PDU\_\-ENV\_\-encode}}
\index{PDU_ENV_encode@{PDU\_\-ENV\_\-encode}!encode.c@{encode.c}}
\subsubsection[PDU\_\-ENV\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void PDU\_\-ENV\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a19}


Create a LATp command targeted at the environment block of the PDU. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]should be one of LEM\_\-LATP\_\-ADDR \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a10}{
\index{encode.c@{encode.c}!TCC_encode@{TCC\_\-encode}}
\index{TCC_encode@{TCC\_\-encode}!encode.c@{encode.c}}
\subsubsection[TCC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void TCC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em tcc}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a10}


Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at a TCC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical address of the TEM \item[{\em tcc}]should be the ID of the target TCC, or BCAST to broadcast to all TCCs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a13}{
\index{encode.c@{encode.c}!TDC_encode@{TDC\_\-encode}}
\index{TDC_encode@{TDC\_\-encode}!encode.c@{encode.c}}
\subsubsection[TDC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void TDC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em tcc}, unsigned {\em trc}, unsigned {\em tfe}, unsigned long long {\em payload})}}
\label{encode_8c_a13}


Create a LATp Command targeted at the DAC register of a TFE. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em tcc}]should be the ID of the target TCC, or BCAST to broadcast to all TCCs \item[{\em trc}]should be the ID of the target TRC, or BCAST to broadcast to all TRCs \item[{\em tfe}]should be the ID of the target TFE, or BCAST to broadcast to all TFEs \item[{\em payload}]64 bits of data to send with the load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a5}{
\index{encode.c@{encode.c}!TEM_encode@{TEM\_\-encode}}
\index{TEM_encode@{TEM\_\-encode}!encode.c@{encode.c}}
\subsubsection[TEM\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void TEM\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a5}


Create a LATp command targeted at the common controller block of a TEM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a12}{
\index{encode.c@{encode.c}!TFE_encode@{TFE\_\-encode}}
\index{TFE_encode@{TFE\_\-encode}!encode.c@{encode.c}}
\subsubsection[TFE\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void TFE\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em tcc}, unsigned {\em trc}, unsigned {\em tfe}, unsigned {\em reg}, unsigned long long {\em payload})}}
\label{encode_8c_a12}


Create a LATp Command targeted at a TFE. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em tcc}]should be the ID of the target TCC, or BCAST to broadcast to all TCCs \item[{\em trc}]should be the ID of the target TRC, or BCAST to broadcast to all TRCs \item[{\em tfe}]should be the ID of the target TFE, or BCAST to broadcast to all TFEs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]64 bits of data to send with the load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a6}{
\index{encode.c@{encode.c}!TIC_encode@{TIC\_\-encode}}
\index{TIC_encode@{TIC\_\-encode}!encode.c@{encode.c}}
\subsubsection[TIC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void TIC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em reg}, unsigned {\em payload})}}
\label{encode_8c_a6}


Create a LATp command targeted at the TIC block of a TEM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Ptr to \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em reg}]should be the ID of the target register \item[{\em payload}]32 bits of data to send with a load command\end{description}
\end{Desc}
\hypertarget{encode_8c_a11}{
\index{encode.c@{encode.c}!TRC_encode@{TRC\_\-encode}}
\index{TRC_encode@{TRC\_\-encode}!encode.c@{encode.c}}
\subsubsection[TRC\_\-encode]{\setlength{\rightskip}{0pt plus 5cm}void TRC\_\-encode (\hyperlink{structLEM__ci}{LEM\_\-ci} $\ast$ {\em cmd}, \hyperlink{defs_8h_a419}{LEM\_\-FUNCTION} {\em function}, \hyperlink{defs_8h_a429}{LEM\_\-LATP\_\-ADDR} {\em addr}, unsigned {\em tcc}, unsigned {\em trc}, unsigned {\em reg}, unsigned long long {\em payload})}}
\label{encode_8c_a11}


Create a \hyperlink{structLEM__ci}{LEM\_\-ci} targeted at a TRC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em cmd}]Pointer to the \hyperlink{structLEM__ci}{LEM\_\-ci} to pack \item[{\em function}]should be one of CMD\_\-READ, CMD\_\-LOAD, CMD\_\-DATALESS \item[{\em addr}]Logical LATp address of the TEM \item[{\em tcc}]should be the ID of the target TCC, or BCAST to broadcast to all TCCs \item[{\em trc}]should be the ID of the target TRC, or BCAST to broadcast to all TRCs \item[{\em reg}]should be the ID of the target register \item[{\em payload}]64 bits of data to send with a load command\end{description}
\end{Desc}
