\hypertarget{power_8c}{
\section{power.c File Reference}
\label{power_8c}\index{power.c@{power.c}}
}
Provides functions to power on and configure the LAT.  


{\tt \#include \char`\"{}DUTIL/power.h\char`\"{}}\par
{\tt \#include \char`\"{}DUTIL/start.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-log.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-init.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-io.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-dispatch.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-err.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-bulk.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LCB\_\-reg.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LIOX.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LIOX\_\-init.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LIOX\_\-sys.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LIOX\_\-sync.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LIOX\_\-cmd.h\char`\"{}}\par
{\tt \#include \char`\"{}LCB/LIOX\_\-addr.h\char`\"{}}\par
{\tt \#include \char`\"{}DAB/reg.h\char`\"{}}\par
{\tt \#include \char`\"{}DAB/scru.h\char`\"{}}\par
{\tt \#include \char`\"{}DAB/spdu.h\char`\"{}}\par
{\tt \#include \char`\"{}DAB/sgem.h\char`\"{}}\par
{\tt \#include \char`\"{}DAB/sebm.h\char`\"{}}\par
{\tt \#include \char`\"{}DEM/TEM\_\-reg.h\char`\"{}}\par
{\tt \#include \char`\"{}DEM/TEM\_\-CC\_\-sync.h\char`\"{}}\par
{\tt \#include \char`\"{}DEM/TEM\_\-GCCC\_\-sync.h\char`\"{}}\par
{\tt \#include \char`\"{}DEM/TEM\_\-GTIC\_\-sync.h\char`\"{}}\par
{\tt \#include \char`\"{}DEM/AEM\_\-reg.h\char`\"{}}\par
{\tt \#include \char`\"{}DEM/AEM\_\-CC\_\-sync.h\char`\"{}}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$string.h$>$}\par


Include dependency graph for power.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=141pt]{power_8c__incl}
\end{center}
\end{figure}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\hypertarget{power_8c_a0}{
\#define \hyperlink{power_8c_a0}{N\_\-CRU\_\-REGS}\ 3}
\label{power_8c_a0}

\begin{CompactList}\small\item\em Number of CRU registers to save and restore in use\-Other\-DAB. \item\end{CompactList}\item 
\hypertarget{power_8c_a1}{
\#define \hyperlink{power_8c_a1}{N\_\-EBM\_\-REGS}\ 8}
\label{power_8c_a1}

\begin{CompactList}\small\item\em Number of EBM registers to save and restore in use\-Other\-DAB. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{power_8c_a2}{power\-On} (LIOXs slh, unsigned mask0, unsigned mask1, unsigned delay)
\begin{CompactList}\small\item\em Configures the PDUs to power the required components of the LAT. \item\end{CompactList}\item 
int \hyperlink{power_8c_a3}{power\-Off} (LIOXs slh, unsigned cpt\-Mask, unsigned delay)
\begin{CompactList}\small\item\em Configures the PDUs to power the required components of the LAT. \item\end{CompactList}\item 
int \hyperlink{power_8c_a4}{config\-CRU} (LIOXs slh, unsigned cpt\-Mask)
\begin{CompactList}\small\item\em Configures the CRU to allow LATp C/R with the specified components and sets the LATp addresses of those cpts. \item\end{CompactList}\item 
int \hyperlink{power_8c_a5}{config\-EBM} (LIOXs slh, unsigned cpt\-Mask)
\begin{CompactList}\small\item\em Configures the source and destination enables of the EBM. \item\end{CompactList}\item 
unsigned \hyperlink{power_8c_a6}{use\-Other\-DAB} (LCB lcb, LIOXs slh)
\begin{CompactList}\small\item\em Stop using the current (prim/red) LATp fabric and switch to the other, transferring over the CRU and EBM configurations in the process. \item\end{CompactList}\item 
int \hyperlink{power_8c_a7}{add\-TEM} (LIOXs slh, unsigned tem\-ID, unsigned pdu\-ID, unsigned delay)
\begin{CompactList}\small\item\em Power on a TEM and configure it along with the CRU and EBM. \item\end{CompactList}\item 
int \hyperlink{power_8c_a8}{remove\-TEM} (LIOXs slh, unsigned tem\-ID, unsigned delay)
\begin{CompactList}\small\item\em Power off a TEM and remove it from the CRU and EBM configurations. \item\end{CompactList}\item 
int \hyperlink{power_8c_a9}{add\-EPU} (LIOXs slh, unsigned epu\-ID, unsigned pdu\-ID, unsigned delay)
\begin{CompactList}\small\item\em Power on an EPU and configure it along with the CRU and EBM. \item\end{CompactList}\item 
int \hyperlink{power_8c_a10}{remove\-EPU} (LIOXs slh, unsigned epu\-ID, unsigned delay)
\begin{CompactList}\small\item\em Power off an EPU and remove it from the CRU and EBM configurations. \item\end{CompactList}\item 
int \hyperlink{power_8c_a11}{power\-On\-TWR} (LIOXs slh, unsigned tkr\-Mask, unsigned cal\-Mask, unsigned delay)
\begin{CompactList}\small\item\em Power on the CAL and TRK. \item\end{CompactList}\item 
int \hyperlink{power_8c_a12}{power\-Off\-TWR} (LIOXs slh, unsigned tkr\-Mask, unsigned cal\-Mask, unsigned delay)
\begin{CompactList}\small\item\em Power off the CAL and TRK. \item\end{CompactList}\item 
int \hyperlink{power_8c_a13}{power\-On\-ACD} (LIOXs slh, unsigned free\-Mask, unsigned delay)
\begin{CompactList}\small\item\em Power on the FREE boards. \item\end{CompactList}\item 
int \hyperlink{power_8c_a14}{power\-Off\-ACD} (LIOXs slh, unsigned free\-Mask, unsigned delay)
\begin{CompactList}\small\item\em Power on the FREE boards. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Provides functions to power on and configure the LAT. 

\begin{Desc}
\item[Author:]James Swain -- \href{mailto:jswain@slac.stanford.edu}{\tt jswain@slac.stanford.edu} \end{Desc}


\subsection{Function Documentation}
\hypertarget{power_8c_a9}{
\index{power.c@{power.c}!addEPU@{addEPU}}
\index{addEPU@{addEPU}!power.c@{power.c}}
\subsubsection[addEPU]{\setlength{\rightskip}{0pt plus 5cm}int add\-EPU (LIOXs {\em slh}, unsigned {\em epu\-ID}, unsigned {\em pdu\-ID}, unsigned {\em delay})}}
\label{power_8c_a9}


Power on an EPU and configure it along with the CRU and EBM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em epu\-ID}]0 ... 2 \item[{\em pdu\-ID}]0 -$>$ use Primary PDU, 1 -$>$ use Redundant PDU \item[{\em delay}]Time (in 60ths of a second) to wait after powering a cpt before proceeding \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 if successful, -1 if failed \end{Desc}
\hypertarget{power_8c_a7}{
\index{power.c@{power.c}!addTEM@{addTEM}}
\index{addTEM@{addTEM}!power.c@{power.c}}
\subsubsection[addTEM]{\setlength{\rightskip}{0pt plus 5cm}int add\-TEM (LIOXs {\em slh}, unsigned {\em tem\-ID}, unsigned {\em pdu\-ID}, unsigned {\em delay})}}
\label{power_8c_a7}


Power on a TEM and configure it along with the CRU and EBM. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em tem\-ID}]0 ... 15 \item[{\em pdu\-ID}]0 -$>$ use Primary PDU, 1 -$>$ use Redundant PDU \item[{\em delay}]Time (in 60ths of a second) to wait after powering a cpt before proceeding \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 if successful, -1 if failed \end{Desc}
\hypertarget{power_8c_a4}{
\index{power.c@{power.c}!configCRU@{configCRU}}
\index{configCRU@{configCRU}!power.c@{power.c}}
\subsubsection[configCRU]{\setlength{\rightskip}{0pt plus 5cm}int config\-CRU (LIOXs {\em slh}, unsigned {\em cpt\-Mask})}}
\label{power_8c_a4}


Configures the CRU to allow LATp C/R with the specified components and sets the LATp addresses of those cpts. 

int \hyperlink{power_8c_a4}{config\-CRU(LIOXs slh, unsigned cpt\-Mask)} \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em cpt\-Mask}]Bit mask indicating which components should be configured \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
1) Any component that is not specified in {\em cpt\-Mask\/} will be inaccessible following the execution of this function

2) Only the TEMs, DAB and PDUs are configured by this function.

3) {\em cpt\-Mask\/} is laid out in the manner of the CRU command and response enable bit masks (LAT-TD-01547, figs 12 \& 13).

TEM0 = 0x00000001 TEM1 = 0x00000002 TEM2 = 0x00000004 : TEMe = 0x00004000 TEMf = 0x00008000 GEM = 0x00010000 AEM = 0x00020000 EBM = 0x00040000 PDU0 = 0x00080000 PDU1 = 0x00100000 SIUx = 0x01000000 SIU0 = 0x02000000 SIU1 = 0x04000000 EPU0 = 0x08000000 EPU1 = 0x10000000 EPU2 = 0x20000000 \hypertarget{power_8c_a5}{
\index{power.c@{power.c}!configEBM@{configEBM}}
\index{configEBM@{configEBM}!power.c@{power.c}}
\subsubsection[configEBM]{\setlength{\rightskip}{0pt plus 5cm}int config\-EBM (LIOXs {\em slh}, unsigned {\em cpt\-Mask})}}
\label{power_8c_a5}


Configures the source and destination enables of the EBM. 

int \hyperlink{power_8c_a5}{config\-EBM(LIOXs slh, unsigned cpt\-Mask)} \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em cpt\-Mask}]Bit mask indicating which components should be configured \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
1) {\em cpt\-Mask\/} is the concatenation of registers 4-6 of the EBM controller block (LAT-TD-01546, the source enable registers) with an additional bit in the most- significant-byte representing the SSR

GEM = 0x00000001 TEM0 = 0x00000002 TEM1 = 0x00000004 TEM2 = 0x00000008 : TEMe = 0x00008000 TEMf = 0x00010000 AEM = 0x00020000 SIUX = 0x00040000 SIU0 = 0x00080000 SIU1 = 0x00100000 EPU0 = 0x00200000 EPU1 = 0x00400000 EPU2 = 0x00800000 \hypertarget{power_8c_a3}{
\index{power.c@{power.c}!powerOff@{powerOff}}
\index{powerOff@{powerOff}!power.c@{power.c}}
\subsubsection[powerOff]{\setlength{\rightskip}{0pt plus 5cm}int power\-Off (LIOXs {\em slh}, unsigned {\em cpt\-Mask}, unsigned {\em delay})}}
\label{power_8c_a3}


Configures the PDUs to power the required components of the LAT. 

int power\-Off (LIOXs slh, unsigned cpt\-Mask, unsigned delay) \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em cpt\-Mask}]Bit mask indicating which components should be powered off \item[{\em delay}]Time (in 60ths of a second) to wait after powering a cpt before powering the next \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
1) Function assumes that the CRU is unconfigured so begins by configuring the CRU to access the requested PDUs and sets the LATp addresses of the aforementioned PDUs.

2) Currently only the Primary EPU DC-DC converters are available.

3) Currently only the Primary ACD supply and converters are available.

4) {\em cpt\-Mask\/} is laid out in the manner of the CRU command and response enable bit masks (LAT-TD-01547, figs 12 \& 13).

TEM0 = 0x00000001 TEM1 = 0x00000002 TEM2 = 0x00000004 : TEMe = 0x00004000 TEMf = 0x00008000 GEM = 0x00010000 AEM = 0x00020000 EBM = 0x00040000 PDU0 = 0x00080000 PDU1 = 0x00100000 SIUx = 0x01000000 SIU0 = 0x02000000 SIU1 = 0x04000000 EPU0 = 0x08000000 EPU1 = 0x10000000 EPU2 = 0x20000000 \hypertarget{power_8c_a14}{
\index{power.c@{power.c}!powerOffACD@{powerOffACD}}
\index{powerOffACD@{powerOffACD}!power.c@{power.c}}
\subsubsection[powerOffACD]{\setlength{\rightskip}{0pt plus 5cm}int power\-Off\-ACD (LIOXs {\em slh}, unsigned {\em free\-Mask}, unsigned {\em delay})}}
\label{power_8c_a14}


Power on the FREE boards. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchrounous LIOX handle \item[{\em free\-Mask}]Bitmask indicating which free boards should be powered \item[{\em delay}]Time (in 60ths of a second) between each power-on command \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
\hypertarget{power_8c_a12}{
\index{power.c@{power.c}!powerOffTWR@{powerOffTWR}}
\index{powerOffTWR@{powerOffTWR}!power.c@{power.c}}
\subsubsection[powerOffTWR]{\setlength{\rightskip}{0pt plus 5cm}int power\-Off\-TWR (LIOXs {\em slh}, unsigned {\em tkr\-Mask}, unsigned {\em cal\-Mask}, unsigned {\em delay})}}
\label{power_8c_a12}


Power off the CAL and TRK. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em tkr\-Mask}]Bitmask indicating which tracker towers to turn on \item[{\em cal\-Mask}]Bitmask indicating which cal towers to turn on \item[{\em delay}]Time (in 60ths of a second) between each power-on command \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
\hypertarget{power_8c_a2}{
\index{power.c@{power.c}!powerOn@{powerOn}}
\index{powerOn@{powerOn}!power.c@{power.c}}
\subsubsection[powerOn]{\setlength{\rightskip}{0pt plus 5cm}void power\-On (LIOXs {\em slh}, unsigned {\em mask0}, unsigned {\em mask1}, unsigned {\em delay})}}
\label{power_8c_a2}


Configures the PDUs to power the required components of the LAT. 

void power\-On (LIOXs slh, unsigned mask0, unsigned mask1, unsigned delay) \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em mask0}]Bit mask indicating which components should be powered on by the PRIMARY PDU \item[{\em mask1}]Bit mask indicating which components should be powered on by the REDUNDANT PDU \item[{\em delay}]Time (in 60ths of a second) to wait after powering a cpt before powering the next \end{description}
\end{Desc}
1) Function assumes that the CRU is unconfigured so begins by configuring the CRU to access the requested PDUs and sets the LATp addresses of the aforementioned PDUs.

2) Currently only the Primary EPU DC-DC converters are available.

3) Currently only the Primary ACD supply and converters are available.

4) {\em mask0\/} and {\em mask1\/} are laid out in the manner of the CRU command and response enable bit masks (LAT-TD-01547, figs 12 \& 13).

TEM0 = 0x00000001 TEM1 = 0x00000002 TEM2 = 0x00000004 : TEMe = 0x00004000 TEMf = 0x00008000 GEM = 0x00010000 AEM = 0x00020000 EBM = 0x00040000 PDU0 = 0x00080000 PDU1 = 0x00100000 SIUx = 0x01000000 SIU0 = 0x02000000 SIU1 = 0x04000000 EPU0 = 0x08000000 EPU1 = 0x10000000 EPU2 = 0x20000000 \hypertarget{power_8c_a13}{
\index{power.c@{power.c}!powerOnACD@{powerOnACD}}
\index{powerOnACD@{powerOnACD}!power.c@{power.c}}
\subsubsection[powerOnACD]{\setlength{\rightskip}{0pt plus 5cm}int power\-On\-ACD (LIOXs {\em slh}, unsigned {\em free\-Mask}, unsigned {\em delay})}}
\label{power_8c_a13}


Power on the FREE boards. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchrounous LIOX handle \item[{\em free\-Mask}]Bitmask indicating which free boards should be powered \item[{\em delay}]Time (in 60ths of a second) between each power-on command \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
\hypertarget{power_8c_a11}{
\index{power.c@{power.c}!powerOnTWR@{powerOnTWR}}
\index{powerOnTWR@{powerOnTWR}!power.c@{power.c}}
\subsubsection[powerOnTWR]{\setlength{\rightskip}{0pt plus 5cm}int power\-On\-TWR (LIOXs {\em slh}, unsigned {\em tkr\-Mask}, unsigned {\em cal\-Mask}, unsigned {\em delay})}}
\label{power_8c_a11}


Power on the CAL and TRK. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em tkr\-Mask}]Bitmask indicating which tracker towers to turn on \item[{\em cal\-Mask}]Bitmask indicating which cal towers to turn on \item[{\em delay}]Time (in 60ths of a second) between each power-on command \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 on success, -1 on failure \end{Desc}
\hypertarget{power_8c_a10}{
\index{power.c@{power.c}!removeEPU@{removeEPU}}
\index{removeEPU@{removeEPU}!power.c@{power.c}}
\subsubsection[removeEPU]{\setlength{\rightskip}{0pt plus 5cm}int remove\-EPU (LIOXs {\em slh}, unsigned {\em epu\-ID}, unsigned {\em delay})}}
\label{power_8c_a10}


Power off an EPU and remove it from the CRU and EBM configurations. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em epu\-ID}]0 ... 3 \item[{\em delay}]Time (in 60ths of a second) to wait after powering a cpt before proceeding \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 if successful, -1 if failed \end{Desc}
\hypertarget{power_8c_a8}{
\index{power.c@{power.c}!removeTEM@{removeTEM}}
\index{removeTEM@{removeTEM}!power.c@{power.c}}
\subsubsection[removeTEM]{\setlength{\rightskip}{0pt plus 5cm}int remove\-TEM (LIOXs {\em slh}, unsigned {\em tem\-ID}, unsigned {\em delay})}}
\label{power_8c_a8}


Power off a TEM and remove it from the CRU and EBM configurations. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em slh}]Synchronous LIOX handle \item[{\em tem\-ID}]0 ... 15 \item[{\em delay}]Time (in 60ths of a second) to wait after powering a cpt before proceeding \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]0 if successful, -1 if failed \end{Desc}
\hypertarget{power_8c_a6}{
\index{power.c@{power.c}!useOtherDAB@{useOtherDAB}}
\index{useOtherDAB@{useOtherDAB}!power.c@{power.c}}
\subsubsection[useOtherDAB]{\setlength{\rightskip}{0pt plus 5cm}unsigned use\-Other\-DAB (LCB {\em lcb}, LIOXs {\em slh})}}
\label{power_8c_a6}


Stop using the current (prim/red) LATp fabric and switch to the other, transferring over the CRU and EBM configurations in the process. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em lcb}]Pointer to the LCB \item[{\em slh}]Synchronous LIOX handle \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]DAB status code (DAB\_\-SUCCESS if all goes well) \end{Desc}
