\section{aversive\_\-10-03-12/modules/comm/mf2\_\-server/mf2\_\-server.c File Reference}
\label{mf2__server_8c}\index{aversive\_\-10-03-12/modules/comm/mf2\_\-server/mf2\_\-server.c@{aversive\_\-10-03-12/modules/comm/mf2\_\-server/mf2\_\-server.c}}
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$aversive.h$>$}\par
{\tt \#include $<$aversive/wait.h$>$}\par
{\tt \#include $<$timer.h$>$}\par
{\tt \#include $<$mf2\_\-server.h$>$}\par
{\tt \#include $<$mf2\_\-server\_\-config.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf data\_\-Z}()~do \{ cbi(DDR(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT); \} while(0)
\item 
\#define {\bf data\_\-0}()~do \{ sbi(DDR(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT); \} while(0)
\item 
\#define {\bf read\_\-data}()~(bit\_\-is\_\-set(PIN(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT))
\item 
\#define {\bf data\_\-is\_\-Z}()~(!bit\_\-is\_\-set(DDR(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT))
\item 
\#define {\bf clk\_\-Z}()~do \{ cbi(DDR(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT); \} while(0)
\item 
\#define {\bf clk\_\-0}()~do \{ sbi(DDR(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT); \} while(0)
\item 
\#define {\bf read\_\-clk}()~(bit\_\-is\_\-set(PIN(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT))
\item 
\#define {\bf clk\_\-is\_\-Z}()~(!bit\_\-is\_\-set(DDR(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT))
\item 
\#define {\bf MF2\_\-SERVER\_\-STATE\_\-READY}~0
\item 
\#define {\bf MF2\_\-SERVER\_\-STATE\_\-SEND}~1
\item 
\#define {\bf MF2\_\-SERVER\_\-STATE\_\-RECV}~2
\item 
\#define {\bf WAIT\_\-KBD\_\-CYCLE}~600
\item 
\#define {\bf WAIT\_\-KBD\_\-CYCLE4}~WAIT\_\-KBD\_\-CYCLE/4
\item 
\#define {\bf dump}()~do \{\} while(0)
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef void( {\bf event} )(char)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf recv} (void)
\item 
int8\_\-t {\bf mf2\_\-server\_\-ready} (void)
\item 
void {\bf disp} (char c)
\item 
void {\bf mf2\_\-server\_\-timer\_\-cb} (void)
\item 
int8\_\-t {\bf mf2\_\-server\_\-send} (char c)
\item 
void {\bf mf2\_\-server\_\-init} (void)
\item 
void {\bf mf2\_\-server\_\-register\_\-tx\_\-event} (void($\ast$f)(char))
\item 
void {\bf mf2\_\-server\_\-register\_\-rx\_\-event} (void($\ast$f)(char))
\end{CompactItemize}


\subsection{Define Documentation}
\index{mf2\_\-server.c@{mf2\_\-server.c}!clk\_\-0@{clk\_\-0}}
\index{clk\_\-0@{clk\_\-0}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[clk\_\-0]{\setlength{\rightskip}{0pt plus 5cm}\#define clk\_\-0()~do \{ sbi(DDR(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT); \} while(0)}\label{mf2__server_8c_69bfb1522cca8e1ae6de81e260819d18}




Definition at line 39 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!clk\_\-is\_\-Z@{clk\_\-is\_\-Z}}
\index{clk\_\-is\_\-Z@{clk\_\-is\_\-Z}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[clk\_\-is\_\-Z]{\setlength{\rightskip}{0pt plus 5cm}\#define clk\_\-is\_\-Z()~(!bit\_\-is\_\-set(DDR(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT))}\label{mf2__server_8c_aee74d928c6b1c8439f7b4e028f67b7d}




Definition at line 41 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!clk\_\-Z@{clk\_\-Z}}
\index{clk\_\-Z@{clk\_\-Z}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[clk\_\-Z]{\setlength{\rightskip}{0pt plus 5cm}\#define clk\_\-Z()~do \{ cbi(DDR(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT); \} while(0)}\label{mf2__server_8c_3b657dbaf8a8cb4013c8a547e5689f8a}




Definition at line 38 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!data\_\-0@{data\_\-0}}
\index{data\_\-0@{data\_\-0}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[data\_\-0]{\setlength{\rightskip}{0pt plus 5cm}\#define data\_\-0()~do \{ sbi(DDR(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT); \} while(0)}\label{mf2__server_8c_f4a0f0ad8f7c6c3a045da59788993dc2}




Definition at line 34 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!data\_\-is\_\-Z@{data\_\-is\_\-Z}}
\index{data\_\-is\_\-Z@{data\_\-is\_\-Z}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[data\_\-is\_\-Z]{\setlength{\rightskip}{0pt plus 5cm}\#define data\_\-is\_\-Z()~(!bit\_\-is\_\-set(DDR(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT))}\label{mf2__server_8c_a52331cf007bb5424a65f3cb6e56caad}




Definition at line 36 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!data\_\-Z@{data\_\-Z}}
\index{data\_\-Z@{data\_\-Z}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[data\_\-Z]{\setlength{\rightskip}{0pt plus 5cm}\#define data\_\-Z()~do \{ cbi(DDR(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT); \} while(0)}\label{mf2__server_8c_d0d516cba3150ec427bef2d53e29304b}




Definition at line 33 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!dump@{dump}}
\index{dump@{dump}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[dump]{\setlength{\rightskip}{0pt plus 5cm}\#define dump()~do \{\} while(0)}\label{mf2__server_8c_053ecfbc8be0a94249e7d76eaf4f963f}




Definition at line 147 of file mf2\_\-server.c.

Referenced by mf2\_\-server\_\-timer\_\-cb().\index{mf2\_\-server.c@{mf2\_\-server.c}!MF2\_\-SERVER\_\-STATE\_\-READY@{MF2\_\-SERVER\_\-STATE\_\-READY}}
\index{MF2\_\-SERVER\_\-STATE\_\-READY@{MF2\_\-SERVER\_\-STATE\_\-READY}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[MF2\_\-SERVER\_\-STATE\_\-READY]{\setlength{\rightskip}{0pt plus 5cm}\#define MF2\_\-SERVER\_\-STATE\_\-READY~0}\label{mf2__server_8c_399f9ce4fb2f1b6e51ac4dc9c7f522ae}




Definition at line 43 of file mf2\_\-server.c.

Referenced by mf2\_\-server\_\-ready(), and mf2\_\-server\_\-timer\_\-cb().\index{mf2\_\-server.c@{mf2\_\-server.c}!MF2\_\-SERVER\_\-STATE\_\-RECV@{MF2\_\-SERVER\_\-STATE\_\-RECV}}
\index{MF2\_\-SERVER\_\-STATE\_\-RECV@{MF2\_\-SERVER\_\-STATE\_\-RECV}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[MF2\_\-SERVER\_\-STATE\_\-RECV]{\setlength{\rightskip}{0pt plus 5cm}\#define MF2\_\-SERVER\_\-STATE\_\-RECV~2}\label{mf2__server_8c_23d8cc8a5af5d91512ccada5ab996a4a}




Definition at line 45 of file mf2\_\-server.c.

Referenced by mf2\_\-server\_\-timer\_\-cb().\index{mf2\_\-server.c@{mf2\_\-server.c}!MF2\_\-SERVER\_\-STATE\_\-SEND@{MF2\_\-SERVER\_\-STATE\_\-SEND}}
\index{MF2\_\-SERVER\_\-STATE\_\-SEND@{MF2\_\-SERVER\_\-STATE\_\-SEND}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[MF2\_\-SERVER\_\-STATE\_\-SEND]{\setlength{\rightskip}{0pt plus 5cm}\#define MF2\_\-SERVER\_\-STATE\_\-SEND~1}\label{mf2__server_8c_4808a99fe303d9890f62250454c82db9}




Definition at line 44 of file mf2\_\-server.c.

Referenced by mf2\_\-server\_\-send().\index{mf2\_\-server.c@{mf2\_\-server.c}!read\_\-clk@{read\_\-clk}}
\index{read\_\-clk@{read\_\-clk}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[read\_\-clk]{\setlength{\rightskip}{0pt plus 5cm}\#define read\_\-clk()~(bit\_\-is\_\-set(PIN(MF2\_\-SERVER\_\-CLK\_\-PORT), MF2\_\-SERVER\_\-CLK\_\-BIT))}\label{mf2__server_8c_068508fd0a63e1d9c1b96ea156dfe6dd}




Definition at line 40 of file mf2\_\-server.c.

Referenced by mf2\_\-server\_\-timer\_\-cb().\index{mf2\_\-server.c@{mf2\_\-server.c}!read\_\-data@{read\_\-data}}
\index{read\_\-data@{read\_\-data}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[read\_\-data]{\setlength{\rightskip}{0pt plus 5cm}\#define read\_\-data()~(bit\_\-is\_\-set(PIN(MF2\_\-SERVER\_\-DATA\_\-PORT), MF2\_\-SERVER\_\-DATA\_\-BIT))}\label{mf2__server_8c_07de2b68d903bb20b12217f0054724df}




Definition at line 35 of file mf2\_\-server.c.

Referenced by mf2\_\-server\_\-timer\_\-cb(), and recv().\index{mf2\_\-server.c@{mf2\_\-server.c}!WAIT\_\-KBD\_\-CYCLE@{WAIT\_\-KBD\_\-CYCLE}}
\index{WAIT\_\-KBD\_\-CYCLE@{WAIT\_\-KBD\_\-CYCLE}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[WAIT\_\-KBD\_\-CYCLE]{\setlength{\rightskip}{0pt plus 5cm}\#define WAIT\_\-KBD\_\-CYCLE~600}\label{mf2__server_8c_b17b24b187e6e7581cb7cc1023eac272}




Definition at line 58 of file mf2\_\-server.c.\index{mf2\_\-server.c@{mf2\_\-server.c}!WAIT\_\-KBD\_\-CYCLE4@{WAIT\_\-KBD\_\-CYCLE4}}
\index{WAIT\_\-KBD\_\-CYCLE4@{WAIT\_\-KBD\_\-CYCLE4}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[WAIT\_\-KBD\_\-CYCLE4]{\setlength{\rightskip}{0pt plus 5cm}\#define WAIT\_\-KBD\_\-CYCLE4~WAIT\_\-KBD\_\-CYCLE/4}\label{mf2__server_8c_5a70ef393236241b11ed08df2f3b4fc2}




Definition at line 59 of file mf2\_\-server.c.

Referenced by recv().

\subsection{Typedef Documentation}
\index{mf2\_\-server.c@{mf2\_\-server.c}!event@{event}}
\index{event@{event}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[event]{\setlength{\rightskip}{0pt plus 5cm}typedef void( {\bf event})(char)}\label{mf2__server_8c_c002e5ef6b25541b21fa588f567903fa}




Definition at line 49 of file mf2\_\-server.c.

\subsection{Function Documentation}
\index{mf2\_\-server.c@{mf2\_\-server.c}!disp@{disp}}
\index{disp@{disp}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[disp]{\setlength{\rightskip}{0pt plus 5cm}void disp (char {\em c})}\label{mf2__server_8c_646d91dc9bbdb7b1fc9d17bdf6e717eb}


\index{mf2\_\-server.c@{mf2\_\-server.c}!mf2\_\-server\_\-init@{mf2\_\-server\_\-init}}
\index{mf2\_\-server\_\-init@{mf2\_\-server\_\-init}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[mf2\_\-server\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void mf2\_\-server\_\-init (void)}\label{mf2__server_8c_ca09c735a1b79ab011f6e96e6332c776}




Definition at line 362 of file mf2\_\-server.c.

References cbi, clk\_\-Z, data\_\-Z, and mf2\_\-server\_\-timer\_\-cb().\index{mf2\_\-server.c@{mf2\_\-server.c}!mf2\_\-server\_\-ready@{mf2\_\-server\_\-ready}}
\index{mf2\_\-server\_\-ready@{mf2\_\-server\_\-ready}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[mf2\_\-server\_\-ready]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t mf2\_\-server\_\-ready (void)}\label{mf2__server_8c_89120039f5d390a700a7ac23772d0994}




Definition at line 122 of file mf2\_\-server.c.

References MF2\_\-SERVER\_\-STATE\_\-READY.

Referenced by mf2\_\-server\_\-send().\index{mf2\_\-server.c@{mf2\_\-server.c}!mf2\_\-server\_\-register\_\-rx\_\-event@{mf2\_\-server\_\-register\_\-rx\_\-event}}
\index{mf2\_\-server\_\-register\_\-rx\_\-event@{mf2\_\-server\_\-register\_\-rx\_\-event}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[mf2\_\-server\_\-register\_\-rx\_\-event]{\setlength{\rightskip}{0pt plus 5cm}void mf2\_\-server\_\-register\_\-rx\_\-event (void($\ast$)(char) {\em f})}\label{mf2__server_8c_7c4d43b1040daef11349168dc3bd2920}




Definition at line 387 of file mf2\_\-server.c.

References parse\_\-symbols::f, IRQ\_\-LOCK, IRQ\_\-UNLOCK, and rx\_\-event.\index{mf2\_\-server.c@{mf2\_\-server.c}!mf2\_\-server\_\-register\_\-tx\_\-event@{mf2\_\-server\_\-register\_\-tx\_\-event}}
\index{mf2\_\-server\_\-register\_\-tx\_\-event@{mf2\_\-server\_\-register\_\-tx\_\-event}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[mf2\_\-server\_\-register\_\-tx\_\-event]{\setlength{\rightskip}{0pt plus 5cm}void mf2\_\-server\_\-register\_\-tx\_\-event (void($\ast$)(char) {\em f})}\label{mf2__server_8c_06db454f446c500c6ff8b61bd61c8e73}




Definition at line 377 of file mf2\_\-server.c.

References parse\_\-symbols::f, IRQ\_\-LOCK, IRQ\_\-UNLOCK, and tx\_\-event.\index{mf2\_\-server.c@{mf2\_\-server.c}!mf2\_\-server\_\-send@{mf2\_\-server\_\-send}}
\index{mf2\_\-server\_\-send@{mf2\_\-server\_\-send}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[mf2\_\-server\_\-send]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t mf2\_\-server\_\-send (char {\em c})}\label{mf2__server_8c_b0f0a5aea29236cbbaacb1a01481405a}




Definition at line 338 of file mf2\_\-server.c.

References clk\_\-Z, data\_\-Z, IRQ\_\-LOCK, IRQ\_\-UNLOCK, mf2\_\-server\_\-ready(), MF2\_\-SERVER\_\-STATE\_\-SEND, and mf2\_\-server\_\-timer\_\-cb().\index{mf2\_\-server.c@{mf2\_\-server.c}!mf2\_\-server\_\-timer\_\-cb@{mf2\_\-server\_\-timer\_\-cb}}
\index{mf2\_\-server\_\-timer\_\-cb@{mf2\_\-server\_\-timer\_\-cb}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[mf2\_\-server\_\-timer\_\-cb]{\setlength{\rightskip}{0pt plus 5cm}void mf2\_\-server\_\-timer\_\-cb (void)}\label{mf2__server_8c_6facccfef54c8beb8a9d0fe4412ff498}




Definition at line 150 of file mf2\_\-server.c.

References clk\_\-0, clk\_\-Z, data\_\-0, data\_\-Z, dump, MF2\_\-SERVER\_\-STATE\_\-READY, MF2\_\-SERVER\_\-STATE\_\-RECV, read\_\-clk, read\_\-data, and rx\_\-event.

Referenced by mf2\_\-server\_\-init(), and mf2\_\-server\_\-send().\index{mf2\_\-server.c@{mf2\_\-server.c}!recv@{recv}}
\index{recv@{recv}!mf2_server.c@{mf2\_\-server.c}}
\subsubsection[recv]{\setlength{\rightskip}{0pt plus 5cm}void recv (void)}\label{mf2__server_8c_9260b44a72bbdd7ba7870b7b0f352db4}




Definition at line 62 of file mf2\_\-server.c.

References clk\_\-0, clk\_\-Z, data\_\-0, data\_\-Z, i, read\_\-data, wait\_\-4cyc, and WAIT\_\-KBD\_\-CYCLE4.