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