\hypertarget{AD7708_8h}{
\section{AD7708.h File Reference}
\label{AD7708_8h}\index{AD7708.h@{AD7708.h}}
}
{\tt \#include $<$avr/io.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{AD7708_8h_fb36ec1d80e4ec46ec38c66465c50338}{write\_\-adc\_\-reg} (uint8\_\-t command, uint8\_\-t data)
\begin{CompactList}\small\item\em Assert CS on the ADC, and send command then data via SPI. \item\end{CompactList}\item 
uint8\_\-t \hyperlink{AD7708_8h_f403e08179e72cb0decde584e134922b}{read\_\-adc\_\-reg} (uint8\_\-t command)
\begin{CompactList}\small\item\em Assert CS on the ADC, send command and retrieve the subsequent byte of data via SPI. \item\end{CompactList}\item 
uint16\_\-t \hyperlink{AD7708_8h_95fd5b537e7faffc9e969fe771d78973}{read\_\-adc\_\-result} ()
\begin{CompactList}\small\item\em Assert CS on the ADC, send command 0x44 and retrieve 16 bit result. \item\end{CompactList}\item 
void \hyperlink{AD7708_8h_b15cf82f0329bc4d7262c03559eaaa8e}{init\_\-adc} (void)
\begin{CompactList}\small\item\em Initialise ADC to 19.56Hz, Ch0 unipolar 2.56V FS, 10 channel, no buffering, idle mode. \item\end{CompactList}\item 
void \hyperlink{AD7708_8h_52140480c238c3f3c20962db30c15c3e}{adc\_\-select\_\-channel} (uint8\_\-t channel)
\begin{CompactList}\small\item\em Select the input channel to the ADC. \item\end{CompactList}\item 
void \hyperlink{AD7708_8h_cec96a02bae816e24b67875114d526f5}{adc\_\-start\_\-conversion} (void)
\begin{CompactList}\small\item\em Issue the command to start ADC conversion. \item\end{CompactList}\item 
void \hyperlink{AD7708_8h_ebb56d9decefabe9bedc9dceb7736f1a}{adc\_\-wait\_\-idle} (void)
\begin{CompactList}\small\item\em Wait until the ADC has finished a conversion, then return. \item\end{CompactList}\item 
void \hyperlink{AD7708_8h_2f85fec0adbcb463fdb14c57ed347794}{adc\_\-get\_\-set\_\-of\_\-readings} (uint16\_\-t $\ast$data)
\begin{CompactList}\small\item\em Get a set of qty 8 16 bit readings from the ADC. \item\end{CompactList}\end{CompactItemize}


\subsection{Function Documentation}
\hypertarget{AD7708_8h_2f85fec0adbcb463fdb14c57ed347794}{
\index{AD7708.h@{AD7708.h}!adc\_\-get\_\-set\_\-of\_\-readings@{adc\_\-get\_\-set\_\-of\_\-readings}}
\index{adc\_\-get\_\-set\_\-of\_\-readings@{adc\_\-get\_\-set\_\-of\_\-readings}!AD7708.h@{AD7708.h}}
\subsubsection[{adc\_\-get\_\-set\_\-of\_\-readings}]{\setlength{\rightskip}{0pt plus 5cm}void adc\_\-get\_\-set\_\-of\_\-readings (uint16\_\-t $\ast$ {\em data})}}
\label{AD7708_8h_2f85fec0adbcb463fdb14c57ed347794}


Get a set of qty 8 16 bit readings from the ADC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em $\ast$data}]pointer for where to store the 8 sets of 16 bits read\end{description}
\end{Desc}
Handles the channel change, discard erroneous readings, and waiting for valid results. \hypertarget{AD7708_8h_52140480c238c3f3c20962db30c15c3e}{
\index{AD7708.h@{AD7708.h}!adc\_\-select\_\-channel@{adc\_\-select\_\-channel}}
\index{adc\_\-select\_\-channel@{adc\_\-select\_\-channel}!AD7708.h@{AD7708.h}}
\subsubsection[{adc\_\-select\_\-channel}]{\setlength{\rightskip}{0pt plus 5cm}void adc\_\-select\_\-channel (uint8\_\-t {\em channel})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{AD7708_8h_52140480c238c3f3c20962db30c15c3e}


Select the input channel to the ADC. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em channel}]channel number in lowest 4 bits. Values 0-9 are valid \end{description}
\end{Desc}
\hypertarget{AD7708_8h_cec96a02bae816e24b67875114d526f5}{
\index{AD7708.h@{AD7708.h}!adc\_\-start\_\-conversion@{adc\_\-start\_\-conversion}}
\index{adc\_\-start\_\-conversion@{adc\_\-start\_\-conversion}!AD7708.h@{AD7708.h}}
\subsubsection[{adc\_\-start\_\-conversion}]{\setlength{\rightskip}{0pt plus 5cm}void adc\_\-start\_\-conversion (void)\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{AD7708_8h_cec96a02bae816e24b67875114d526f5}


Issue the command to start ADC conversion. 

\hypertarget{AD7708_8h_ebb56d9decefabe9bedc9dceb7736f1a}{
\index{AD7708.h@{AD7708.h}!adc\_\-wait\_\-idle@{adc\_\-wait\_\-idle}}
\index{adc\_\-wait\_\-idle@{adc\_\-wait\_\-idle}!AD7708.h@{AD7708.h}}
\subsubsection[{adc\_\-wait\_\-idle}]{\setlength{\rightskip}{0pt plus 5cm}void adc\_\-wait\_\-idle (void)\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{AD7708_8h_ebb56d9decefabe9bedc9dceb7736f1a}


Wait until the ADC has finished a conversion, then return. 

\hypertarget{AD7708_8h_b15cf82f0329bc4d7262c03559eaaa8e}{
\index{AD7708.h@{AD7708.h}!init\_\-adc@{init\_\-adc}}
\index{init\_\-adc@{init\_\-adc}!AD7708.h@{AD7708.h}}
\subsubsection[{init\_\-adc}]{\setlength{\rightskip}{0pt plus 5cm}void init\_\-adc (void)\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{AD7708_8h_b15cf82f0329bc4d7262c03559eaaa8e}


Initialise ADC to 19.56Hz, Ch0 unipolar 2.56V FS, 10 channel, no buffering, idle mode. 

\hypertarget{AD7708_8h_f403e08179e72cb0decde584e134922b}{
\index{AD7708.h@{AD7708.h}!read\_\-adc\_\-reg@{read\_\-adc\_\-reg}}
\index{read\_\-adc\_\-reg@{read\_\-adc\_\-reg}!AD7708.h@{AD7708.h}}
\subsubsection[{read\_\-adc\_\-reg}]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t read\_\-adc\_\-reg (uint8\_\-t {\em command})}}
\label{AD7708_8h_f403e08179e72cb0decde584e134922b}


Assert CS on the ADC, send command and retrieve the subsequent byte of data via SPI. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em command}]command to send as first byte \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]data data read as a result of command \end{Desc}
\hypertarget{AD7708_8h_95fd5b537e7faffc9e969fe771d78973}{
\index{AD7708.h@{AD7708.h}!read\_\-adc\_\-result@{read\_\-adc\_\-result}}
\index{read\_\-adc\_\-result@{read\_\-adc\_\-result}!AD7708.h@{AD7708.h}}
\subsubsection[{read\_\-adc\_\-result}]{\setlength{\rightskip}{0pt plus 5cm}uint16\_\-t read\_\-adc\_\-result ()}}
\label{AD7708_8h_95fd5b537e7faffc9e969fe771d78973}


Assert CS on the ADC, send command 0x44 and retrieve 16 bit result. 

\begin{Desc}
\item[Returns:]data 16 bit data returned by ADC \end{Desc}
\hypertarget{AD7708_8h_fb36ec1d80e4ec46ec38c66465c50338}{
\index{AD7708.h@{AD7708.h}!write\_\-adc\_\-reg@{write\_\-adc\_\-reg}}
\index{write\_\-adc\_\-reg@{write\_\-adc\_\-reg}!AD7708.h@{AD7708.h}}
\subsubsection[{write\_\-adc\_\-reg}]{\setlength{\rightskip}{0pt plus 5cm}void write\_\-adc\_\-reg (uint8\_\-t {\em command}, \/  uint8\_\-t {\em data})}}
\label{AD7708_8h_fb36ec1d80e4ec46ec38c66465c50338}


Assert CS on the ADC, and send command then data via SPI. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em command}]command to send as first byte \item[{\em data}]data to send as second byte \end{description}
\end{Desc}
