MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

32b/offset.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/offset/src/32b/offset.h"
43
44
45
46 // **************************************************************************
47 // the defines
48
49
50 // **************************************************************************
51 // the globals
52
53
54 // **************************************************************************
55 // the functions
56
57
58 _iq OFFSET_getBeta(OFFSET_Handle handle)
59 {
60 OFFSET_Obj *obj = (OFFSET_Obj *)handle;
61 _iq b0;
62 _iq b1;
63
64 FILTER_FO_getNumCoeffs(obj->filterHandle,&b0,&b1);
65
66 return(b0);
67 } // end of OFFSET_getBeta() function
68
69
70 OFFSET_Handle OFFSET_init(void *pMemory,const size_t numBytes)
71 {
72 OFFSET_Handle handle;
73 OFFSET_Obj *obj;
74
75 if(numBytes < sizeof(OFFSET_Obj))
76 return((OFFSET_Handle)NULL);
77
78 // assign the handle
79 handle = (OFFSET_Handle)pMemory;
80 obj = (OFFSET_Obj *)handle;
81
82 obj->filterHandle = FILTER_FO_init(&(obj->filter),sizeof(obj->filter));
83
84 return(handle);
85 } // end of OFFSET_init() function
86
87
88 void OFFSET_setBeta(OFFSET_Handle handle,const _iq beta)
89 {
90 OFFSET_Obj *obj = (OFFSET_Obj *)handle;
91 _iq a1 = (beta - _IQ(1.0));
92 _iq b0 = beta;
93 _iq b1 = 0;
94
95 FILTER_FO_setDenCoeffs(obj->filterHandle,a1);
96 FILTER_FO_setNumCoeffs(obj->filterHandle,b0,b1);
97
98 return;
99 } // end of OFFSET_setBeta() function
100
101
102 void OFFSET_setInitCond(OFFSET_Handle handle,const _iq initCond)
103 {
104 OFFSET_Obj *obj = (OFFSET_Obj *)handle;
105
106 FILTER_FO_setInitialConditions(obj->filterHandle,initCond,initCond);
107 obj->value = initCond;
108
109 return;
110 } // end of OFFSET_setInitCond() function
111
112
113 void OFFSET_setOffset(OFFSET_Handle handle, _iq offsetValue)
114 {
115 OFFSET_Obj *obj = (OFFSET_Obj *)handle;
116
117 obj->value = offsetValue;
118
119 return;
120 } // end of OFFSET_setOffset() function
121
122 // end of file
123
124
125
126
127
128
129
130
131
132
133
_OFFSET_::value
_iq value
the offset value (iq)
Definition: 32b/offset.h:85
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
_IQ
#define _IQ(A)
Definition: 32b/IQmathLib.h:319
offset.h
Contains the public interface to the offset (OFFSET) module routines.
_OFFSET_::filter
FILTER_FO_Obj filter
the first order filter object used.
Definition: 32b/offset.h:87
_iq
long _iq
Definition: 32b/IQmathLib.h:223
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
OFFSET_setInitCond
void OFFSET_setInitCond(OFFSET_Handle handle, const _iq initCond)
Set the initial condition of the integrator or the value of y[n-1].
Definition: 32b/offset.c:102
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
OFFSET_setOffset
void OFFSET_setOffset(OFFSET_Handle handle, _iq offsetValue)
Sets the offset value.
Definition: 32b/offset.c:113
OFFSET_Handle
struct _OFFSET_Obj_ * OFFSET_Handle
Defines the OFFSET handle.
Definition: 32b/offset.h:95
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
OFFSET_setBeta
void OFFSET_setBeta(OFFSET_Handle handle, const _iq beta)
Sets the beta offset filter coefficient.
Definition: 32b/offset.c:88
_OFFSET_::filterHandle
FILTER_FO_Handle filterHandle
the first order filter handle.
Definition: 32b/offset.h:88
OFFSET_getBeta
_iq OFFSET_getBeta(OFFSET_Handle handle)
Gets the beta offset filter coefficient.
Definition: 32b/offset.c:58
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
OFFSET_init
OFFSET_Handle OFFSET_init(void *pMemory, const size_t numBytes)
Initializes the offset.
Definition: 32b/offset.c:70
_OFFSET_
Defines the offset (OFFSET) object.
Definition: 32b/offset.h:82