MotorWare f2806x Module API Documentation
32b/ipark.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 _IPARK_H_
33 #define _IPARK_H_
34 
40 
41 
42 // **************************************************************************
43 // the includes
44 
47 
48 
53 
54 
55 // Include the algorithm overview defined in modules/<module>/docs/doxygen/doxygen.h
57 
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 
64 // **************************************************************************
65 // the defines
66 
67 
68 // **************************************************************************
69 // the typedefs
70 
73 typedef struct _IPARK_Obj_
74 {
75 
78 
79 } IPARK_Obj;
80 
81 
84 typedef struct _IPARK_Obj_ *IPARK_Handle;
85 
86 
87 // **************************************************************************
88 // the function prototypes
89 
93 static inline _iq IPARK_getCosTh(IPARK_Handle handle)
94 {
95  IPARK_Obj *obj = (IPARK_Obj *)handle;
96 
97  return(obj->cosTh);
98 } // end of IPARK_getCosTh() function
99 
100 
104 static inline void IPARK_getPhasor(IPARK_Handle handle,MATH_vec2 *pPhasor)
105 {
106  IPARK_Obj *obj = (IPARK_Obj *)handle;
107 
108  pPhasor->value[0] = obj->cosTh;
109  pPhasor->value[1] = obj->sinTh;
110 
111  return;
112 } // end of IPARK_getPhasor() function
113 
114 
118 static inline _iq IPARK_getSinTh(IPARK_Handle handle)
119 {
120  IPARK_Obj *obj = (IPARK_Obj *)handle;
121 
122  return(obj->sinTh);
123 } // end of IPARK_getSinTh() function
124 
125 
130 extern IPARK_Handle IPARK_init(void *pMemory,const size_t numBytes);
131 
132 
137 static inline void IPARK_run(IPARK_Handle handle,const MATH_vec2 *pInVec,MATH_vec2 *pOutVec)
138 {
139  IPARK_Obj *obj = (IPARK_Obj *)handle;
140 
141  _iq sinTh = obj->sinTh;
142  _iq cosTh = obj->cosTh;
143 
144  _iq value_0 = pInVec->value[0];
145  _iq value_1 = pInVec->value[1];
146 
147 
148  pOutVec->value[0] = _IQmpy(value_0,cosTh) - _IQmpy(value_1,sinTh);
149  pOutVec->value[1] = _IQmpy(value_1,cosTh) + _IQmpy(value_0,sinTh);
150 
151  return;
152 } // end of IPARK_run() function
153 
154 
158 static inline void IPARK_setCosTh(IPARK_Handle handle,const _iq cosTh)
159 {
160  IPARK_Obj *obj = (IPARK_Obj *)handle;
161 
162  obj->cosTh = cosTh;
163 
164  return;
165 } // end of IPARK_setCosTh() function
166 
167 
171 static inline void IPARK_setPhasor(IPARK_Handle handle,const MATH_vec2 *pPhasor)
172 {
173  IPARK_Obj *obj = (IPARK_Obj *)handle;
174 
175  obj->cosTh = pPhasor->value[0];
176  obj->sinTh = pPhasor->value[1];
177 
178  return;
179 } // end of IPARK_setPhasor() function
180 
181 
185 static inline void IPARK_setSinTh(IPARK_Handle handle,const _iq sinTh)
186 {
187  IPARK_Obj *obj = (IPARK_Obj *)handle;
188 
189  obj->sinTh = sinTh;
190 
191  return;
192 } // end of IPARK_setSinTh() function
193 
194 
198 static inline void IPARK_setup(IPARK_Handle handle,const _iq Th_pu)
199 {
200  IPARK_Obj *obj = (IPARK_Obj *)handle;
201 
202  obj->sinTh = _IQsinPU(Th_pu);
203  obj->cosTh = _IQcosPU(Th_pu);
204 
205  return;
206 } // end of IPARK_setup() function
207 
208 
209 #ifdef __cplusplus
210 }
211 #endif // extern "C"
212 
214 #endif // end of _IPARK_H_ definition
215 
216 
struct _IPARK_Obj_ IPARK_Obj
Defines the IPARK object.
IPARK_Handle IPARK_init(void *pMemory, const size_t numBytes)
Initializes the inverse Park transform module.
Definition: 32b/ipark.c:56
#define _IQsinPU(A)
Defines a two element vector.
Definition: 32b/math.h:248
#define _IQcosPU(A)
static _iq IPARK_getSinTh(IPARK_Handle handle)
Gets the sine of the angle between the d,q and the alpha,beta coordinate systems. ...
Definition: 32b/ipark.h:118
Defines the IPARK object.
Definition: 32b/ipark.h:73
long _iq
static void IPARK_setCosTh(IPARK_Handle handle, const _iq cosTh)
Sets the cosine of the angle between the d,q and the alpha,beta coordinate systems.
Definition: 32b/ipark.h:158
#define _IQmpy(A, B)
_iq cosTh
the cosine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/ipark.h:77
_iq value[2]
Definition: 32b/math.h:251
Contains the public interface to the math (MATH) module routines.
static void IPARK_run(IPARK_Handle handle, const MATH_vec2 *pInVec, MATH_vec2 *pOutVec)
Runs the inverse Park transform module.
Definition: 32b/ipark.h:137
static void IPARK_setup(IPARK_Handle handle, const _iq Th_pu)
Sets up the inverse Park transform module.
Definition: 32b/ipark.h:198
_iq sinTh
the sine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/ipark.h:76
static void IPARK_setPhasor(IPARK_Handle handle, const MATH_vec2 *pPhasor)
Sets the cosine/sine phasor for the inverse Park transform.
Definition: 32b/ipark.h:171
static _iq IPARK_getCosTh(IPARK_Handle handle)
Gets the cosine of the angle between the d,q and the alpha,beta coordinate systems.
Definition: 32b/ipark.h:93
struct _IPARK_Obj_ * IPARK_Handle
Defines the IPARK handle.
Definition: 32b/ipark.h:84
static void IPARK_getPhasor(IPARK_Handle handle, MATH_vec2 *pPhasor)
Gets the cosine/sine phasor for the inverse Park transform.
Definition: 32b/ipark.h:104
static void IPARK_setSinTh(IPARK_Handle handle, const _iq sinTh)
Sets the sine of the angle between the d,q and the alpha,beta coordinate systems. ...
Definition: 32b/ipark.h:185