\section{aversive\_\-10-03-12/modules/devices/control\_\-system/filters/biquad/biquad.h File Reference}
\label{biquad_8h}\index{aversive\_\-10-03-12/modules/devices/control\_\-system/filters/biquad/biquad.h@{aversive\_\-10-03-12/modules/devices/control\_\-system/filters/biquad/biquad.h}}
{\tt \#include $<$aversive.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf biquad\_\-filter}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf biquad\_\-init} (struct {\bf biquad\_\-filter} $\ast$p)
\item 
void {\bf biquad\_\-set\_\-numerator\_\-coeffs} (struct {\bf biquad\_\-filter} $\ast$p, int16\_\-t b0, int16\_\-t b1, int16\_\-t b2)
\item 
void {\bf biquad\_\-set\_\-deniminator\_\-coeffs} (struct {\bf biquad\_\-filter} $\ast$p, int16\_\-t a1, int16\_\-t a2)
\item 
void {\bf biquad\_\-set\_\-divisor\_\-shifts} (struct {\bf biquad\_\-filter} $\ast$p, uint8\_\-t recursive\_\-shift, uint8\_\-t out\_\-shift)
\item 
void {\bf biquad\_\-set\_\-series\_\-son} (struct {\bf biquad\_\-filter} $\ast$p, struct {\bf biquad\_\-filter} $\ast$son)
\item 
void {\bf biquad\_\-flush\_\-memories} (struct {\bf biquad\_\-filter} $\ast$p)
\item 
int32\_\-t {\bf biquad\_\-do\_\-filter} (void $\ast$data, int32\_\-t in)
\end{CompactItemize}


\subsection{Function Documentation}
\index{biquad.h@{biquad.h}!biquad\_\-do\_\-filter@{biquad\_\-do\_\-filter}}
\index{biquad\_\-do\_\-filter@{biquad\_\-do\_\-filter}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-do\_\-filter]{\setlength{\rightskip}{0pt plus 5cm}int32\_\-t biquad\_\-do\_\-filter (void $\ast$ {\em data}, \/  int32\_\-t {\em in})}\label{biquad_8h_4acca269db06d415efa12715b637de41}


filter processing, 1 iteration. This function is not protected against writing in the structure while execution is ongoing!

filter processing, 1 iteration. This function is not protected against writing in the structure while execution is ongoing! 

Definition at line 107 of file biquad.c.

References biquad\_\-filter::a1, biquad\_\-filter::a2, biquad\_\-filter::b0, biquad\_\-filter::b1, biquad\_\-filter::b2, biquad\_\-do\_\-filter(), biquad\_\-filter::mem\_\-in\_\-1, biquad\_\-filter::mem\_\-in\_\-2, biquad\_\-filter::mem\_\-out\_\-1, biquad\_\-filter::mem\_\-out\_\-2, biquad\_\-filter::out\_\-shift, gen\_\-regs::p, biquad\_\-filter::recursive\_\-shift, and biquad\_\-filter::son.

Referenced by biquad\_\-do\_\-filter().\index{biquad.h@{biquad.h}!biquad\_\-flush\_\-memories@{biquad\_\-flush\_\-memories}}
\index{biquad\_\-flush\_\-memories@{biquad\_\-flush\_\-memories}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-flush\_\-memories]{\setlength{\rightskip}{0pt plus 5cm}void biquad\_\-flush\_\-memories (struct {\bf biquad\_\-filter} $\ast$ {\em p})}\label{biquad_8h_d1abd618377b89b47ae816078c6c24a2}


this is useful for cleaning the filter memories before a new data set.

With this you avoid having old data in the filter memories when beginning to filter a new stream. Can also be used after changing the coefficients, to avoid jumps of the output value.

this is useful for cleaning the filter memories before a new data set. With this you avoid having old data in the filter memories when beginning to filter a new stream. Can also be used after changing the coefficients, to avoid jumps of the output value. 

Definition at line 46 of file biquad.c.

References IRQ\_\-LOCK, IRQ\_\-UNLOCK, biquad\_\-filter::mem\_\-in\_\-1, biquad\_\-filter::mem\_\-in\_\-2, biquad\_\-filter::mem\_\-out\_\-1, and biquad\_\-filter::mem\_\-out\_\-2.\index{biquad.h@{biquad.h}!biquad\_\-init@{biquad\_\-init}}
\index{biquad\_\-init@{biquad\_\-init}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void biquad\_\-init (struct {\bf biquad\_\-filter} $\ast$ {\em p})}\label{biquad_8h_c825a4ae4a799c1dd48519b25cb4cdcd}


Prototyping init sets an unity filter, as usual initialization is absolutely necessary !

init sets an unity filter, as usual 

Definition at line 27 of file biquad.c.

References IRQ\_\-LOCK, and IRQ\_\-UNLOCK.\index{biquad.h@{biquad.h}!biquad\_\-set\_\-deniminator\_\-coeffs@{biquad\_\-set\_\-deniminator\_\-coeffs}}
\index{biquad\_\-set\_\-deniminator\_\-coeffs@{biquad\_\-set\_\-deniminator\_\-coeffs}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-set\_\-deniminator\_\-coeffs]{\setlength{\rightskip}{0pt plus 5cm}void biquad\_\-set\_\-deniminator\_\-coeffs (struct {\bf biquad\_\-filter} $\ast$ {\em p}, \/  int16\_\-t {\em a1}, \/  int16\_\-t {\em a2})}\label{biquad_8h_9f2763dda5890b0185dcb794487e44bd}




Definition at line 73 of file biquad.c.

References biquad\_\-filter::a1, biquad\_\-filter::a2, IRQ\_\-LOCK, and IRQ\_\-UNLOCK.\index{biquad.h@{biquad.h}!biquad\_\-set\_\-divisor\_\-shifts@{biquad\_\-set\_\-divisor\_\-shifts}}
\index{biquad\_\-set\_\-divisor\_\-shifts@{biquad\_\-set\_\-divisor\_\-shifts}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-set\_\-divisor\_\-shifts]{\setlength{\rightskip}{0pt plus 5cm}void biquad\_\-set\_\-divisor\_\-shifts (struct {\bf biquad\_\-filter} $\ast$ {\em p}, \/  uint8\_\-t {\em recursive\_\-shift}, \/  uint8\_\-t {\em out\_\-shift})}\label{biquad_8h_e1442b1d38100f4c97eaf7f4aec5303d}




Definition at line 84 of file biquad.c.

References IRQ\_\-LOCK, and IRQ\_\-UNLOCK.\index{biquad.h@{biquad.h}!biquad\_\-set\_\-numerator\_\-coeffs@{biquad\_\-set\_\-numerator\_\-coeffs}}
\index{biquad\_\-set\_\-numerator\_\-coeffs@{biquad\_\-set\_\-numerator\_\-coeffs}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-set\_\-numerator\_\-coeffs]{\setlength{\rightskip}{0pt plus 5cm}void biquad\_\-set\_\-numerator\_\-coeffs (struct {\bf biquad\_\-filter} $\ast$ {\em p}, \/  int16\_\-t {\em b0}, \/  int16\_\-t {\em b1}, \/  int16\_\-t {\em b2})}\label{biquad_8h_13c3cc12ee72c100aa42c1813424f501}


accessors to coefficients 

Definition at line 61 of file biquad.c.

References biquad\_\-filter::b0, biquad\_\-filter::b1, biquad\_\-filter::b2, IRQ\_\-LOCK, and IRQ\_\-UNLOCK.\index{biquad.h@{biquad.h}!biquad\_\-set\_\-series\_\-son@{biquad\_\-set\_\-series\_\-son}}
\index{biquad\_\-set\_\-series\_\-son@{biquad\_\-set\_\-series\_\-son}!biquad.h@{biquad.h}}
\subsubsection[biquad\_\-set\_\-series\_\-son]{\setlength{\rightskip}{0pt plus 5cm}void biquad\_\-set\_\-series\_\-son (struct {\bf biquad\_\-filter} $\ast$ {\em p}, \/  struct {\bf biquad\_\-filter} $\ast$ {\em son})}\label{biquad_8h_9480121b67ab7507c1252903c12a9bbc}


this sets a filter to put in series. use as following :

biquad\_\-set\_\-series\_\-son(\& filter1, \&filter2)

then please use ONLY the filter1. The filter 2 will recursively be called into the filter 1 function : output = biquad\_\-do\_\-filter(\& filter1, input);

You can put in series as much biquad filters as you want. 

Definition at line 95 of file biquad.c.

References IRQ\_\-LOCK, IRQ\_\-UNLOCK, and biquad\_\-filter::son.