MotorWare f2806x Module API Documentation
32b/filter_so.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2012, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
37 
38 
39 // **************************************************************************
40 // the includes
41 
43 
44 
45 // **************************************************************************
46 // the defines
47 
48 
49 // **************************************************************************
50 // the globals
51 
52 
53 // **************************************************************************
54 // the functions
55 
56 
58 {
59  FILTER_SO_Obj *obj = (FILTER_SO_Obj *)handle;
60 
61 
62  *pa1 = obj->a1;
63  *pa2 = obj->a2;
64 
65  return;
66 } // end of FILTER_SO_getDenCoeffs() function
67 
68 
70  _iq *py1,_iq *py2)
71 {
72  FILTER_SO_Obj *obj = (FILTER_SO_Obj *)handle;
73 
74 
75  *px1 = obj->x1;
76  *px2 = obj->x2;
77 
78  *py1 = obj->y1;
79  *py2 = obj->y2;
80 
81  return;
82 } // end of FILTER_SO_getInitialConditions() function
83 
84 
85 void FILTER_SO_getNumCoeffs(FILTER_SO_Handle handle,_iq *pb0,_iq *pb1,_iq *pb2)
86 {
87  FILTER_SO_Obj *obj = (FILTER_SO_Obj *)handle;
88 
89 
90  *pb0 = obj->b0;
91  *pb1 = obj->b1;
92  *pb2 = obj->b2;
93 
94  return;
95 } // end of FILTER_SO_getNumCoeffs() function
96 
97 
98 FILTER_SO_Handle FILTER_SO_init(void *pMemory,const size_t numBytes)
99 {
100  FILTER_SO_Handle handle;
101 
102 
103  if(numBytes < sizeof(FILTER_SO_Obj))
104  return((FILTER_SO_Handle)NULL);
105 
106  // assign the handle
107  handle = (FILTER_SO_Handle)pMemory;
108 
109  return(handle);
110 } // end of FILTER_SO_init() function
111 
112 
113 void FILTER_SO_setDenCoeffs(FILTER_SO_Handle handle,const _iq a1,const _iq a2)
114 {
115  FILTER_SO_Obj *obj = (FILTER_SO_Obj *)handle;
116 
117 
118  obj->a1 = a1;
119  obj->a2 = a2;
120 
121  return;
122 } // end of FILTER_SO_setDenCoeffs() function
123 
124 
126  const _iq y1,const _iq y2)
127 {
128  FILTER_SO_Obj *obj = (FILTER_SO_Obj *)handle;
129 
130 
131  obj->x1 = x1;
132  obj->x2 = x2;
133 
134  obj->y1 = y1;
135  obj->y2 = y2;
136 
137  return;
138 } // end of FILTER_SO_setInitialConditions() function
139 
140 
141 void FILTER_SO_setNumCoeffs(FILTER_SO_Handle handle,const _iq b0,const _iq b1,const _iq b2)
142 {
143  FILTER_SO_Obj *obj = (FILTER_SO_Obj *)handle;
144 
145 
146  obj->b0 = b0;
147  obj->b1 = b1;
148  obj->b2 = b2;
149 
150  return;
151 } // end of FILTER_SO_setNumCoeffs() function
152 
153 // end of file
154 
155 
156 
157 
void FILTER_SO_getNumCoeffs(FILTER_SO_Handle handle, _iq *pb0, _iq *pb1, _iq *pb2)
Gets the second-order filter numerator coefficients.
Definition: 32b/filter_so.c:85
void FILTER_SO_getDenCoeffs(FILTER_SO_Handle handle, _iq *pa1, _iq *pa2)
Gets the second-order filter denominator coefficients.
Definition: 32b/filter_so.c:57
float_t b1
the numerator filter coefficient value for z^(-1)
_iq a1
the denominator filter coefficient value for z^(-1)
Definition: 32b/filter_so.h:73
FILTER_SO_Handle FILTER_SO_init(void *pMemory, const size_t numBytes)
Initializes the second-order filter.
Definition: 32b/filter_so.c:98
float_t x1
the input value at time sample n=-1
_iq y1
the output value at time sample n=-1
Definition: 32b/filter_so.h:83
long _iq
Defines the second-order filter (FILTER_SO) object.
void FILTER_SO_setDenCoeffs(FILTER_SO_Handle handle, const _iq a1, const _iq a2)
Sets the second-order filter denominator coefficients.
Contains the public interface to the second-order filter (FILTER_SO) module routines.
void FILTER_SO_setNumCoeffs(FILTER_SO_Handle handle, const _iq b0, const _iq b1, const _iq b2)
Sets the second-order filter numerator coefficients.
_iq y2
the output value at time sample n=-2
Definition: 32b/filter_so.h:84
Defines the second-order filter (FILTER_SO) object.
Definition: 32b/filter_so.h:71
_iq a2
the denominator filter coefficient value for z^(-2)
Definition: 32b/filter_so.h:74
struct _FILTER_SO_Obj_ * FILTER_SO_Handle
Defines the second-order filter (FILTER_SO) handle.
Definition: 32b/filter_so.h:90
_iq x2
the input value at time sample n=-2
Definition: 32b/filter_so.h:81
_iq x1
the input value at time sample n=-1
Definition: 32b/filter_so.h:80
_iq b2
the numerator filter coefficient value for z^(-2)
Definition: 32b/filter_so.h:78
float_t b0
the numerator filter coefficient value for z^0
float_t a1
the denominator filter coefficient value for z^(-1)
void FILTER_SO_setInitialConditions(FILTER_SO_Handle handle, const _iq x1, const _iq x2, const _iq y1, const _iq y2)
Sets the initial conditions of the second-order filter.
_iq b0
the numerator filter coefficient value for z^0
Definition: 32b/filter_so.h:76
void FILTER_SO_getInitialConditions(FILTER_SO_Handle handle, _iq *px1, _iq *px2, _iq *py1, _iq *py2)
Gets the initial conditions of the second-order filter.
Definition: 32b/filter_so.c:69
float_t y1
the output value at time sample n=-1
_iq b1
the numerator filter coefficient value for z^(-1)
Definition: 32b/filter_so.h:77