AM273x MCU+ SDK  08.05.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 
81 extern float ti_arm_cos(float angleRad);
82 
93 extern void ti_arm_sincos(float angleRad, float *retValues);
94 
106 extern float ti_arm_asin(float x);
107 
119 extern float ti_arm_acos(float x);
120 
131 extern float ti_arm_atan(float x);
132 
144 extern float ti_arm_atan2(float y, float x);
145 
154 TRIG_TEXT_SECTION static inline float ti_arm_sqrt(float x);
155 
164 TRIG_TEXT_SECTION static inline float ti_arm_abs(float x);
165 
166 /* ========================================================================== */
167 /* Static Function Definitions */
168 /* ========================================================================== */
169 
170 TRIG_TEXT_SECTION static inline float ti_arm_sqrt(float x)
171 {
172  float r = 0;
173  __asm ("VSQRT.F32 %0, %1" : "=t" (r) : "t" (x));
174  return r;
175 }
176 
177 TRIG_TEXT_SECTION static inline float ti_arm_abs(float x)
178 {
179  float r = 0;
180  __asm ("VABS.F32 %0, %1" : "=t" (r) : "t" (x));
181  return r;
182 }
183 
184 #endif /* TI_ARM_TRIG_H */
185 
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:170
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:177
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.