\section{aversive\_\-10-03-12/modules/encoding/hamming/hamming.c File Reference}
\label{hamming_8c}\index{aversive\_\-10-03-12/modules/encoding/hamming/hamming.c@{aversive\_\-10-03-12/modules/encoding/hamming/hamming.c}}
Implementation for the Hamiing module. 

{\tt \#include $<$aversive.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf P\_\-MASK}~0x0000808B
\item 
\#define {\bf P0\_\-MASK}~0x15555554
\item 
\#define {\bf P1\_\-MASK}~0x06666664
\item 
\#define {\bf P2\_\-MASK}~0x18787870
\item 
\#define {\bf P3\_\-MASK}~0x1F807F00
\item 
\#define {\bf P4\_\-MASK}~0x1FFF0000
\item 
\#define {\bf P0\_\-EMPL}~0
\item 
\#define {\bf P1\_\-EMPL}~1
\item 
\#define {\bf P2\_\-EMPL}~3
\item 
\#define {\bf P3\_\-EMPL}~7
\item 
\#define {\bf P4\_\-EMPL}~15
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
uint32\_\-t {\bf hamming\_\-expand} (uint32\_\-t frame)
\item 
uint32\_\-t {\bf hamming\_\-shrink} (uint32\_\-t frame)
\item 
uint32\_\-t {\bf hamming\_\-process} (uint32\_\-t frame)
\item 
uint8\_\-t {\bf hamming\_\-unprocess} (uint32\_\-t frame)
\item 
uint32\_\-t {\bf hamming\_\-correct} (uint32\_\-t frame, uint8\_\-t {\bf i})
\item 
void {\bf hamming\_\-do} (uint32\_\-t $\ast$frame)
\item 
uint8\_\-t {\bf hamming\_\-undo} (uint32\_\-t $\ast$frame)
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
uint8\_\-t {\bf tab\_\-abcd} [16]
\item 
uint8\_\-t {\bf tab\_\-dcba} [32]
\item 
uint8\_\-t {\bf tab\_\-parity} [256]
\end{CompactItemize}


\subsection{Detailed Description}
Implementation for the Hamiing module. 

Interface for the Hamming module.

\begin{Desc}
\item[{\bf Todo}]use progmem to store tables !\end{Desc}
\begin{Desc}
\item[{\bf Test}]Seems to work\end{Desc}
This module provides functions for \doxyref{error}{p.}{structerror} detection/correction

\begin{Desc}
\item[{\bf Todo}]nothing.\end{Desc}
\begin{Desc}
\item[{\bf Test}]Seems to work\end{Desc}
This module provides functions for \doxyref{error}{p.}{structerror} detection/correction 

Definition in file {\bf hamming.c}.

\subsection{Define Documentation}
\index{hamming.c@{hamming.c}!P0\_\-EMPL@{P0\_\-EMPL}}
\index{P0\_\-EMPL@{P0\_\-EMPL}!hamming.c@{hamming.c}}
\subsubsection[P0\_\-EMPL]{\setlength{\rightskip}{0pt plus 5cm}\#define P0\_\-EMPL~0}\label{hamming_8c_deb4a431c2223fc65e693210f10c2ed4}




Definition at line 50 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P0\_\-MASK@{P0\_\-MASK}}
\index{P0\_\-MASK@{P0\_\-MASK}!hamming.c@{hamming.c}}
\subsubsection[P0\_\-MASK]{\setlength{\rightskip}{0pt plus 5cm}\#define P0\_\-MASK~0x15555554}\label{hamming_8c_2cf03678525fd7782e25d2b3b4d70014}




Definition at line 44 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P1\_\-EMPL@{P1\_\-EMPL}}
\index{P1\_\-EMPL@{P1\_\-EMPL}!hamming.c@{hamming.c}}
\subsubsection[P1\_\-EMPL]{\setlength{\rightskip}{0pt plus 5cm}\#define P1\_\-EMPL~1}\label{hamming_8c_f9d361bdf7e5afa8272c505a2afbeae4}




Definition at line 51 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P1\_\-MASK@{P1\_\-MASK}}
\index{P1\_\-MASK@{P1\_\-MASK}!hamming.c@{hamming.c}}
\subsubsection[P1\_\-MASK]{\setlength{\rightskip}{0pt plus 5cm}\#define P1\_\-MASK~0x06666664}\label{hamming_8c_87d229b86d690621ed7e52b62e8a0299}




Definition at line 45 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P2\_\-EMPL@{P2\_\-EMPL}}
\index{P2\_\-EMPL@{P2\_\-EMPL}!hamming.c@{hamming.c}}
\subsubsection[P2\_\-EMPL]{\setlength{\rightskip}{0pt plus 5cm}\#define P2\_\-EMPL~3}\label{hamming_8c_4440ed4e342fa4f18657d49b0c9c3e07}




Definition at line 52 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P2\_\-MASK@{P2\_\-MASK}}
\index{P2\_\-MASK@{P2\_\-MASK}!hamming.c@{hamming.c}}
\subsubsection[P2\_\-MASK]{\setlength{\rightskip}{0pt plus 5cm}\#define P2\_\-MASK~0x18787870}\label{hamming_8c_fa3495f6362d3015b51292c5575be378}




Definition at line 46 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P3\_\-EMPL@{P3\_\-EMPL}}
\index{P3\_\-EMPL@{P3\_\-EMPL}!hamming.c@{hamming.c}}
\subsubsection[P3\_\-EMPL]{\setlength{\rightskip}{0pt plus 5cm}\#define P3\_\-EMPL~7}\label{hamming_8c_d66039a8a58dfd2e6c86e8c0933934c1}




Definition at line 53 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P3\_\-MASK@{P3\_\-MASK}}
\index{P3\_\-MASK@{P3\_\-MASK}!hamming.c@{hamming.c}}
\subsubsection[P3\_\-MASK]{\setlength{\rightskip}{0pt plus 5cm}\#define P3\_\-MASK~0x1F807F00}\label{hamming_8c_4de583e0f3299c8c08c821bfb485be4d}




Definition at line 47 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P4\_\-EMPL@{P4\_\-EMPL}}
\index{P4\_\-EMPL@{P4\_\-EMPL}!hamming.c@{hamming.c}}
\subsubsection[P4\_\-EMPL]{\setlength{\rightskip}{0pt plus 5cm}\#define P4\_\-EMPL~15}\label{hamming_8c_f4d7c5294f0feb8e4606738c193bbc17}




Definition at line 54 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P4\_\-MASK@{P4\_\-MASK}}
\index{P4\_\-MASK@{P4\_\-MASK}!hamming.c@{hamming.c}}
\subsubsection[P4\_\-MASK]{\setlength{\rightskip}{0pt plus 5cm}\#define P4\_\-MASK~0x1FFF0000}\label{hamming_8c_2bb29bd16a219aaa82d1ec6f7de6093b}




Definition at line 48 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!P\_\-MASK@{P\_\-MASK}}
\index{P\_\-MASK@{P\_\-MASK}!hamming.c@{hamming.c}}
\subsubsection[P\_\-MASK]{\setlength{\rightskip}{0pt plus 5cm}\#define P\_\-MASK~0x0000808B}\label{hamming_8c_3a0a461150f4cd46b72a37f570fc43e9}




Definition at line 42 of file hamming.c.

\subsection{Function Documentation}
\index{hamming.c@{hamming.c}!hamming\_\-correct@{hamming\_\-correct}}
\index{hamming\_\-correct@{hamming\_\-correct}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-correct]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t hamming\_\-correct (uint32\_\-t {\em frame}, \/  uint8\_\-t {\em i})}\label{hamming_8c_a5800f553bdee7228155f3fe9574fe19}




Definition at line 291 of file hamming.c.

References parse\_\-symbols::l.

Referenced by hamming\_\-undo().\index{hamming.c@{hamming.c}!hamming\_\-do@{hamming\_\-do}}
\index{hamming\_\-do@{hamming\_\-do}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-do]{\setlength{\rightskip}{0pt plus 5cm}void hamming\_\-do (uint32\_\-t $\ast$ {\em frame})}\label{hamming_8c_ff94925b3bed87baf31985851bf0b227}


Encode the frame (the 24 LSB bits) into a 29 bits frame with hamming \doxyref{error}{p.}{structerror} correction bits. The 3 MSB bits are not used. 

Definition at line 299 of file hamming.c.

References hamming\_\-expand(), and hamming\_\-process().\index{hamming.c@{hamming.c}!hamming\_\-expand@{hamming\_\-expand}}
\index{hamming\_\-expand@{hamming\_\-expand}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-expand]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t hamming\_\-expand (uint32\_\-t {\em frame})}\label{hamming_8c_1c8cc73e8013b4d510f42a2083a800c1}




Definition at line 119 of file hamming.c.

References extr32\_\-08\_\-2, extr32\_\-16\_\-mid, and tab\_\-abcd.

Referenced by hamming\_\-do().\index{hamming.c@{hamming.c}!hamming\_\-process@{hamming\_\-process}}
\index{hamming\_\-process@{hamming\_\-process}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-process]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t hamming\_\-process (uint32\_\-t {\em frame})}\label{hamming_8c_7e1a11fab25a8a1fecc5aad968bc1b78}




Definition at line 163 of file hamming.c.

References parse\_\-symbols::l, P0\_\-EMPL, P0\_\-MASK, P1\_\-EMPL, P1\_\-MASK, P2\_\-EMPL, P2\_\-MASK, P3\_\-EMPL, P3\_\-MASK, P4\_\-EMPL, P4\_\-MASK, and tab\_\-parity.

Referenced by hamming\_\-do().\index{hamming.c@{hamming.c}!hamming\_\-shrink@{hamming\_\-shrink}}
\index{hamming\_\-shrink@{hamming\_\-shrink}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-shrink]{\setlength{\rightskip}{0pt plus 5cm}uint32\_\-t hamming\_\-shrink (uint32\_\-t {\em frame})}\label{hamming_8c_ea10ce30d3194f0b0e86fcefd00d4d6a}




Definition at line 142 of file hamming.c.

References tab\_\-dcba.

Referenced by hamming\_\-undo().\index{hamming.c@{hamming.c}!hamming\_\-undo@{hamming\_\-undo}}
\index{hamming\_\-undo@{hamming\_\-undo}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-undo]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t hamming\_\-undo (uint32\_\-t $\ast$ {\em frame})}\label{hamming_8c_22f7dc4171eaa1cd257006d82d314137}


Decode the 29 bits frame into a 24 bits one. If an \doxyref{error}{p.}{structerror} occurs, the function tries to correct it and returns a positive value. If there is no \doxyref{error}{p.}{structerror}, the function returns 0. 

Definition at line 306 of file hamming.c.

References hamming\_\-correct(), hamming\_\-shrink(), and hamming\_\-unprocess().\index{hamming.c@{hamming.c}!hamming\_\-unprocess@{hamming\_\-unprocess}}
\index{hamming\_\-unprocess@{hamming\_\-unprocess}!hamming.c@{hamming.c}}
\subsubsection[hamming\_\-unprocess]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t hamming\_\-unprocess (uint32\_\-t {\em frame})}\label{hamming_8c_f4babd6b96a24d4379dadbdee43824e9}




Definition at line 218 of file hamming.c.

References parse\_\-symbols::l, P0\_\-EMPL, P0\_\-MASK, P1\_\-EMPL, P1\_\-MASK, P2\_\-EMPL, P2\_\-MASK, P3\_\-EMPL, P3\_\-MASK, P4\_\-EMPL, P4\_\-MASK, and tab\_\-parity.

Referenced by hamming\_\-undo().

\subsection{Variable Documentation}
\index{hamming.c@{hamming.c}!tab\_\-abcd@{tab\_\-abcd}}
\index{tab\_\-abcd@{tab\_\-abcd}!hamming.c@{hamming.c}}
\subsubsection[tab\_\-abcd]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t {\bf tab\_\-abcd}[16]}\label{hamming_8c_e1bf0a9fc0d5f798c258ee75d16acda7}


\textbf{Initial value:}

\begin{Code}\begin{verbatim}
  {
    0,
    4,
    16,
    20,
    32,
    36,
    48,
    52,
    64,
    68,
    80,
    84,
    96,
    100,
    112,
    116
  }
\end{verbatim}
\end{Code}


Definition at line 56 of file hamming.c.

Referenced by hamming\_\-expand().\index{hamming.c@{hamming.c}!tab\_\-dcba@{tab\_\-dcba}}
\index{tab\_\-dcba@{tab\_\-dcba}!hamming.c@{hamming.c}}
\subsubsection[tab\_\-dcba]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t {\bf tab\_\-dcba}[32]}\label{hamming_8c_5f20f4f6c1959835b882a3de92c1a4f8}




Definition at line 76 of file hamming.c.

Referenced by hamming\_\-shrink().\index{hamming.c@{hamming.c}!tab\_\-parity@{tab\_\-parity}}
\index{tab\_\-parity@{tab\_\-parity}!hamming.c@{hamming.c}}
\subsubsection[tab\_\-parity]{\setlength{\rightskip}{0pt plus 5cm}uint8\_\-t {\bf tab\_\-parity}[256]}\label{hamming_8c_8cec3af959d9a6a73652e513ed361683}


\textbf{Initial value:}

\begin{Code}\begin{verbatim}
  {
  0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0 
  }
\end{verbatim}
\end{Code}


Definition at line 112 of file hamming.c.

Referenced by hamming\_\-process(), and hamming\_\-unprocess().