MotorWare f2806x Module API Documentation
float/offset.h
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2014, 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 includes
44 
45 // modules
48 
49 
54 
55 
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
62 // **************************************************************************
63 // the defines
64 
65 
66 // **************************************************************************
67 // the typedefs
68 
71 typedef struct _OFFSET_
72 {
73 
77 
78 } OFFSET_Obj;
79 
80 
83 typedef struct _OFFSET_Obj_ *OFFSET_Handle;
84 
85 
86 // **************************************************************************
87 // the globals
88 
89 
90 // **************************************************************************
91 // the function prototypes
92 
93 
97 extern float_t OFFSET_getBeta(OFFSET_Handle handle);
98 
99 
103 static inline float_t OFFSET_getOffset(OFFSET_Handle handle)
104 {
105  OFFSET_Obj *obj = (OFFSET_Obj *)handle;
106 
107  return(obj->value);
108 } // end of OFFSET_getOffset() function
109 
110 
115 extern OFFSET_Handle OFFSET_init(void *pMemory,const size_t numBytes);
116 
117 
125 static inline void OFFSET_run(OFFSET_Handle handle,const float_t inputValue)
126 {
127  OFFSET_Obj *obj = (OFFSET_Obj *)handle;
128 
129  obj->value = FILTER_FO_run(obj->filterHandle,inputValue);
130 
131  return;
132 } // end of OFFSET_run() function
133 
134 
138 extern void OFFSET_setBeta(OFFSET_Handle handle,const float_t beta_rad);
139 
140 
144 extern void OFFSET_setInitCond(OFFSET_Handle handle,const float_t initCond);
145 
146 
150 extern void OFFSET_setOffset(OFFSET_Handle handle, float_t offsetValue);
151 
152 
153 #ifdef __cplusplus
154 }
155 #endif // extern "C"
156 
158 #endif // end of _OFFSET_H_ definition
159 
160 
_iq value
the offset value (iq)
Definition: 32b/offset.h:85
Contains the public interface to the first-order filter (FILTER_FO) module routines.
Contains the public interface to the types definitions.
void OFFSET_setOffset(OFFSET_Handle handle, float_t offsetValue)
Sets the offset value.
Definition: float/offset.c:115
static float_t OFFSET_getOffset(OFFSET_Handle handle)
Gets the offset value.
Definition: float/offset.h:103
FILTER_FO_Obj filter
the first order filter object used.
Definition: 32b/offset.h:87
float_t value
the offset value
Definition: float/offset.h:74
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
void OFFSET_setBeta(OFFSET_Handle handle, const float_t beta_rad)
Sets the beta offset filter coefficient.
Definition: float/offset.c:90
struct _OFFSET_Obj_ * OFFSET_Handle
Defines the OFFSET handle.
Definition: float/offset.h:83
struct _OFFSET_ OFFSET_Obj
Defines the offset (OFFSET) object.
void OFFSET_setInitCond(OFFSET_Handle handle, const float_t initCond)
Set the initial condition of the integrator or the value of y[n-1].
Definition: float/offset.c:104
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
static void OFFSET_run(OFFSET_Handle handle, const float_t inputValue)
Runs an offset filter of the form y[n] = beta*x[n] + (1 - beta)*y[n-1] y -> The DC offset x -> The AD...
Definition: float/offset.h:125
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.
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121
Defines the offset (OFFSET) object.
Definition: 32b/offset.h:82