\hypertarget{usart1_8c}{
\section{usart1.c File Reference}
\label{usart1_8c}\index{usart1.c@{usart1.c}}
}
{\tt \#include \char`\"{}usart1.h\char`\"{}}\par
{\tt \#include $<$config.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void \hyperlink{usart1_8c_9289b5b6564d73e36ffa6811ee8def1f}{USART\_\-init} (uint16\_\-t baudval)
\begin{CompactList}\small\item\em Initialise USART and set baud rate. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_439575d82f67481708c7b028d7452038}{USART\_\-transmit} (uint8\_\-t data)
\item 
void \hyperlink{usart1_8c_64e012dc3e87a5ddc34bc9597add7d19}{USART\_\-transmit\_\-string} (const unsigned char $\ast$data)
\begin{CompactList}\small\item\em Transmit a string via USART at currently set baud rate. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_4b574b5e7c6f8eb1d315da406c0a2d51}{USART\_\-transmit\_\-uint8} (uint8\_\-t val)
\begin{CompactList}\small\item\em Transmit an 8 bit unsigned integer via USART at currently set baud rate. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_3178f6d0eb495a693af5a249ce2036a2}{USART\_\-transmit\_\-int8} (int8\_\-t val)
\begin{CompactList}\small\item\em Transmit an 8 bit signed integer via USART at currently set baud rate. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_92c401c12a2fd4961d7fc0ad4edfb9ac}{USART\_\-transmit\_\-uint16} (uint16\_\-t val)
\begin{CompactList}\small\item\em Transmit a 16 bit unsigned integer via USART at currently set baud rate. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_f16f862b58f80b07870cc2604066ad3b}{USART\_\-transmit\_\-int16} (int16\_\-t val)
\begin{CompactList}\small\item\em Transmit a 16 bit signed integer via USART at currently set baud rate. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_89ba8d1cd4d672e7f2e34f2e9227cfdb}{USART\_\-transmit\_\-bin} (uint8\_\-t val)
\begin{CompactList}\small\item\em Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_9360f38a6281993d0a257205bd8b9257}{USART\_\-transmit\_\-nibble} (uint8\_\-t nibble)
\begin{CompactList}\small\item\em Transmit the lowest 4 bits of an 8 bit unsigned integer as a single ASCII character 0-9 or A-F. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_12c23e5a67bbdaf8fcfdb22b884ac2e4}{USART\_\-transmit\_\-hex} (uint8\_\-t val)
\item 
uint8\_\-t \hyperlink{usart1_8c_39da855ebda2abf7e05bd3b55ddd2b3b}{USART\_\-receive} (void)
\begin{CompactList}\small\item\em Receive an 8 bit value from the USART by polling. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_c06eea6a5d5067e9a6584e4f64a47935}{USART\_\-flush} (void)
\begin{CompactList}\small\item\em Repeatedly receive and discard values received by the USART until the input buffer empties. \item\end{CompactList}\item 
void \hyperlink{usart1_8c_6cf7c04e5ebf3123b59e0450814f8e39}{usart\_\-out\_\-iso\_\-time} (uint8\_\-t $\ast$time\_\-store)
\begin{CompactList}\small\item\em Output a time value in ISO format, from data stored in memory. \item\end{CompactList}\end{CompactItemize}


\subsection{Function Documentation}
\hypertarget{usart1_8c_c06eea6a5d5067e9a6584e4f64a47935}{
\index{usart1.c@{usart1.c}!USART\_\-flush@{USART\_\-flush}}
\index{USART\_\-flush@{USART\_\-flush}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-flush}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-flush (void)}}
\label{usart1_8c_c06eea6a5d5067e9a6584e4f64a47935}


Repeatedly receive and discard values received by the USART until the input buffer empties. 

Uses polling.

Note that in the event of continuous input, this function may never complete. \hypertarget{usart1_8c_9289b5b6564d73e36ffa6811ee8def1f}{
\index{usart1.c@{usart1.c}!USART\_\-init@{USART\_\-init}}
\index{USART\_\-init@{USART\_\-init}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-init}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-init (uint16\_\-t {\em baudval})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{usart1_8c_9289b5b6564d73e36ffa6811ee8def1f}


Initialise USART and set baud rate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em baudval}]Value to put in UBRR to selectbaud rate.\end{description}
\end{Desc}
Initialise USART on microcontrollers where there is a single USART which doesn't use the newer register and bit position names which include a USART number

The baudval parameter will depend on the CPU clock frequency see the tables in the microcontroller documentation for suitable values

Clears any existing transmissions, turns off double speed, enables transmitter and receiver.

Note that this initialisation DOESN'T enable the interrupts Rx complete and Tx Complete \hypertarget{usart1_8c_6cf7c04e5ebf3123b59e0450814f8e39}{
\index{usart1.c@{usart1.c}!usart\_\-out\_\-iso\_\-time@{usart\_\-out\_\-iso\_\-time}}
\index{usart\_\-out\_\-iso\_\-time@{usart\_\-out\_\-iso\_\-time}!usart1.c@{usart1.c}}
\subsubsection[{usart\_\-out\_\-iso\_\-time}]{\setlength{\rightskip}{0pt plus 5cm}void usart\_\-out\_\-iso\_\-time (uint8\_\-t $\ast$ {\em time\_\-store})}}
\label{usart1_8c_6cf7c04e5ebf3123b59e0450814f8e39}


Output a time value in ISO format, from data stored in memory. 

Output a time value in ISO format to USART, from data stored in memory.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em time\_\-store}]Pointer to 7 BCD values representing in order seconds,minutes,hours,day,month,day of week(ignored),year.\end{description}
\end{Desc}
Takes a set of values representing a time (typically in the order received from a RTC chip) and outputs them via the USART in an ISO like format:

15:23:00 on 3rd April 2010 would be \char`\"{}2010-04-03	15:23:00\char`\"{}

Uses polling. Calls USART\_\-transmit and USART\_\-transmit\_\-hex \hypertarget{usart1_8c_39da855ebda2abf7e05bd3b55ddd2b3b}{
\index{usart1.c@{usart1.c}!USART\_\-receive@{USART\_\-receive}}
\index{USART\_\-receive@{USART\_\-receive}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-receive}]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t USART\_\-receive (void)}}
\label{usart1_8c_39da855ebda2abf7e05bd3b55ddd2b3b}


Receive an 8 bit value from the USART by polling. 

\begin{Desc}
\item[Returns:]value Value received.\end{Desc}
Uses polling, so waits for receive buffer to fill before returning. \hypertarget{usart1_8c_439575d82f67481708c7b028d7452038}{
\index{usart1.c@{usart1.c}!USART\_\-transmit@{USART\_\-transmit}}
\index{USART\_\-transmit@{USART\_\-transmit}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit (uint8\_\-t {\em data})}}
\label{usart1_8c_439575d82f67481708c7b028d7452038}


\hypertarget{usart1_8c_89ba8d1cd4d672e7f2e34f2e9227cfdb}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-bin@{USART\_\-transmit\_\-bin}}
\index{USART\_\-transmit\_\-bin@{USART\_\-transmit\_\-bin}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-bin}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-bin (uint8\_\-t {\em val})}}
\label{usart1_8c_89ba8d1cd4d672e7f2e34f2e9227cfdb}


Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]Value to transmit.\end{description}
\end{Desc}
Transmit an 8 bit unsigned integer as eight ASCII characters 0 or 1.

Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty before appending new characters \hypertarget{usart1_8c_12c23e5a67bbdaf8fcfdb22b884ac2e4}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-hex@{USART\_\-transmit\_\-hex}}
\index{USART\_\-transmit\_\-hex@{USART\_\-transmit\_\-hex}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-hex}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-hex (uint8\_\-t {\em val})}}
\label{usart1_8c_12c23e5a67bbdaf8fcfdb22b884ac2e4}


\hypertarget{usart1_8c_f16f862b58f80b07870cc2604066ad3b}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-int16@{USART\_\-transmit\_\-int16}}
\index{USART\_\-transmit\_\-int16@{USART\_\-transmit\_\-int16}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-int16}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-int16 (int16\_\-t {\em val})}}
\label{usart1_8c_f16f862b58f80b07870cc2604066ad3b}


Transmit a 16 bit signed integer via USART at currently set baud rate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]value to transmit.\end{description}
\end{Desc}
Transmit a 16 bit signed integer via the USART, as an optional minus sign followed by up to five decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty before appending new characters \hypertarget{usart1_8c_3178f6d0eb495a693af5a249ce2036a2}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-int8@{USART\_\-transmit\_\-int8}}
\index{USART\_\-transmit\_\-int8@{USART\_\-transmit\_\-int8}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-int8}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-int8 (int8\_\-t {\em val})}}
\label{usart1_8c_3178f6d0eb495a693af5a249ce2036a2}


Transmit an 8 bit signed integer via USART at currently set baud rate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]Value to transmit.\end{description}
\end{Desc}
Transmit an 8 bit signed integer via the USART, as an optional minus sign followed by up to three decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty before appending new characters \hypertarget{usart1_8c_9360f38a6281993d0a257205bd8b9257}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-nibble@{USART\_\-transmit\_\-nibble}}
\index{USART\_\-transmit\_\-nibble@{USART\_\-transmit\_\-nibble}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-nibble}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-nibble (uint8\_\-t {\em nibble})}}
\label{usart1_8c_9360f38a6281993d0a257205bd8b9257}


Transmit the lowest 4 bits of an 8 bit unsigned integer as a single ASCII character 0-9 or A-F. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em nibble}]Value to transmit.\end{description}
\end{Desc}
Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty before appending new characters \hypertarget{usart1_8c_64e012dc3e87a5ddc34bc9597add7d19}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-string@{USART\_\-transmit\_\-string}}
\index{USART\_\-transmit\_\-string@{USART\_\-transmit\_\-string}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-string}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-string (const unsigned char $\ast$ {\em data})\hspace{0.3cm}{\tt  \mbox{[}inline\mbox{]}}}}
\label{usart1_8c_64e012dc3e87a5ddc34bc9597add7d19}


Transmit a string via USART at currently set baud rate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em data}]Pointer to start of string.\end{description}
\end{Desc}
Transmit a string via the USART, using polling, not interrutps. Doesn't change baud rate. Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty \hypertarget{usart1_8c_92c401c12a2fd4961d7fc0ad4edfb9ac}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-uint16@{USART\_\-transmit\_\-uint16}}
\index{USART\_\-transmit\_\-uint16@{USART\_\-transmit\_\-uint16}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-uint16}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-uint16 (uint16\_\-t {\em val})}}
\label{usart1_8c_92c401c12a2fd4961d7fc0ad4edfb9ac}


Transmit a 16 bit unsigned integer via USART at currently set baud rate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]Value to transmit.\end{description}
\end{Desc}
Transmit a 16 bit unsigned integer via the USART, as a series of up to five decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty before appending new characters \hypertarget{usart1_8c_4b574b5e7c6f8eb1d315da406c0a2d51}{
\index{usart1.c@{usart1.c}!USART\_\-transmit\_\-uint8@{USART\_\-transmit\_\-uint8}}
\index{USART\_\-transmit\_\-uint8@{USART\_\-transmit\_\-uint8}!usart1.c@{usart1.c}}
\subsubsection[{USART\_\-transmit\_\-uint8}]{\setlength{\rightskip}{0pt plus 5cm}void USART\_\-transmit\_\-uint8 (uint8\_\-t {\em val})}}
\label{usart1_8c_4b574b5e7c6f8eb1d315da406c0a2d51}


Transmit an 8 bit unsigned integer via USART at currently set baud rate. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em val}]Character to transmit.\end{description}
\end{Desc}
Transmit an 8 bit unsigned integer via the USART, as a series of up to three decimal characters, using polling, not interrutps. Doesn't output leading zeroes, so number of characters transmitted may vary. Doesn't interrupt any existing transmit already in progress.

Uses polling, so waits for transmit buffer to be empty before appending new characters 