\section{aversive\_\-10-03-12/modules/comm/uart/uart\_\-host.c File Reference}
\label{uart__host_8c}\index{aversive\_\-10-03-12/modules/comm/uart/uart\_\-host.c@{aversive\_\-10-03-12/modules/comm/uart/uart\_\-host.c}}
{\tt \#include $<$uart.h$>$}\par
{\tt \#include $<$uart\_\-private.h$>$}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf uart\_\-init} (void)
\item 
int8\_\-t {\bf uart\_\-setconf} (uint8\_\-t num, struct {\bf uart\_\-config} $\ast$u)
\item 
void {\bf uart\_\-getconf} (uint8\_\-t num, struct {\bf uart\_\-config} $\ast$u)
\item 
int {\bf uart\_\-recv} (uint8\_\-t num)
\item 
int {\bf uart\_\-send\_\-nowait} (uint8\_\-t num, char c)
\item 
int {\bf uart\_\-send} (uint8\_\-t num, char c)
\item 
void {\bf uart\_\-register\_\-tx\_\-event} (uint8\_\-t num, void($\ast$f)(char))
\item 
void {\bf uart\_\-register\_\-rx\_\-event} (uint8\_\-t num, void($\ast$f)(char))
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
{\bf event} $\ast$ {\bf rx\_\-event} [UART\_\-HW\_\-NUM]
\item 
{\bf event} $\ast$ {\bf tx\_\-event} [UART\_\-HW\_\-NUM]
\end{CompactItemize}


\subsection{Function Documentation}
\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-getconf@{uart\_\-getconf}}
\index{uart\_\-getconf@{uart\_\-getconf}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-getconf]{\setlength{\rightskip}{0pt plus 5cm}void uart\_\-getconf (uint8\_\-t {\em num}, \/  struct {\bf uart\_\-config} $\ast$ {\em u})}\label{uart__host_8c_8b254078fe61199632993cbeabd12023}


Get the current configuration of the uart 'num' 

Definition at line 43 of file uart\_\-host.c.\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-init@{uart\_\-init}}
\index{uart\_\-init@{uart\_\-init}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void uart\_\-init (void)}\label{uart__host_8c_0c0ca72359ddf28dcd15900dfba19343}


Initialisation function. This function puts the registers of the microcontroler in a correct state in order to use the uart. It uses the configuration file $<$uart\_\-config.h$>$ ; this function is equivalent to call uartX\_\-setconf(NULL) for each uart. 

Definition at line 30 of file uart\_\-host.c.

References uart\_\-setconf().\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-recv@{uart\_\-recv}}
\index{uart\_\-recv@{uart\_\-recv}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-recv]{\setlength{\rightskip}{0pt plus 5cm}int uart\_\-recv (uint8\_\-t {\em num})}\label{uart__host_8c_f2868eb5b1a02c5fa1ecee7bab7f2dc6}


uart\_\-recv returns the next character, taken from the fifo (if any). If there is nothing to read, the function waits until something come on the uart. 

Definition at line 47 of file uart\_\-host.c.\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-register\_\-rx\_\-event@{uart\_\-register\_\-rx\_\-event}}
\index{uart\_\-register\_\-rx\_\-event@{uart\_\-register\_\-rx\_\-event}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-register\_\-rx\_\-event]{\setlength{\rightskip}{0pt plus 5cm}void uart\_\-register\_\-rx\_\-event (uint8\_\-t {\em num}, \/  void($\ast$)(char) {\em f})}\label{uart__host_8c_cf2c6bdeda5b85cd4555024655834278}


This function is used to register another function which will be executed at each byte reception (5, 6 ,7 ,8 bits) 

Definition at line 67 of file uart\_\-host.c.

References parse\_\-symbols::f, and rx\_\-event.\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-register\_\-tx\_\-event@{uart\_\-register\_\-tx\_\-event}}
\index{uart\_\-register\_\-tx\_\-event@{uart\_\-register\_\-tx\_\-event}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-register\_\-tx\_\-event]{\setlength{\rightskip}{0pt plus 5cm}void uart\_\-register\_\-tx\_\-event (uint8\_\-t {\em num}, \/  void($\ast$)(char) {\em f})}\label{uart__host_8c_d9aeffe9f0d6629d5967dc4651e9eb06}


This function is used to register another function which will be executed at each byte transmission (5, 6 ,7 ,8 bits) 

Definition at line 62 of file uart\_\-host.c.

References parse\_\-symbols::f, and tx\_\-event.\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-send@{uart\_\-send}}
\index{uart\_\-send@{uart\_\-send}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-send]{\setlength{\rightskip}{0pt plus 5cm}int uart\_\-send (uint8\_\-t {\em num}, \/  char {\em c})}\label{uart__host_8c_d703d5aa05cbfeadc6d2499aefb2cc92}


uart\_\-send is used to send data to the uart 'num'. The data is first stored in the FIFO before beeing sent. If the FIFO is full, the function wait until the uart is ready. The function returns c. 

Definition at line 57 of file uart\_\-host.c.\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-send\_\-nowait@{uart\_\-send\_\-nowait}}
\index{uart\_\-send\_\-nowait@{uart\_\-send\_\-nowait}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-send\_\-nowait]{\setlength{\rightskip}{0pt plus 5cm}int uart\_\-send\_\-nowait (uint8\_\-t {\em num}, \/  char {\em c})}\label{uart__host_8c_ecd7c63e7c51ee5922ceb6229354b895}


uart\_\-send\_\-nowait is used to send data to the uart 'num'. The data is first stored in the FIFO before beeing sent. If the FIFO is full, data is dropped and the function returns -1, else it returns the character c. 

Definition at line 52 of file uart\_\-host.c.\index{uart\_\-host.c@{uart\_\-host.c}!uart\_\-setconf@{uart\_\-setconf}}
\index{uart\_\-setconf@{uart\_\-setconf}!uart_host.c@{uart\_\-host.c}}
\subsubsection[uart\_\-setconf]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t uart\_\-setconf (uint8\_\-t {\em num}, \/  struct {\bf uart\_\-config} $\ast$ {\em u})}\label{uart__host_8c_b6107b6bd3a29f6c8d7da52da726ea27}


Configure the uart 'num' with the given configuration. Returns 0 on success. 

Definition at line 38 of file uart\_\-host.c.

\subsection{Variable Documentation}
\index{uart\_\-host.c@{uart\_\-host.c}!rx\_\-event@{rx\_\-event}}
\index{rx\_\-event@{rx\_\-event}!uart_host.c@{uart\_\-host.c}}
\subsubsection[rx\_\-event]{\setlength{\rightskip}{0pt plus 5cm}{\bf event}$\ast$ {\bf rx\_\-event}[UART\_\-HW\_\-NUM]}\label{uart__host_8c_f7d146cd775aa8ee3d58d56dc007c15d}




Definition at line 35 of file uart\_\-host.c.\index{uart\_\-host.c@{uart\_\-host.c}!tx\_\-event@{tx\_\-event}}
\index{tx\_\-event@{tx\_\-event}!uart_host.c@{uart\_\-host.c}}
\subsubsection[tx\_\-event]{\setlength{\rightskip}{0pt plus 5cm}{\bf event}$\ast$ {\bf tx\_\-event}[UART\_\-HW\_\-NUM]}\label{uart__host_8c_81015e0afbe262f229d5bc46c7720791}




Definition at line 36 of file uart\_\-host.c.