MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

32b/filter_fo.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
42 #include "sw/modules/filter/src/32b/filter_fo.h"
43
44
45
46 // **************************************************************************
47 // the defines
48
49
50 // **************************************************************************
51 // the globals
52
53
54 // **************************************************************************
55 // the functions
56
57
58 void FILTER_FO_getDenCoeffs(FILTER_FO_Handle handle,_iq *pa1)
59 {
60 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
61
62
63 *pa1 = obj->a1;
64
65 return;
66 } // end of FILTER_FO_getDenCoeffs() function
67
68
69 void FILTER_FO_getInitialConditions(FILTER_FO_Handle handle,_iq *px1,_iq *py1)
70 {
71 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
72
73
74 *px1 = obj->x1;
75
76 *py1 = obj->y1;
77
78 return;
79 } // end of FILTER_FO_getInitialConditions() function
80
81
82 void FILTER_FO_getNumCoeffs(FILTER_FO_Handle handle,_iq *pb0,_iq *pb1)
83 {
84 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
85
86
87 *pb0 = obj->b0;
88 *pb1 = obj->b1;
89
90 return;
91 } // end of FILTER_FO_getNumCoeffs() function
92
93
94 FILTER_FO_Handle FILTER_FO_init(void *pMemory,const size_t numBytes)
95 {
96 FILTER_FO_Handle handle;
97
98
99 if(numBytes < sizeof(FILTER_FO_Obj))
100 return((FILTER_FO_Handle)NULL);
101
102 // assign the handle
103 handle = (FILTER_FO_Handle)pMemory;
104
105 return(handle);
106 } // end of FILTER_FO_init() function
107
108
109 void FILTER_FO_setDenCoeffs(FILTER_FO_Handle handle,const _iq a1)
110 {
111 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
112
113
114 obj->a1 = a1;
115
116 return;
117 } // end of FILTER_FO_setDenCoeffs() function
118
119
120 void FILTER_FO_setInitialConditions(FILTER_FO_Handle handle,const _iq x1,const _iq y1)
121 {
122 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
123
124
125 obj->x1 = x1;
126
127 obj->y1 = y1;
128
129 return;
130 } // end of FILTER_FO_setInitialConditions() function
131
132
133 void FILTER_FO_setNumCoeffs(FILTER_FO_Handle handle,const _iq b0,const _iq b1)
134 {
135 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
136
137
138 obj->b0 = b0;
139 obj->b1 = b1;
140
141 return;
142 } // end of FILTER_FO_setNumCoeffs() function
143
144
145 // end of file
146
147
148
FILTER_FO_getNumCoeffs
void FILTER_FO_getNumCoeffs(FILTER_FO_Handle handle, _iq *pb0, _iq *pb1)
Gets the first-order filter numerator coefficients.
Definition: 32b/filter_fo.c:82
_FILTER_FO_::b1
_iq b1
the numerator filter coefficient value for z^(-1)
Definition: 32b/filter_fo.h:76
_FILTER_FO_::a1
_iq a1
the denominator filter coefficient value for z^(-1)
Definition: 32b/filter_fo.h:73
FILTER_FO_getInitialConditions
void FILTER_FO_getInitialConditions(FILTER_FO_Handle handle, _iq *px1, _iq *py1)
Gets the initial conditions of the first-order filter.
Definition: 32b/filter_fo.c:69
FILTER_FO_Handle
struct _FILTER_FO_Obj_ * FILTER_FO_Handle
Defines the first-order filter (FILTER_FO) handle.
Definition: 32b/filter_fo.h:86
_FILTER_FO_
Defines the first-order filter (FILTER_FO) object.
Definition: 32b/filter_fo.h:71
_iq
long _iq
Definition: 32b/IQmathLib.h:223
_FILTER_FO_::x1
_iq x1
the input value at time sample n=-1
Definition: 32b/filter_fo.h:78
FILTER_FO_init
FILTER_FO_Handle FILTER_FO_init(void *pMemory, const size_t numBytes)
Initializes the first-order filter.
Definition: 32b/filter_fo.c:94
FILTER_FO_setNumCoeffs
void FILTER_FO_setNumCoeffs(FILTER_FO_Handle handle, const _iq b0, const _iq b1)
Sets the first-order filter numerator coefficients.
Definition: 32b/filter_fo.c:133
FILTER_FO_getDenCoeffs
void FILTER_FO_getDenCoeffs(FILTER_FO_Handle handle, _iq *pa1)
Gets the first-order filter denominator coefficients.
Definition: 32b/filter_fo.c:58
_FILTER_FO_::b0
_iq b0
the numerator filter coefficient value for z^0
Definition: 32b/filter_fo.h:75
_FILTER_FO_::y1
_iq y1
the output value at time sample n=-1
Definition: 32b/filter_fo.h:80
FILTER_FO_setInitialConditions
void FILTER_FO_setInitialConditions(FILTER_FO_Handle handle, const _iq x1, const _iq y1)
Sets the initial conditions of the first-order filter.
Definition: 32b/filter_fo.c:120
FILTER_FO_setDenCoeffs
void FILTER_FO_setDenCoeffs(FILTER_FO_Handle handle, const _iq a1)
Sets the first-order filter denominator coefficients.
Definition: 32b/filter_fo.c:109
_FILTER_FO_Obj_
Defines the first-order filter (FILTER_FO) object.
Definition: float/filter_fo.h:69
filter_fo.h
Contains the public interface to the first-order filter (FILTER_FO) module routines.