AM261x MCU+ SDK: ti_arm_trig.h Source File

| AM261x MCU+ SDK 26.00.00 |

ti_arm_trig.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2022 Texas Instruments Incorporated
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * 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
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
43 #ifndef TI_ARM_TRIG_H_
44 #define TI_ARM_TRIG_H_
45
46 /* ========================================================================== */
47 /* Macros */
48 /* ========================================================================== */
49
50 #define TRIG_TEXT_SECTION __attribute__((section(".trigText"))) __attribute__((always_inline)) //avoid function call overhead
51 #define TRIG_DATA_SECTION __attribute__((aligned(8), section(".trigData")))
52
53 /* ========================================================================== */
54 /* Function Declarations */
55 /* ========================================================================== */
56
68 extern float ti_arm_sin(float angleRad);
69
70
82 extern float ti_arm_cos(float angleRad);
83
84
95 extern void ti_arm_sincos(float angleRad, float *retValues);
96
108 extern float ti_arm_asin(float x);
109
121 extern float ti_arm_acos(float x);
122
133 extern float ti_arm_atan(float x);
134
135
147 extern float ti_arm_atan2(float y, float x);
148
157 TRIG_TEXT_SECTION static inline float ti_arm_sqrt(float x);
158
167 TRIG_TEXT_SECTION static inline float ti_arm_abs(float x);
168
169 /* ========================================================================== */
170 /* Static Function Definitions */
171 /* ========================================================================== */
172
173 TRIG_TEXT_SECTION static inline float ti_arm_sqrt(float x)
174 {
175 float r = 0;
176 __asm ("VSQRT.F32 %0, %1" : "=t" (r) : "t" (x));
177 return r;
178 }
179
180 TRIG_TEXT_SECTION static inline float ti_arm_abs(float x)
181 {
182 float r = 0;
183 __asm ("VABS.F32 %0, %1" : "=t" (r) : "t" (x));
184 return r;
185 }
186
187 #endif /* TI_ARM_TRIG_H */
188
ti_arm_sin
float ti_arm_sin(float angleRad)
Computes the trigonometric sine value of the input angle using polynomial approximation techniques.
ti_arm_atan
float ti_arm_atan(float x)
Computes the trigonometric arctangent value of the input value using polynomial approximation techniq...
ti_arm_sqrt
static TRIG_TEXT_SECTION float ti_arm_sqrt(float x)
Arm FPU Hardware Single-Precision Square Root Function.
Definition: ti_arm_trig.h:173
ti_arm_abs
static TRIG_TEXT_SECTION float ti_arm_abs(float x)
Arm FPU Hardware Single-Precision Absolute Value Function.
Definition: ti_arm_trig.h:180
ti_arm_sincos
void ti_arm_sincos(float angleRad, float *retValues)
Computes the trigonometric sine and cosine values of the input angle using polynomial approximation t...
ti_arm_asin
float ti_arm_asin(float x)
Computes the trigonometric arcsine value of the input value using polynomial approximation techniques...
TRIG_TEXT_SECTION
#define TRIG_TEXT_SECTION
Definition: ti_arm_trig.h:50
ti_arm_acos
float ti_arm_acos(float x)
Computes the trigonometric arccosine value of the input value using polynomial approximation techniqu...
ti_arm_atan2
float ti_arm_atan2(float y, float x)
Computes the trigonometric atan2 value of the input values using polynomial approximation techniques.
ti_arm_cos
float ti_arm_cos(float angleRad)
Computes the trigonometric cosine value of the input angle using polynomial approximation techniques.