MotorWare f2806x Module API Documentation
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
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;
79 
80 } OFFSET_Obj;
81 #else
82 typedef struct _OFFSET_
83 {
84 
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 
_iq value
the offset value (iq)
Definition: 32b/offset.h:85
Contains the public interface to the types definitions.
FILTER_FO_Obj filter
the first order filter object used.
Definition: 32b/offset.h:87
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].
Defines the first-order filter (FILTER_FO) object.
Definition: 32b/filter_fo.h:71
_iq bias
the bias value (iq)
Definition: 32b/offset.h:86
long _iq
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
void OFFSET_setOffset(OFFSET_Handle handle, _iq offsetValue)
Sets the offset value.
Definition: 32b/offset.c:113
struct _OFFSET_Obj_ * OFFSET_Handle
Defines the OFFSET handle.
Definition: 32b/offset.h:95
void OFFSET_setBeta(OFFSET_Handle handle, const _iq beta)
Sets the beta offset filter coefficient.
Definition: 32b/offset.c:88
struct _OFFSET_ OFFSET_Obj
Defines the offset (OFFSET) object.
FILTER_FO_Handle filterHandle
the first order filter handle.
Definition: 32b/offset.h:88
_iq OFFSET_getBeta(OFFSET_Handle handle)
Gets the beta offset filter coefficient.
Definition: 32b/offset.c:58
OFFSET_Handle OFFSET_init(void *pMemory, const size_t numBytes)
Initializes the offset.
Definition: 32b/offset.c:70
Defines the first-order filter (FILTER_FO) object.
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
static _iq OFFSET_getOffset(OFFSET_Handle handle)
Gets the offset value.
Definition: 32b/offset.h:115
Contains the public interface to the first-order filter (FILTER_FO) module routines.
Defines the offset (OFFSET) object.
Definition: 32b/offset.h:82