\hypertarget{utilities_8c}{\section{src/utilities.c File Reference}
\label{utilities_8c}\index{src/utilities.\-c@{src/utilities.\-c}}
}
{\ttfamily \#include \char`\"{}utilities.\-h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}M\-A\-X\-R\-E\-F\-D\-E\-S14.\-h\char`\"{}}\\*
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{utilities_8c_a3635c0eee0c1ea6ccbd6f882e6ed233e}{print\-\_\-asterisks} (int n\-Quantity)
\begin{DoxyCompactList}\small\item\em Print n\-Quantity of asterisks to the default Hyperterminal U\-A\-R\-T. \end{DoxyCompactList}\item 
int \hyperlink{utilities_8c_a8afbe3d97dead2d8cce254854eceae2a}{Spi\-R\-W} (u32 un\-Peripheral\-Address\-S\-P\-I, unsigned int un\-C\-P\-H\-A, unsigned int un\-C\-P\-O\-L, u8 $\ast$auch\-Write\-Buf, u8 $\ast$auch\-Read\-Buf, int un\-Num\-Bytes, u8 uch\-Cs\-Active\-High)
\begin{DoxyCompactList}\small\item\em Perform a S\-P\-I read or write. \end{DoxyCompactList}\item 
void \hyperlink{utilities_8c_a577eeffeb82895bf8ee72a7995ae144f}{delay} (int n\-Stop\-Value)
\begin{DoxyCompactList}\small\item\em Loop for n\-Stop\-Value iterations to provide a delay. \end{DoxyCompactList}\item 
void \hyperlink{utilities_8c_a71b3584d12efc81b2806f9fd385e5068}{led\-\_\-knight\-\_\-rider} (X\-Gpio $\ast$p\-L\-E\-D\-\_\-\-G\-P\-I\-O, int n\-Number\-Of\-Times)
\begin{DoxyCompactList}\small\item\em Blink a row of L\-E\-Ds n\-Number\-Of\-Times times. \end{DoxyCompactList}\item 
void \hyperlink{utilities_8c_a928f473c0f79c00f8393e753380737d5}{max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port} (u8 uch\-Pmod\-Port\-A, u8 uch\-Pmod\-Port\-B, u8 uch\-Pmod\-Port\-C, u8 uch\-Pmod\-Port\-D)
\begin{DoxyCompactList}\small\item\em Configure driving peripherals on each Pmod port. \end{DoxyCompactList}\item 
int \hyperlink{utilities_8c_a43452e828b311502b20f26b00601b25e}{check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present} ()
\begin{DoxyCompactList}\small\item\em Test for S\-D\-A and S\-C\-L pullups. \end{DoxyCompactList}\item 
int \hyperlink{utilities_8c_a9ec4604d2e5d321f202b28d8e454f48b}{number\-\_\-raised\-\_\-to\-\_\-power} (int n\-Base, int n\-Exponent)
\begin{DoxyCompactList}\small\item\em Raise n\-Base to the n\-Exponent power (operates with integers only). \end{DoxyCompactList}\item 
int \hyperlink{utilities_8c_ab4a6b8b0f9374b9b411f1d5fcf11405c}{receive\-\_\-byte\-\_\-with\-\_\-timeout} (u32 un\-Uart\-Address, int n\-Timeout\-In\-Tenths\-Of\-Seconds, u8 $\ast$uch\-Rx\-Data)
\begin{DoxyCompactList}\small\item\em Receive a byte from the U\-A\-R\-T located at $\ast$p\-Uart\-Address. \end{DoxyCompactList}\item 
int \hyperlink{utilities_8c_ab9425b60b1de203f59c42cbee8dab6bb}{Get\-Line} (char $\ast$s\-Input\-String, unsigned int un\-Max\-Size)
\begin{DoxyCompactList}\small\item\em Retrieve a line of characters from the default Hyperterminal U\-A\-R\-T (D\-E\-F\-A\-U\-L\-T\-\_\-\-H\-Y\-P\-E\-R\-T\-E\-R\-M\-I\-N\-A\-L\-\_\-\-U\-A\-R\-T). \end{DoxyCompactList}\item 
void \hyperlink{utilities_8c_a87c34d06f1fa3dd2b0f9e63e2494109c}{printf\-\_\-temp} (float f\-Temp, u8 uch\-Print\-Celsius, u8 uch\-Add\-Carriage\-Return)
\begin{DoxyCompactList}\small\item\em Print temperature as xx.\-x as degrees F or C. \end{DoxyCompactList}\item 
u8 \hyperlink{utilities_8c_afeb63a121e157a02df31ddb150e11ea3}{get\-Uart\-Byte} (u32 n\-Uart\-Address)
\begin{DoxyCompactList}\small\item\em Get a byte from either the full U\-A\-R\-T in the Zynq P\-S, or a Xilinx Uart\-Lite. \end{DoxyCompactList}\item 
int \hyperlink{utilities_8c_a56e95cdac6ef7cc8e6c3c84d62b0c774}{htoi} (char $\ast$s\-Str)
\end{DoxyCompactItemize}


\subsection{Detailed Description}


 \begin{DoxyVerb}      Project: Maxim Plug-in Peripheral Modules
     Filename: utilities.c
  Description: This module contains a collection of general utility
               functions which are not specific to any particular
               module.
\end{DoxyVerb}


Revision History\-: \par
 4-\/13-\/12 Rev 1.\-0 Seth Messimer Initial Release \par
 7-\/20-\/12 Rev 1.\-4 Nathan Young Additional functions 



This code follows the following naming conventions.

char ch\-Pmod\-Value char (array) s\-Pmod\-String\mbox{[}16\mbox{]} float f\-Pmod\-Value int n\-Pmod\-Value int (array) an\-Pmod\-Value\mbox{[}16\mbox{]} u16 u\-Pmod\-Value u8 uch\-Pmod\-Value u8 (array) auch\-Pmod\-Buffer\mbox{[}16\mbox{]} unsigned int un\-Pmod\-Value int $\ast$ pun\-Pmod\-Value 



Definition in file \hyperlink{utilities_8c_source}{utilities.\-c}.



\subsection{Function Documentation}
\hypertarget{utilities_8c_a43452e828b311502b20f26b00601b25e}{\index{utilities.\-c@{utilities.\-c}!check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present@{check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present}}
\index{check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present@{check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present}!utilities.c@{utilities.\-c}}
\subsubsection[{check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present}]{\setlength{\rightskip}{0pt plus 5cm}int check\-\_\-if\-\_\-i2c\-\_\-device\-\_\-is\-\_\-present (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a43452e828b311502b20f26b00601b25e}


Test for S\-D\-A and S\-C\-L pullups. 

\begin{DoxyParagraph}{Details}
This function places the P\-M\-O\-D A port into G\-P\-I\-O mode briefly in order to sample the S\-D\-A and S\-C\-L lines If they are high, then this implies that a pull-\/up is present, and hence a P\-M\-O\-D board is likely present
\end{DoxyParagraph}

\begin{DoxyParams}{Parameters}
{\em None} & \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\-R\-U\-E} & if pull-\/ups present, F\-A\-L\-S\-E if pullups not present \\
\hline
\end{DoxyRetVals}


Definition at line 261 of file utilities.\-c.

\hypertarget{utilities_8c_a577eeffeb82895bf8ee72a7995ae144f}{\index{utilities.\-c@{utilities.\-c}!delay@{delay}}
\index{delay@{delay}!utilities.c@{utilities.\-c}}
\subsubsection[{delay}]{\setlength{\rightskip}{0pt plus 5cm}void delay (
\begin{DoxyParamCaption}
\item[{int}]{n\-Stop\-Value}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a577eeffeb82895bf8ee72a7995ae144f}


Loop for n\-Stop\-Value iterations to provide a delay. 

\begin{DoxyParagraph}{Details}
It is commonly used with the constant 'A\-B\-O\-U\-T\-\_\-\-O\-N\-E\-\_\-\-S\-E\-C\-O\-N\-D' defined in maxim\-P\-M\-O\-D.\-h for setting approximate delays
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em n\-Stop\-Value} & -\/ number of iterations to loop\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em None} & \\
\hline
\end{DoxyRetVals}


Definition at line 165 of file utilities.\-c.

\hypertarget{utilities_8c_ab9425b60b1de203f59c42cbee8dab6bb}{\index{utilities.\-c@{utilities.\-c}!Get\-Line@{Get\-Line}}
\index{Get\-Line@{Get\-Line}!utilities.c@{utilities.\-c}}
\subsubsection[{Get\-Line}]{\setlength{\rightskip}{0pt plus 5cm}int Get\-Line (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{s\-Input\-String, }
\item[{unsigned int}]{un\-Max\-Size}
\end{DoxyParamCaption}
)}}\label{utilities_8c_ab9425b60b1de203f59c42cbee8dab6bb}


Retrieve a line of characters from the default Hyperterminal U\-A\-R\-T (D\-E\-F\-A\-U\-L\-T\-\_\-\-H\-Y\-P\-E\-R\-T\-E\-R\-M\-I\-N\-A\-L\-\_\-\-U\-A\-R\-T). 

\begin{DoxyParagraph}{Details}
Maximum number of characters can be specified. Function will timeout after 10 seconds.
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em s\-Input\-String} & -\/ pointer to buffer for input string \\
\hline
\mbox{\tt in}  & {\em un\-Max\-Size} & -\/ maximum number of characters to input\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\-R\-U\-E} & if operation succeeded \\
\hline
\end{DoxyRetVals}


Definition at line 393 of file utilities.\-c.

\hypertarget{utilities_8c_afeb63a121e157a02df31ddb150e11ea3}{\index{utilities.\-c@{utilities.\-c}!get\-Uart\-Byte@{get\-Uart\-Byte}}
\index{get\-Uart\-Byte@{get\-Uart\-Byte}!utilities.c@{utilities.\-c}}
\subsubsection[{get\-Uart\-Byte}]{\setlength{\rightskip}{0pt plus 5cm}u8 get\-Uart\-Byte (
\begin{DoxyParamCaption}
\item[{u32}]{n\-Uart\-Address}
\end{DoxyParamCaption}
)}}\label{utilities_8c_afeb63a121e157a02df31ddb150e11ea3}


Get a byte from either the full U\-A\-R\-T in the Zynq P\-S, or a Xilinx Uart\-Lite. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em un\-Uart\-Address.} & 32 bit U\-A\-R\-T address\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em Returns} & the next byte from the Uart Rx F\-I\-F\-O \\
\hline
\end{DoxyRetVals}


Definition at line 442 of file utilities.\-c.

\hypertarget{utilities_8c_a56e95cdac6ef7cc8e6c3c84d62b0c774}{\index{utilities.\-c@{utilities.\-c}!htoi@{htoi}}
\index{htoi@{htoi}!utilities.c@{utilities.\-c}}
\subsubsection[{htoi}]{\setlength{\rightskip}{0pt plus 5cm}int htoi (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{s\-Str}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a56e95cdac6ef7cc8e6c3c84d62b0c774}


Definition at line 457 of file utilities.\-c.

\hypertarget{utilities_8c_a71b3584d12efc81b2806f9fd385e5068}{\index{utilities.\-c@{utilities.\-c}!led\-\_\-knight\-\_\-rider@{led\-\_\-knight\-\_\-rider}}
\index{led\-\_\-knight\-\_\-rider@{led\-\_\-knight\-\_\-rider}!utilities.c@{utilities.\-c}}
\subsubsection[{led\-\_\-knight\-\_\-rider}]{\setlength{\rightskip}{0pt plus 5cm}void led\-\_\-knight\-\_\-rider (
\begin{DoxyParamCaption}
\item[{X\-Gpio $\ast$}]{p\-L\-E\-D\-\_\-\-G\-P\-I\-O, }
\item[{int}]{n\-Number\-Of\-Times}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a71b3584d12efc81b2806f9fd385e5068}


Blink a row of L\-E\-Ds n\-Number\-Of\-Times times. 

\begin{DoxyParagraph}{Details}
The Digilent N\-E\-X\-Y\-S-\/3 board has 8 green L\-E\-Ds located above the toggle switches. This function blinks them back/forth (a bit like the K\-I\-T\-T car from Knight Rider)
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em $\ast$p\-L\-E\-D\-\_\-\-G\-P\-I\-O} & -\/ address of the G\-P\-I\-O peripheral driving the L\-E\-Ds in Micro\-Blaze memory map\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em None} & \\
\hline
\end{DoxyRetVals}


Definition at line 186 of file utilities.\-c.

\hypertarget{utilities_8c_a928f473c0f79c00f8393e753380737d5}{\index{utilities.\-c@{utilities.\-c}!max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port@{max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port}}
\index{max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port@{max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port}!utilities.c@{utilities.\-c}}
\subsubsection[{max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port}]{\setlength{\rightskip}{0pt plus 5cm}void max\-\_\-configure\-\_\-\-P\-M\-O\-D\-\_\-port (
\begin{DoxyParamCaption}
\item[{u8}]{uch\-Pmod\-Port\-A, }
\item[{u8}]{uch\-Pmod\-Port\-B, }
\item[{u8}]{uch\-Pmod\-Port\-C, }
\item[{u8}]{uch\-Pmod\-Port\-D}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a928f473c0f79c00f8393e753380737d5}


Configure driving peripherals on each Pmod port. 

\begin{DoxyParagraph}{Details}
The Maxim H\-D\-L hardware design for the Nexys 3 includes a multiplexer on each P\-M\-O\-D port to allow I2\-C, S\-P\-I, G\-P\-I\-O, and U\-A\-R\-T functionality to be selected on each port. The standard configuration is (Port\-A = I2\-C, Port\-B = S\-P\-I, Port\-C = G\-P\-I\-O, Port\-D = U\-A\-R\-T) This function is used to set the standard configuration in the \hyperlink{_m_a_x_r_e_f_d_e_s14_8c_ae66f6b31b5ad750f1fe042a706a4e3d4}{main()} function, as well as to optionally change the port config. The 2-\/bit number used to define the port configuration is encoded as follows\-: \par
 00=U\-A\-R\-T, 01=S\-P\-I, 10=G\-P\-I\-O and 11=I2\-C
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em uch\-Pmod\-Port\-A} & -\/ 2-\/bit number to define configuration for Pmod port A \\
\hline
\mbox{\tt in}  & {\em uch\-Pmod\-Port\-B} & -\/ 2-\/bit number to define configuration for Pmod port B \\
\hline
\mbox{\tt in}  & {\em uch\-Pmod\-Port\-C} & -\/ 2-\/bit number to define configuration for Pmod port C \\
\hline
\mbox{\tt in}  & {\em uch\-Pmod\-Port\-D} & -\/ 2-\/bit number to define configuration for Pmod port D\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\-R\-U\-E} & if operation succeeded \\
\hline
\end{DoxyRetVals}


Definition at line 221 of file utilities.\-c.

\hypertarget{utilities_8c_a9ec4604d2e5d321f202b28d8e454f48b}{\index{utilities.\-c@{utilities.\-c}!number\-\_\-raised\-\_\-to\-\_\-power@{number\-\_\-raised\-\_\-to\-\_\-power}}
\index{number\-\_\-raised\-\_\-to\-\_\-power@{number\-\_\-raised\-\_\-to\-\_\-power}!utilities.c@{utilities.\-c}}
\subsubsection[{number\-\_\-raised\-\_\-to\-\_\-power}]{\setlength{\rightskip}{0pt plus 5cm}int number\-\_\-raised\-\_\-to\-\_\-power (
\begin{DoxyParamCaption}
\item[{int}]{n\-Base, }
\item[{int}]{n\-Exponent}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a9ec4604d2e5d321f202b28d8e454f48b}


Raise n\-Base to the n\-Exponent power (operates with integers only). 

\begin{DoxyParagraph}{Details}
Many Microblaze applications will not have math.\-h included due to limited memory space. This is a simple functions to implement (n\-Base $^\wedge$ n\-Exponent) Some Maxim devices (such as M\-A\-X44009) return values in mantissa + (power of 2) exponent format.
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em n\-Base} & -\/ base \\
\hline
\mbox{\tt in}  & {\em n\-Exponent} & -\/ exponent\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em Base$^\wedge$\-Exponent} & \\
\hline
\end{DoxyRetVals}


Definition at line 308 of file utilities.\-c.

\hypertarget{utilities_8c_a3635c0eee0c1ea6ccbd6f882e6ed233e}{\index{utilities.\-c@{utilities.\-c}!print\-\_\-asterisks@{print\-\_\-asterisks}}
\index{print\-\_\-asterisks@{print\-\_\-asterisks}!utilities.c@{utilities.\-c}}
\subsubsection[{print\-\_\-asterisks}]{\setlength{\rightskip}{0pt plus 5cm}void print\-\_\-asterisks (
\begin{DoxyParamCaption}
\item[{int}]{n\-Quantity}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a3635c0eee0c1ea6ccbd6f882e6ed233e}


Print n\-Quantity of asterisks to the default Hyperterminal U\-A\-R\-T. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em n\-Quantity} & -\/ number of asterisks to print\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em None} & \\
\hline
\end{DoxyRetVals}


Definition at line 64 of file utilities.\-c.

\hypertarget{utilities_8c_a87c34d06f1fa3dd2b0f9e63e2494109c}{\index{utilities.\-c@{utilities.\-c}!printf\-\_\-temp@{printf\-\_\-temp}}
\index{printf\-\_\-temp@{printf\-\_\-temp}!utilities.c@{utilities.\-c}}
\subsubsection[{printf\-\_\-temp}]{\setlength{\rightskip}{0pt plus 5cm}void printf\-\_\-temp (
\begin{DoxyParamCaption}
\item[{float}]{f\-Temp, }
\item[{u8}]{uch\-Print\-Celsius, }
\item[{u8}]{uch\-Add\-Carriage\-Return}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a87c34d06f1fa3dd2b0f9e63e2494109c}


Print temperature as xx.\-x as degrees F or C. 

\begin{DoxyParagraph}{Details}
This function prints the temperature with .1 degree resolution in either degrees \par
 Celsius (uch\-Print\-Celsius==T\-R\-U\-E) -\/or-\/ Fahrenheit (uch\-Print\-Celsius==F\-A\-L\-S\-E)
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em f\-Temp} & -\/ temperature to print in celsius \\
\hline
\mbox{\tt in}  & {\em uch\-Print\-Celsius} & -\/ true = print as celsius, false = print as fahrenheit \\
\hline
\mbox{\tt in}  & {\em uch\-Add\-Carriage\-Return} & -\/ true = add a carriage return\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em None} & \\
\hline
\end{DoxyRetVals}


Definition at line 420 of file utilities.\-c.

\hypertarget{utilities_8c_ab4a6b8b0f9374b9b411f1d5fcf11405c}{\index{utilities.\-c@{utilities.\-c}!receive\-\_\-byte\-\_\-with\-\_\-timeout@{receive\-\_\-byte\-\_\-with\-\_\-timeout}}
\index{receive\-\_\-byte\-\_\-with\-\_\-timeout@{receive\-\_\-byte\-\_\-with\-\_\-timeout}!utilities.c@{utilities.\-c}}
\subsubsection[{receive\-\_\-byte\-\_\-with\-\_\-timeout}]{\setlength{\rightskip}{0pt plus 5cm}int receive\-\_\-byte\-\_\-with\-\_\-timeout (
\begin{DoxyParamCaption}
\item[{u32}]{un\-Uart\-Address, }
\item[{int}]{n\-Timeout\-In\-Tenths\-Of\-Seconds, }
\item[{u8 $\ast$}]{uch\-Rx\-Data}
\end{DoxyParamCaption}
)}}\label{utilities_8c_ab4a6b8b0f9374b9b411f1d5fcf11405c}


Receive a byte from the U\-A\-R\-T located at $\ast$p\-Uart\-Address. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em un\-Uart\-Address} & -\/ address of the U\-A\-R\-T peripheral in Micro\-Blaze memory map  \\
\hline
\mbox{\tt in}  & {\em n\-Timeout\-In\-Tenths\-Of\-Seconds} & -\/ amount of time to allow before T\-I\-M\-E\-O\-U\-T \\
\hline
\mbox{\tt out}  & {\em $\ast$uch\-Rx\-Data} & -\/ received data is stored at uch\-Rx\-Data\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em T\-R\-U\-E} & if operation succeeded \\
\hline
\end{DoxyRetVals}


Definition at line 337 of file utilities.\-c.

\hypertarget{utilities_8c_a8afbe3d97dead2d8cce254854eceae2a}{\index{utilities.\-c@{utilities.\-c}!Spi\-R\-W@{Spi\-R\-W}}
\index{Spi\-R\-W@{Spi\-R\-W}!utilities.c@{utilities.\-c}}
\subsubsection[{Spi\-R\-W}]{\setlength{\rightskip}{0pt plus 5cm}int Spi\-R\-W (
\begin{DoxyParamCaption}
\item[{u32}]{un\-Peripheral\-Address\-S\-P\-I, }
\item[{unsigned int}]{un\-C\-P\-H\-A, }
\item[{unsigned int}]{un\-C\-P\-O\-L, }
\item[{u8 $\ast$}]{auch\-Write\-Buf, }
\item[{u8 $\ast$}]{auch\-Read\-Buf, }
\item[{int}]{un\-Num\-Bytes, }
\item[{u8}]{uch\-Cs\-Active\-High}
\end{DoxyParamCaption}
)}}\label{utilities_8c_a8afbe3d97dead2d8cce254854eceae2a}


Perform a S\-P\-I read or write. 

\begin{DoxyParagraph}{Details}
This function provides a combination S\-P\-I Read and Write to the chosen S\-P\-I port in the design C\-P\-H\-A and C\-P\-O\-L can be set to 0 or 1 Pointers are provided to u8 buffers containing the data to be written and received Data in the auch\-Write\-Buf will be clocked out (M\-S\-B first) onto the M\-O\-S\-I pin Data from the M\-I\-S\-O pin will be placed into the auch\-Read\-Buf uch\-Cs\-Active\-High==T\-R\-U\-E allows S\-S configurations to be used uch\-Cs\-Active\-High==F\-A\-L\-S\-E allows S\-S\# configurations to be used
\end{DoxyParagraph}

\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em un\-Peripheral\-Address\-S\-P\-I} & -\/  \\
\hline
\mbox{\tt in}  & {\em un\-C\-P\-H\-A} & -\/ phase of S\-C\-K (edge to trigger on). 0=Leading edge, 1=Trailing edge \\
\hline
\mbox{\tt in}  & {\em un\-C\-P\-O\-L} & -\/ polarity of S\-C\-K. 0=Active high, 1=Active low \\
\hline
\mbox{\tt in}  & {\em auch\-Write\-Buf} & -\/ pointer to write data buffer \\
\hline
\mbox{\tt in}  & {\em auch\-Read\-Buf} & -\/ pointer to read data buffer \\
\hline
\mbox{\tt in}  & {\em un\-Num\-Bytes} & -\/ number of bytes to transfer \\
\hline
\mbox{\tt in}  & {\em uch\-Cs\-Active\-High} & -\/ polarity of slave select 0=active low, 1=active high\\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em Always} & returns 0 \\
\hline
\end{DoxyRetVals}


Definition at line 78 of file utilities.\-c.

