MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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
45 #include "sw/modules/iqmath/src/32b/IQmathLib.h"
46 #include "sw/modules/math/src/32b/math.h"
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
76 _iq sinTh;
77 _iq cosTh;
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
IPARK_Obj
struct _IPARK_Obj_ IPARK_Obj
Defines the IPARK object.
IPARK_init
IPARK_Handle IPARK_init(void *pMemory, const size_t numBytes)
Initializes the inverse Park transform module.
Definition: 32b/ipark.c:56
_IQsinPU
#define _IQsinPU(A)
Definition: 32b/IQmathLib.h:1379
_MATH_vec2_
Defines a two element vector.
Definition: 32b/math.h:248
_IQcosPU
#define _IQcosPU(A)
Definition: 32b/IQmathLib.h:1745
IPARK_getSinTh
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
_IPARK_Obj_
Defines the IPARK object.
Definition: 32b/ipark.h:73
_iq
long _iq
Definition: 32b/IQmathLib.h:223
IPARK_setCosTh
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
_IQmpy
#define _IQmpy(A, B)
Definition: 32b/IQmathLib.h:809
_IPARK_Obj_::cosTh
_iq cosTh
the cosine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/ipark.h:77
_MATH_vec2_::value
_iq value[2]
Definition: 32b/math.h:251
math.h
Contains the public interface to the math (MATH) module routines.
IPARK_run
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
IPARK_setup
static void IPARK_setup(IPARK_Handle handle, const _iq Th_pu)
Sets up the inverse Park transform module.
Definition: 32b/ipark.h:198
_IPARK_Obj_::sinTh
_iq sinTh
the sine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/ipark.h:76
IPARK_setPhasor
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
IPARK_getCosTh
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
IPARK_Handle
struct _IPARK_Obj_ * IPARK_Handle
Defines the IPARK handle.
Definition: 32b/ipark.h:84
IQmathLib.h
IPARK_getPhasor
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
IPARK_setSinTh
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