MotorWare f2806x Module API Documentation
float/ipark.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 _IPARK_H_
33 #define _IPARK_H_
34 
40 
41 
42 // **************************************************************************
43 // the includes
44 #ifdef __TMS320C28XX_CLA__
46 #else
47 #include <math.h>
48 #endif
49 
50 // modules
52 
53 
58 
59 
60 // Include the algorithm overview defined in modules/<module>/docs/doxygen/doxygen.h
62 
63 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
68 
69 // **************************************************************************
70 // the defines
71 
72 
73 // **************************************************************************
74 // the typedefs
75 
78 typedef struct _IPARK_Obj_
79 {
80 
83 
84 } IPARK_Obj;
85 
86 
89 typedef struct _IPARK_Obj_ *IPARK_Handle;
90 
91 
92 // **************************************************************************
93 // the function prototypes
94 
98 static inline float_t IPARK_getCosTh(IPARK_Handle handle)
99 {
100  IPARK_Obj *obj = (IPARK_Obj *)handle;
101 
102  return(obj->cosTh);
103 } // end of IPARK_getCosTh() function
104 
105 
109 static inline void IPARK_getPhasor(IPARK_Handle handle,MATH_vec2 *pPhasor)
110 {
111  IPARK_Obj *obj = (IPARK_Obj *)handle;
112 
113  pPhasor->value[0] = obj->cosTh;
114  pPhasor->value[1] = obj->sinTh;
115 
116  return;
117 } // end of IPARK_getPhasor() function
118 
119 
123 static inline float_t IPARK_getSinTh(IPARK_Handle handle)
124 {
125  IPARK_Obj *obj = (IPARK_Obj *)handle;
126 
127  return(obj->sinTh);
128 } // end of IPARK_getSinTh() function
129 
130 
135 extern IPARK_Handle IPARK_init(void *pMemory,const size_t numBytes);
136 
137 
142 #ifdef __TMS320C28XX_CLA__
143 #pragma FUNC_ALWAYS_INLINE(IPARK_run)
144 #endif
145 static inline void IPARK_run(IPARK_Handle handle,const MATH_vec2 *pInVec,MATH_vec2 *pOutVec)
146 {
147  IPARK_Obj *obj = (IPARK_Obj *)handle;
148 
149  float_t sinTh = obj->sinTh;
150  float_t cosTh = obj->cosTh;
151 
152  float_t value_0 = pInVec->value[0];
153  float_t value_1 = pInVec->value[1];
154 
155  pOutVec->value[0] = (value_0 * cosTh) - (value_1 * sinTh);
156  pOutVec->value[1] = (value_1 * cosTh) + (value_0 * sinTh);
157 
158  return;
159 } // end of IPARK_run() function
160 
161 
165 static inline void IPARK_setCosTh(IPARK_Handle handle,const float_t cosTh)
166 {
167  IPARK_Obj *obj = (IPARK_Obj *)handle;
168 
169  obj->cosTh = cosTh;
170 
171  return;
172 } // end of IPARK_setCosTh() function
173 
174 
178 static inline void IPARK_setPhasor(IPARK_Handle handle,const MATH_vec2 *pPhasor)
179 {
180  IPARK_Obj *obj = (IPARK_Obj *)handle;
181 
182  obj->cosTh = pPhasor->value[0];
183  obj->sinTh = pPhasor->value[1];
184 
185  return;
186 } // end of IPARK_setPhasor() function
187 
188 
192 static inline void IPARK_setSinTh(IPARK_Handle handle,const float_t sinTh)
193 {
194  IPARK_Obj *obj = (IPARK_Obj *)handle;
195 
196  obj->sinTh = sinTh;
197 
198  return;
199 } // end of IPARK_setSinTh() function
200 
201 
205 static inline void IPARK_setup(IPARK_Handle handle,const float_t Th)
206 {
207  IPARK_Obj *obj = (IPARK_Obj *)handle;
208 
209 #ifdef __TMS320C28XX_CLA__
210  obj->sinTh = CLAsin_inline(Th);
211  obj->cosTh = CLAcos_inline(Th);
212 #else
213  obj->sinTh = (float_t)sin((double_t)Th);
214  obj->cosTh = (float_t)cos((double_t)Th);
215 #endif
216 
217  return;
218 } // end of IPARK_setup() function
219 
220 
221 #ifdef __cplusplus
222 }
223 #endif // extern "C"
224 
226 #endif // end of _IPARK_H_ definition
227 
228 
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
long double double_t
Defines the portable data type for 64 bit, signed floating-point data.
Definition: types.h:126
static float_t IPARK_getSinTh(IPARK_Handle handle)
Gets the sine of the angle between the d,q and the alpha,beta coordinate systems. ...
Definition: float/ipark.h:123
float_t sinTh
the sine of the angle between the d,q and the alpha,beta coordinate systems
Definition: float/ipark.h:81
static void IPARK_setup(IPARK_Handle handle, const float_t Th)
Sets up the inverse Park transform module.
Definition: float/ipark.h:205
Contains the public interface to the math (MATH) module routines.
Defines a two element vector.
Definition: 32b/math.h:248
Defines the IPARK object.
Definition: 32b/ipark.h:73
static void IPARK_getPhasor(IPARK_Handle handle, MATH_vec2 *pPhasor)
Gets the cosine/sine phasor for the inverse Park transform.
Definition: float/ipark.h:109
_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
static void IPARK_setPhasor(IPARK_Handle handle, const MATH_vec2 *pPhasor)
Sets the cosine/sine phasor for the inverse Park transform.
Definition: float/ipark.h:178
static void IPARK_setCosTh(IPARK_Handle handle, const float_t cosTh)
Sets the cosine of the angle between the d,q and the alpha,beta coordinate systems.
Definition: float/ipark.h:165
_iq sinTh
the sine of the angle between the d,q and the alpha,beta coordinate systems
Definition: 32b/ipark.h:76
float_t cosTh
the cosine of the angle between the d,q and the alpha,beta coordinate systems
Definition: float/ipark.h:82
static float_t IPARK_getCosTh(IPARK_Handle handle)
Gets the cosine of the angle between the d,q and the alpha,beta coordinate systems.
Definition: float/ipark.h:98
struct _IPARK_Obj_ * IPARK_Handle
Defines the IPARK handle.
Definition: float/ipark.h:89
static void IPARK_setSinTh(IPARK_Handle handle, const float_t sinTh)
Sets the sine of the angle between the d,q and the alpha,beta coordinate systems. ...
Definition: float/ipark.h:192
static void IPARK_run(IPARK_Handle handle, const MATH_vec2 *pInVec, MATH_vec2 *pOutVec)
Runs the inverse Park transform module.
Definition: float/ipark.h:145
float float_t
Defines the portable data type for 32 bit, signed floating-point data.
Definition: types.h:121