MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

float/filter_fo.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2 * Copyright (c) 2013, 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/float/filter_fo.h"
43
44
45
46 // **************************************************************************
47 // the defines
48
49
50 #ifdef __TMS320C28XX_CLA__
51 #pragma CODE_SECTION(FILTER_FO_getDenCoeffs,"Cla1Prog2");
52 #pragma CODE_SECTION(FILTER_FO_getInitialConditions,"Cla1Prog2");
53 #pragma CODE_SECTION(FILTER_FO_getNumCoeffs,"Cla1Prog2");
54 #pragma CODE_SECTION(FILTER_FO_init,"Cla1Prog2");
55 #pragma CODE_SECTION(FILTER_FO_setDenCoeffs,"Cla1Prog2");
56 #pragma CODE_SECTION(FILTER_FO_setInitialConditions,"Cla1Prog2");
57 #pragma CODE_SECTION(FILTER_FO_setNumCoeffs,"Cla1Prog2");
58 #endif
59
60
61 // **************************************************************************
62 // the globals
63
64
65 // **************************************************************************
66 // the functions
67
68
69 void FILTER_FO_getDenCoeffs(FILTER_FO_Handle handle,float_t *pa1)
70 {
71 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
72
73
74 *pa1 = obj->a1;
75
76 return;
77 } // end of FILTER_FO_getDenCoeffs() function
78
79
80 void FILTER_FO_getInitialConditions(FILTER_FO_Handle handle,float_t *px1,float_t *py1)
81 {
82 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
83
84
85 *px1 = obj->x1;
86
87 *py1 = obj->y1;
88
89 return;
90 } // end of FILTER_FO_getInitialConditions() function
91
92
93 void FILTER_FO_getNumCoeffs(FILTER_FO_Handle handle,float_t *pb0,float_t *pb1)
94 {
95 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
96
97
98 *pb0 = obj->b0;
99 *pb1 = obj->b1;
100
101 return;
102 } // end of FILTER_FO_getNumCoeffs() function
103
104
105 FILTER_FO_Handle FILTER_FO_init(void *pMemory,const size_t numBytes)
106 {
107 FILTER_FO_Handle handle;
108
109
110 if((int16_t)numBytes < (int16_t)sizeof(FILTER_FO_Obj))
111 {
112 /*LDRA_INSPECTED 95 S MR12 11.3 "Below typecasting to NULL has no issues"*/
113 return((FILTER_FO_Handle)NULL);
114 }
115 // assign the handle
116 /*LDRA_INSPECTED 94 S MR12 11.3 "Below typecasting to void * has no issues"*/
117 /*LDRA_INSPECTED 95 S MR12 11.3 "Below typecasting to void * no issues"*/
118 handle = (FILTER_FO_Handle)pMemory;
119
120 /*LDRA_INSPECTED 71 S MR12 11.3 "Always, address of a static object is passed, so ok for wider scope"*/
121 return(handle);
122 } // end of FILTER_FO_init() function
123
124
125 void FILTER_FO_setDenCoeffs(FILTER_FO_Handle handle,const float_t a1)
126 {
127 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
128
129
130 obj->a1 = a1;
131
132 return;
133 } // end of FILTER_FO_setDenCoeffs() function
134
135
136 void FILTER_FO_setInitialConditions(FILTER_FO_Handle handle,const float_t x1,const float_t y1)
137 {
138 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
139
140
141 obj->x1 = x1;
142
143 obj->y1 = y1;
144
145 return;
146 } // end of FILTER_FO_setInitialConditions() function
147
148
149 void FILTER_FO_setNumCoeffs(FILTER_FO_Handle handle,const float_t b0,const float_t b1)
150 {
151 FILTER_FO_Obj *obj = (FILTER_FO_Obj *)handle;
152
153
154 obj->b0 = b0;
155 obj->b1 = b1;
156
157 return;
158 } // end of FILTER_FO_setNumCoeffs() function
159
160
161 // end of file
162
163
164
filter_fo.h
Contains the public interface to the first-order filter (FILTER_FO) module routines.
_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, float_t *px1, float_t *py1)
Gets the initial conditions of the first-order filter.
Definition: float/filter_fo.c:80
FILTER_FO_getNumCoeffs
void FILTER_FO_getNumCoeffs(FILTER_FO_Handle handle, float_t *pb0, float_t *pb1)
Gets the first-order filter numerator coefficients.
Definition: float/filter_fo.c:93
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
_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: float/filter_fo.c:105
FILTER_FO_setNumCoeffs
void FILTER_FO_setNumCoeffs(FILTER_FO_Handle handle, const float_t b0, const float_t b1)
Sets the first-order filter numerator coefficients.
Definition: float/filter_fo.c:149
FILTER_FO_getDenCoeffs
void FILTER_FO_getDenCoeffs(FILTER_FO_Handle handle, float_t *pa1)
Gets the first-order filter denominator coefficients.
Definition: float/filter_fo.c:69
_FILTER_FO_::b0
_iq b0
the numerator filter coefficient value for z^0
Definition: 32b/filter_fo.h:75
FILTER_FO_setDenCoeffs
void FILTER_FO_setDenCoeffs(FILTER_FO_Handle handle, const float_t a1)
Sets the first-order filter denominator coefficients.
Definition: float/filter_fo.c:125
_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 float_t x1, const float_t y1)
Sets the initial conditions of the first-order filter.
Definition: float/filter_fo.c:136
_FILTER_FO_Obj_
Defines the first-order filter (FILTER_FO) object.
Definition: float/filter_fo.h:69
float_t
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121