MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

32b/offset.h
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--*/
32 #ifndef _OFFSET_H_
33 #define _OFFSET_H_
34
40
41
42 // **************************************************************************
43 // the module includes
44
45 // modules
46 #include "sw/modules/types/src/types.h"
47 #include "sw/modules/iqmath/src/32b/IQmathLib.h"
48 #include "sw/modules/filter/src/32b/filter_fo.h"
49
50
55
56
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62
63 // **************************************************************************
64 // the defines
65
66
67 // **************************************************************************
68 // the typedefs
69
72 #ifdef FAST_ROM_V1p6
73 typedef struct _OFFSET_
74 {
75
76 _iq value;
77 FILTER_FO_Obj filter;
78 FILTER_FO_Handle filterHandle;
79
80 } OFFSET_Obj;
81 #else
82 typedef struct _OFFSET_
83 {
84
85 _iq value;
86 _iq bias;
87 FILTER_FO_Obj filter;
88 FILTER_FO_Handle filterHandle;
89
90 } OFFSET_Obj;
91 #endif
92
95 typedef struct _OFFSET_Obj_ *OFFSET_Handle;
96
97
98 // **************************************************************************
99 // the globals
100
101
102 // **************************************************************************
103 // the function prototypes
104
105
109 extern _iq OFFSET_getBeta(OFFSET_Handle handle);
110
111
115 static inline _iq OFFSET_getOffset(OFFSET_Handle handle)
116 {
117 OFFSET_Obj *obj = (OFFSET_Obj *)handle;
118
119 return(obj->value);
120 } // end of OFFSET_getOffset() function
121
122
127 extern OFFSET_Handle OFFSET_init(void *pMemory,const size_t numBytes);
128
129
137 static inline void OFFSET_run(OFFSET_Handle handle,const _iq inputValue)
138 {
139 OFFSET_Obj *obj = (OFFSET_Obj *)handle;
140
141 obj->value = FILTER_FO_run(obj->filterHandle,inputValue);
142
143 return;
144 } // end of OFFSET_run() function
145
146
150 extern void OFFSET_setBeta(OFFSET_Handle handle,const _iq beta);
151
152
156 extern void OFFSET_setInitCond(OFFSET_Handle handle,const _iq initCond);
157
158
162 extern void OFFSET_setOffset(OFFSET_Handle handle, _iq offsetValue);
163
164
165 #ifdef __cplusplus
166 }
167 #endif // extern "C"
168
170 #endif // end of _OFFSET_H_ definition
171
172
_OFFSET_::value
_iq value
the offset value (iq)
Definition: 32b/offset.h:85
types.h
Contains the public interface to the types definitions.
_OFFSET_::filter
FILTER_FO_Obj filter
the first order filter object used.
Definition: 32b/offset.h:87
FILTER_FO_run
static _iq FILTER_FO_run(FILTER_FO_Handle handle, const _iq inputValue)
Runs a first-order filter of the form y[n] = b0*x[n] + b1*x[n-1] - a1*y[n-1].
Definition: 32b/filter_fo.h:189
_FILTER_FO_
Defines the first-order filter (FILTER_FO) object.
Definition: 32b/filter_fo.h:71
_OFFSET_::bias
_iq bias
the bias value (iq)
Definition: 32b/offset.h:86
_iq
long _iq
Definition: 32b/IQmathLib.h:223
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
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
OFFSET_setBeta
void OFFSET_setBeta(OFFSET_Handle handle, const _iq beta)
Sets the beta offset filter coefficient.
Definition: 32b/offset.c:88
OFFSET_Obj
struct _OFFSET_ OFFSET_Obj
Defines the offset (OFFSET) object.
_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
IQmathLib.h
OFFSET_init
OFFSET_Handle OFFSET_init(void *pMemory, const size_t numBytes)
Initializes the offset.
Definition: 32b/offset.c:70
_FILTER_FO_Obj_
Defines the first-order filter (FILTER_FO) object.
Definition: float/filter_fo.h:69
OFFSET_run
static void OFFSET_run(OFFSET_Handle handle, const _iq inputValue)
Runs an offset filter of the form y[n] = beta*(x[n]+bias) + (1 - beta)*y[n-1] y -> The DC offset x ->...
Definition: 32b/offset.h:137
OFFSET_getOffset
static _iq OFFSET_getOffset(OFFSET_Handle handle)
Gets the offset value.
Definition: 32b/offset.h:115
filter_fo.h
Contains the public interface to the first-order filter (FILTER_FO) module routines.
_OFFSET_
Defines the offset (OFFSET) object.
Definition: 32b/offset.h:82