summaryrefslogtreecommitdiffstats
path: root/libsensors_iio/software/core/mpl/interpolator.h
blob: 5eb571d270745a0294270d4caac199b976fa2e70 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 $License:
    Copyright (C) 2011 InvenSense Corporation, All Rights Reserved.
 $
 */
#ifndef INTERPOLATOR_H
#define INTERPOLATOR_H

#ifdef __cplusplus
extern "C" {
#endif

//#include "mltypes.h"

    /* ------------ */
    /* - Defines. - */
    /* ------------ */

#define MAX_INTERPOLATION (20)

typedef struct  {
    long x[2];
    long y[4];
} tInterpolate2;
typedef struct  {
    long x[2];
    long y[6];
} tInterpolate3;
typedef struct  {
    long x[5];
    long y[10];
    int idx1;
} tInterpolate5;
typedef struct {
    tInterpolate2 state1;
    tInterpolate2 state2;
} tInterpolate4;
typedef struct {
    tInterpolate3 state1;
    tInterpolate2 state2;
} tInterpolate6;
typedef struct {
    tInterpolate2 state1;
    tInterpolate4 state2;
} tInterpolate8;
typedef struct {
    tInterpolate3 state1;
    tInterpolate3 state2;
} tInterpolate9;
typedef struct {
    tInterpolate5 state1;
    tInterpolate2 state2;
} tInterpolate10;
typedef struct {
    tInterpolate4 state1;
    tInterpolate3 state2;
} tInterpolate12;
typedef struct {
    tInterpolate5 state1;
    tInterpolate3 state2;
} tInterpolate15;
typedef struct {
    tInterpolate2 state1;
    tInterpolate8 state2;
} tInterpolate16;
typedef struct {
    tInterpolate9 state1;
    tInterpolate2 state2;
} tInterpolate18;
typedef struct {
    tInterpolate10 state1;
    tInterpolate2 state2;
} tInterpolate20;

typedef  union {
    tInterpolate2 u2;
    tInterpolate3 u3;
    tInterpolate4 u4;
    tInterpolate5 u5;
    tInterpolate6 u6;
    tInterpolate8 u8;
    tInterpolate9 u9;
    tInterpolate10 u10;
    tInterpolate12 u12;
    tInterpolate15 u15;
    tInterpolate16 u16;
    tInterpolate18 u18;
    tInterpolate20 u20;
} tInterpolateState;

    /* --------------------- */
    /* - Function p-types. - */
    /* --------------------- */
int inv_get_interp_amount( int x );
int inv_interpolate( int amount, long input, long *output, tInterpolateState *state );
long inv_fxmult( long x, long y );


#ifdef __cplusplus
}
#endif

#endif /* INTERPOLATOR_H */