aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/lsm303d/iirFilter.h
blob: ab4223a8ed23d3193bbca3e76a0e12d18a85d392 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef IIRFILTER__H__
#define IIRFILTER__H__

__BEGIN_DECLS

#define MAX_LENGTH 4

typedef struct FILTER_s
{
	float denData[MAX_LENGTH];
	float numData[MAX_LENGTH];
	int denLength;
	int numLength;
	float Ts;
	float inpData[MAX_LENGTH];
	float outData[MAX_LENGTH];
	unsigned int inpCnt;
} FIL_T;

typedef struct TF_ZPG_s
{
	int    zerosLength;
	double zerosData[MAX_LENGTH + 1];
	int    polesLength;
	double polesData[MAX_LENGTH + 1];
	double gain;
	double Ts;
} TF_ZPG_t;

typedef struct TF_POLY_s
{
	int    numLength;
	double numData[MAX_LENGTH];
	int    denLength;
	double denData[MAX_LENGTH];
	double Ts;
} TF_POLY_t;

typedef struct TF_DIF_s
{
	int    numInt;
	int    numDiff;
	int    lowpassLength;
	int    highpassLength;
	double lowpassData[MAX_LENGTH];
	int    highpassData[MAX_LENGTH];
	double gain;
	double Ts;
} TF_DIF_t;

__EXPORT int testFunction(void);

__EXPORT float updateFilter(FIL_T *pFilt, float inp);

__EXPORT int initFilter(const TF_DIF_t *pDifc, double Ts, FIL_T *pFilt);

__END_DECLS

#endif