Fork of mbed-dsp. CMSIS-DSP library of supporting NEON
Dependents: mbed-os-example-cmsis_dsp_neon
Fork of mbed-dsp by
Information
Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.
CMSIS-DSP of supporting NEON
What is this ?
A library for CMSIS-DSP of supporting NEON.
We supported the NEON to CMSIS-DSP Ver1.4.3(CMSIS V4.1) that ARM supplied, has achieved the processing speed improvement.
If you use the mbed-dsp library, you can use to replace this library.
CMSIS-DSP of supporting NEON is provied as a library.
Library Creation environment
CMSIS-DSP library of supporting NEON was created by the following environment.
- Compiler
ARMCC Version 5.03 - Compile option switch[C Compiler]
-DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -O3 -Otime --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp --vectorize --asm
- Compile option switch[Assembler]
--cpreproc --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp
Effects of NEON support
In the data which passes to each function, large size will be expected more effective than small size.
Also if the data is a multiple of 16, effect will be expected in every function in the CMSIS-DSP.
NEON対応CMSIS-DSP
概要
NEON対応したCMSIS-DSPのライブラリです。
ARM社提供のCMSIS-DSP Ver1.4.3(CMSIS V4.1)をターゲットにNEON対応を行ない、処理速度向上を実現しております。
mbed-dspライブラリを使用している場合は、本ライブラリに置き換えて使用することができます。
NEON対応したCMSIS-DSPはライブラリで提供します。
ライブラリ作成環境
NEON対応CMSIS-DSPライブラリは、以下の環境で作成しています。
- コンパイラ
ARMCC Version 5.03 - コンパイルオプションスイッチ[C Compiler]
-DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -O3 -Otime --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp --vectorize --asm
- コンパイルオプションスイッチ[Assembler]
--cpreproc --cpu=Cortex-A9 --littleend --arm --apcs=/interwork --no_unaligned_access --fpu=vfpv3_fp16 --fpmode=fast --apcs=/hardfp
NEON対応による効果について
CMSIS-DSP内の各関数へ渡すデータは、小さいサイズよりも大きいサイズの方が効果が見込めます。
また、16の倍数のデータであれば、CMSIS-DSP内のどの関数でも効果が見込めます。
cmsis_dsp/ControllerFunctions/arm_sin_cos_f32.c@2:da51fb522205, 2013-05-30 (annotated)
- Committer:
- emilmont
- Date:
- Thu May 30 17:10:11 2013 +0100
- Revision:
- 2:da51fb522205
- Parent:
- 1:fdd22bb7aa52
- Child:
- 3:7a284390b0ce
Keep "cmsis-dsp" module in synch with its source
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:fdd22bb7aa52 | 1 | /* ---------------------------------------------------------------------- |
emilmont | 1:fdd22bb7aa52 | 2 | * Copyright (C) 2010 ARM Limited. All rights reserved. |
emilmont | 1:fdd22bb7aa52 | 3 | * |
emilmont | 1:fdd22bb7aa52 | 4 | * $Date: 15. February 2012 |
emilmont | 2:da51fb522205 | 5 | * $Revision: V1.1.0 |
emilmont | 1:fdd22bb7aa52 | 6 | * |
emilmont | 2:da51fb522205 | 7 | * Project: CMSIS DSP Library |
emilmont | 2:da51fb522205 | 8 | * Title: arm_sin_cos_f32.c |
emilmont | 1:fdd22bb7aa52 | 9 | * |
emilmont | 2:da51fb522205 | 10 | * Description: Sine and Cosine calculation for floating-point values. |
emilmont | 1:fdd22bb7aa52 | 11 | * |
emilmont | 1:fdd22bb7aa52 | 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
emilmont | 1:fdd22bb7aa52 | 13 | * |
emilmont | 1:fdd22bb7aa52 | 14 | * Version 1.1.0 2012/02/15 |
emilmont | 1:fdd22bb7aa52 | 15 | * Updated with more optimizations, bug fixes and minor API changes. |
emilmont | 1:fdd22bb7aa52 | 16 | * |
emilmont | 1:fdd22bb7aa52 | 17 | * Version 1.0.10 2011/7/15 |
emilmont | 1:fdd22bb7aa52 | 18 | * Big Endian support added and Merged M0 and M3/M4 Source code. |
emilmont | 1:fdd22bb7aa52 | 19 | * |
emilmont | 1:fdd22bb7aa52 | 20 | * Version 1.0.3 2010/11/29 |
emilmont | 1:fdd22bb7aa52 | 21 | * Re-organized the CMSIS folders and updated documentation. |
emilmont | 1:fdd22bb7aa52 | 22 | * |
emilmont | 1:fdd22bb7aa52 | 23 | * Version 1.0.2 2010/11/11 |
emilmont | 1:fdd22bb7aa52 | 24 | * Documentation updated. |
emilmont | 1:fdd22bb7aa52 | 25 | * |
emilmont | 1:fdd22bb7aa52 | 26 | * Version 1.0.1 2010/10/05 |
emilmont | 1:fdd22bb7aa52 | 27 | * Production release and review comments incorporated. |
emilmont | 1:fdd22bb7aa52 | 28 | * |
emilmont | 1:fdd22bb7aa52 | 29 | * Version 1.0.0 2010/09/20 |
emilmont | 1:fdd22bb7aa52 | 30 | * Production release and review comments incorporated. |
emilmont | 1:fdd22bb7aa52 | 31 | * -------------------------------------------------------------------- */ |
emilmont | 1:fdd22bb7aa52 | 32 | |
emilmont | 1:fdd22bb7aa52 | 33 | #include "arm_math.h" |
emilmont | 1:fdd22bb7aa52 | 34 | |
emilmont | 1:fdd22bb7aa52 | 35 | /** |
emilmont | 1:fdd22bb7aa52 | 36 | * @ingroup groupController |
emilmont | 1:fdd22bb7aa52 | 37 | */ |
emilmont | 1:fdd22bb7aa52 | 38 | |
emilmont | 1:fdd22bb7aa52 | 39 | /** |
emilmont | 1:fdd22bb7aa52 | 40 | * @defgroup SinCos Sine Cosine |
emilmont | 1:fdd22bb7aa52 | 41 | * |
emilmont | 1:fdd22bb7aa52 | 42 | * Computes the trigonometric sine and cosine values using a combination of table lookup |
emilmont | 1:fdd22bb7aa52 | 43 | * and linear interpolation. |
emilmont | 1:fdd22bb7aa52 | 44 | * There are separate functions for Q31 and floating-point data types. |
emilmont | 1:fdd22bb7aa52 | 45 | * The input to the floating-point version is in degrees while the |
emilmont | 1:fdd22bb7aa52 | 46 | * fixed-point Q31 have a scaled input with the range |
emilmont | 1:fdd22bb7aa52 | 47 | * [-1 0.9999] mapping to [-180 179] degrees. |
emilmont | 1:fdd22bb7aa52 | 48 | * |
emilmont | 1:fdd22bb7aa52 | 49 | * The implementation is based on table lookup using 360 values together with linear interpolation. |
emilmont | 1:fdd22bb7aa52 | 50 | * The steps used are: |
emilmont | 1:fdd22bb7aa52 | 51 | * -# Calculation of the nearest integer table index. |
emilmont | 1:fdd22bb7aa52 | 52 | * -# Compute the fractional portion (fract) of the input. |
emilmont | 1:fdd22bb7aa52 | 53 | * -# Fetch the value corresponding to \c index from sine table to \c y0 and also value from \c index+1 to \c y1. |
emilmont | 1:fdd22bb7aa52 | 54 | * -# Sine value is computed as <code> *psinVal = y0 + (fract * (y1 - y0))</code>. |
emilmont | 1:fdd22bb7aa52 | 55 | * -# Fetch the value corresponding to \c index from cosine table to \c y0 and also value from \c index+1 to \c y1. |
emilmont | 1:fdd22bb7aa52 | 56 | * -# Cosine value is computed as <code> *pcosVal = y0 + (fract * (y1 - y0))</code>. |
emilmont | 1:fdd22bb7aa52 | 57 | */ |
emilmont | 1:fdd22bb7aa52 | 58 | |
emilmont | 1:fdd22bb7aa52 | 59 | /** |
emilmont | 1:fdd22bb7aa52 | 60 | * @addtogroup SinCos |
emilmont | 1:fdd22bb7aa52 | 61 | * @{ |
emilmont | 1:fdd22bb7aa52 | 62 | */ |
emilmont | 1:fdd22bb7aa52 | 63 | |
emilmont | 1:fdd22bb7aa52 | 64 | |
emilmont | 1:fdd22bb7aa52 | 65 | /** |
emilmont | 1:fdd22bb7aa52 | 66 | * \par |
emilmont | 1:fdd22bb7aa52 | 67 | * Cosine Table is generated from following loop |
emilmont | 1:fdd22bb7aa52 | 68 | * <pre>for(i = 0; i < 360; i++) |
emilmont | 1:fdd22bb7aa52 | 69 | * { |
emilmont | 1:fdd22bb7aa52 | 70 | * cosTable[i]= cos((i-180) * PI/180.0); |
emilmont | 1:fdd22bb7aa52 | 71 | * } </pre> |
emilmont | 1:fdd22bb7aa52 | 72 | */ |
emilmont | 1:fdd22bb7aa52 | 73 | |
emilmont | 1:fdd22bb7aa52 | 74 | static const float32_t cosTable[360] = { |
emilmont | 1:fdd22bb7aa52 | 75 | -0.999847695156391270f, -0.999390827019095760f, -0.998629534754573830f, |
emilmont | 1:fdd22bb7aa52 | 76 | -0.997564050259824200f, -0.996194698091745550f, -0.994521895368273290f, |
emilmont | 1:fdd22bb7aa52 | 77 | -0.992546151641321980f, -0.990268068741570250f, |
emilmont | 1:fdd22bb7aa52 | 78 | -0.987688340595137660f, -0.984807753012208020f, -0.981627183447663980f, |
emilmont | 1:fdd22bb7aa52 | 79 | -0.978147600733805690f, -0.974370064785235250f, -0.970295726275996470f, |
emilmont | 1:fdd22bb7aa52 | 80 | -0.965925826289068200f, -0.961261695938318670f, |
emilmont | 1:fdd22bb7aa52 | 81 | -0.956304755963035440f, -0.951056516295153530f, -0.945518575599316740f, |
emilmont | 1:fdd22bb7aa52 | 82 | -0.939692620785908320f, -0.933580426497201740f, -0.927183854566787310f, |
emilmont | 1:fdd22bb7aa52 | 83 | -0.920504853452440150f, -0.913545457642600760f, |
emilmont | 1:fdd22bb7aa52 | 84 | -0.906307787036649940f, -0.898794046299167040f, -0.891006524188367790f, |
emilmont | 1:fdd22bb7aa52 | 85 | -0.882947592858926770f, -0.874619707139395740f, -0.866025403784438710f, |
emilmont | 1:fdd22bb7aa52 | 86 | -0.857167300702112220f, -0.848048096156425960f, |
emilmont | 1:fdd22bb7aa52 | 87 | -0.838670567945424160f, -0.829037572555041620f, -0.819152044288991580f, |
emilmont | 1:fdd22bb7aa52 | 88 | -0.809016994374947340f, -0.798635510047292940f, -0.788010753606721900f, |
emilmont | 1:fdd22bb7aa52 | 89 | -0.777145961456970680f, -0.766044443118977900f, |
emilmont | 1:fdd22bb7aa52 | 90 | -0.754709580222772010f, -0.743144825477394130f, -0.731353701619170460f, |
emilmont | 1:fdd22bb7aa52 | 91 | -0.719339800338651300f, -0.707106781186547460f, -0.694658370458997030f, |
emilmont | 1:fdd22bb7aa52 | 92 | -0.681998360062498370f, -0.669130606358858240f, |
emilmont | 1:fdd22bb7aa52 | 93 | -0.656059028990507500f, -0.642787609686539360f, -0.629320391049837280f, |
emilmont | 1:fdd22bb7aa52 | 94 | -0.615661475325658290f, -0.601815023152048380f, -0.587785252292473030f, |
emilmont | 1:fdd22bb7aa52 | 95 | -0.573576436351045830f, -0.559192903470746680f, |
emilmont | 1:fdd22bb7aa52 | 96 | -0.544639035015027080f, -0.529919264233204790f, -0.515038074910054270f, |
emilmont | 1:fdd22bb7aa52 | 97 | -0.499999999999999780f, -0.484809620246337000f, -0.469471562785890530f, |
emilmont | 1:fdd22bb7aa52 | 98 | -0.453990499739546750f, -0.438371146789077510f, |
emilmont | 1:fdd22bb7aa52 | 99 | -0.422618261740699330f, -0.406736643075800100f, -0.390731128489273600f, |
emilmont | 1:fdd22bb7aa52 | 100 | -0.374606593415912070f, -0.358367949545300270f, -0.342020143325668710f, |
emilmont | 1:fdd22bb7aa52 | 101 | -0.325568154457156420f, -0.309016994374947340f, |
emilmont | 1:fdd22bb7aa52 | 102 | -0.292371704722736660f, -0.275637355816999050f, -0.258819045102520850f, |
emilmont | 1:fdd22bb7aa52 | 103 | -0.241921895599667790f, -0.224951054343864810f, -0.207911690817759120f, |
emilmont | 1:fdd22bb7aa52 | 104 | -0.190808995376544800f, -0.173648177666930300f, |
emilmont | 1:fdd22bb7aa52 | 105 | -0.156434465040231040f, -0.139173100960065350f, -0.121869343405147370f, |
emilmont | 1:fdd22bb7aa52 | 106 | -0.104528463267653330f, -0.087155742747658235f, -0.069756473744125330f, |
emilmont | 1:fdd22bb7aa52 | 107 | -0.052335956242943620f, -0.034899496702500733f, |
emilmont | 1:fdd22bb7aa52 | 108 | -0.017452406437283477f, 0.000000000000000061f, 0.017452406437283376f, |
emilmont | 1:fdd22bb7aa52 | 109 | 0.034899496702501080f, 0.052335956242943966f, 0.069756473744125455f, |
emilmont | 1:fdd22bb7aa52 | 110 | 0.087155742747658138f, 0.104528463267653460f, |
emilmont | 1:fdd22bb7aa52 | 111 | 0.121869343405147490f, 0.139173100960065690f, 0.156434465040230920f, |
emilmont | 1:fdd22bb7aa52 | 112 | 0.173648177666930410f, 0.190808995376544920f, 0.207911690817759450f, |
emilmont | 1:fdd22bb7aa52 | 113 | 0.224951054343864920f, 0.241921895599667900f, |
emilmont | 1:fdd22bb7aa52 | 114 | 0.258819045102520740f, 0.275637355816999160f, 0.292371704722736770f, |
emilmont | 1:fdd22bb7aa52 | 115 | 0.309016994374947450f, 0.325568154457156760f, 0.342020143325668820f, |
emilmont | 1:fdd22bb7aa52 | 116 | 0.358367949545300380f, 0.374606593415911960f, |
emilmont | 1:fdd22bb7aa52 | 117 | 0.390731128489273940f, 0.406736643075800210f, 0.422618261740699440f, |
emilmont | 1:fdd22bb7aa52 | 118 | 0.438371146789077460f, 0.453990499739546860f, 0.469471562785890860f, |
emilmont | 1:fdd22bb7aa52 | 119 | 0.484809620246337110f, 0.500000000000000110f, |
emilmont | 1:fdd22bb7aa52 | 120 | 0.515038074910054380f, 0.529919264233204900f, 0.544639035015027200f, |
emilmont | 1:fdd22bb7aa52 | 121 | 0.559192903470746790f, 0.573576436351046050f, 0.587785252292473140f, |
emilmont | 1:fdd22bb7aa52 | 122 | 0.601815023152048270f, 0.615661475325658290f, |
emilmont | 1:fdd22bb7aa52 | 123 | 0.629320391049837500f, 0.642787609686539360f, 0.656059028990507280f, |
emilmont | 1:fdd22bb7aa52 | 124 | 0.669130606358858240f, 0.681998360062498480f, 0.694658370458997370f, |
emilmont | 1:fdd22bb7aa52 | 125 | 0.707106781186547570f, 0.719339800338651190f, |
emilmont | 1:fdd22bb7aa52 | 126 | 0.731353701619170570f, 0.743144825477394240f, 0.754709580222772010f, |
emilmont | 1:fdd22bb7aa52 | 127 | 0.766044443118978010f, 0.777145961456970900f, 0.788010753606722010f, |
emilmont | 1:fdd22bb7aa52 | 128 | 0.798635510047292830f, 0.809016994374947450f, |
emilmont | 1:fdd22bb7aa52 | 129 | 0.819152044288991800f, 0.829037572555041620f, 0.838670567945424050f, |
emilmont | 1:fdd22bb7aa52 | 130 | 0.848048096156425960f, 0.857167300702112330f, 0.866025403784438710f, |
emilmont | 1:fdd22bb7aa52 | 131 | 0.874619707139395740f, 0.882947592858926990f, |
emilmont | 1:fdd22bb7aa52 | 132 | 0.891006524188367900f, 0.898794046299167040f, 0.906307787036649940f, |
emilmont | 1:fdd22bb7aa52 | 133 | 0.913545457642600870f, 0.920504853452440370f, 0.927183854566787420f, |
emilmont | 1:fdd22bb7aa52 | 134 | 0.933580426497201740f, 0.939692620785908430f, |
emilmont | 1:fdd22bb7aa52 | 135 | 0.945518575599316850f, 0.951056516295153530f, 0.956304755963035440f, |
emilmont | 1:fdd22bb7aa52 | 136 | 0.961261695938318890f, 0.965925826289068310f, 0.970295726275996470f, |
emilmont | 1:fdd22bb7aa52 | 137 | 0.974370064785235250f, 0.978147600733805690f, |
emilmont | 1:fdd22bb7aa52 | 138 | 0.981627183447663980f, 0.984807753012208020f, 0.987688340595137770f, |
emilmont | 1:fdd22bb7aa52 | 139 | 0.990268068741570360f, 0.992546151641321980f, 0.994521895368273290f, |
emilmont | 1:fdd22bb7aa52 | 140 | 0.996194698091745550f, 0.997564050259824200f, |
emilmont | 1:fdd22bb7aa52 | 141 | 0.998629534754573830f, 0.999390827019095760f, 0.999847695156391270f, |
emilmont | 1:fdd22bb7aa52 | 142 | 1.000000000000000000f, 0.999847695156391270f, 0.999390827019095760f, |
emilmont | 1:fdd22bb7aa52 | 143 | 0.998629534754573830f, 0.997564050259824200f, |
emilmont | 1:fdd22bb7aa52 | 144 | 0.996194698091745550f, 0.994521895368273290f, 0.992546151641321980f, |
emilmont | 1:fdd22bb7aa52 | 145 | 0.990268068741570360f, 0.987688340595137770f, 0.984807753012208020f, |
emilmont | 1:fdd22bb7aa52 | 146 | 0.981627183447663980f, 0.978147600733805690f, |
emilmont | 1:fdd22bb7aa52 | 147 | 0.974370064785235250f, 0.970295726275996470f, 0.965925826289068310f, |
emilmont | 1:fdd22bb7aa52 | 148 | 0.961261695938318890f, 0.956304755963035440f, 0.951056516295153530f, |
emilmont | 1:fdd22bb7aa52 | 149 | 0.945518575599316850f, 0.939692620785908430f, |
emilmont | 1:fdd22bb7aa52 | 150 | 0.933580426497201740f, 0.927183854566787420f, 0.920504853452440370f, |
emilmont | 1:fdd22bb7aa52 | 151 | 0.913545457642600870f, 0.906307787036649940f, 0.898794046299167040f, |
emilmont | 1:fdd22bb7aa52 | 152 | 0.891006524188367900f, 0.882947592858926990f, |
emilmont | 1:fdd22bb7aa52 | 153 | 0.874619707139395740f, 0.866025403784438710f, 0.857167300702112330f, |
emilmont | 1:fdd22bb7aa52 | 154 | 0.848048096156425960f, 0.838670567945424050f, 0.829037572555041620f, |
emilmont | 1:fdd22bb7aa52 | 155 | 0.819152044288991800f, 0.809016994374947450f, |
emilmont | 1:fdd22bb7aa52 | 156 | 0.798635510047292830f, 0.788010753606722010f, 0.777145961456970900f, |
emilmont | 1:fdd22bb7aa52 | 157 | 0.766044443118978010f, 0.754709580222772010f, 0.743144825477394240f, |
emilmont | 1:fdd22bb7aa52 | 158 | 0.731353701619170570f, 0.719339800338651190f, |
emilmont | 1:fdd22bb7aa52 | 159 | 0.707106781186547570f, 0.694658370458997370f, 0.681998360062498480f, |
emilmont | 1:fdd22bb7aa52 | 160 | 0.669130606358858240f, 0.656059028990507280f, 0.642787609686539360f, |
emilmont | 1:fdd22bb7aa52 | 161 | 0.629320391049837500f, 0.615661475325658290f, |
emilmont | 1:fdd22bb7aa52 | 162 | 0.601815023152048270f, 0.587785252292473140f, 0.573576436351046050f, |
emilmont | 1:fdd22bb7aa52 | 163 | 0.559192903470746790f, 0.544639035015027200f, 0.529919264233204900f, |
emilmont | 1:fdd22bb7aa52 | 164 | 0.515038074910054380f, 0.500000000000000110f, |
emilmont | 1:fdd22bb7aa52 | 165 | 0.484809620246337110f, 0.469471562785890860f, 0.453990499739546860f, |
emilmont | 1:fdd22bb7aa52 | 166 | 0.438371146789077460f, 0.422618261740699440f, 0.406736643075800210f, |
emilmont | 1:fdd22bb7aa52 | 167 | 0.390731128489273940f, 0.374606593415911960f, |
emilmont | 1:fdd22bb7aa52 | 168 | 0.358367949545300380f, 0.342020143325668820f, 0.325568154457156760f, |
emilmont | 1:fdd22bb7aa52 | 169 | 0.309016994374947450f, 0.292371704722736770f, 0.275637355816999160f, |
emilmont | 1:fdd22bb7aa52 | 170 | 0.258819045102520740f, 0.241921895599667900f, |
emilmont | 1:fdd22bb7aa52 | 171 | 0.224951054343864920f, 0.207911690817759450f, 0.190808995376544920f, |
emilmont | 1:fdd22bb7aa52 | 172 | 0.173648177666930410f, 0.156434465040230920f, 0.139173100960065690f, |
emilmont | 1:fdd22bb7aa52 | 173 | 0.121869343405147490f, 0.104528463267653460f, |
emilmont | 1:fdd22bb7aa52 | 174 | 0.087155742747658138f, 0.069756473744125455f, 0.052335956242943966f, |
emilmont | 1:fdd22bb7aa52 | 175 | 0.034899496702501080f, 0.017452406437283376f, 0.000000000000000061f, |
emilmont | 1:fdd22bb7aa52 | 176 | -0.017452406437283477f, -0.034899496702500733f, |
emilmont | 1:fdd22bb7aa52 | 177 | -0.052335956242943620f, -0.069756473744125330f, -0.087155742747658235f, |
emilmont | 1:fdd22bb7aa52 | 178 | -0.104528463267653330f, -0.121869343405147370f, -0.139173100960065350f, |
emilmont | 1:fdd22bb7aa52 | 179 | -0.156434465040231040f, -0.173648177666930300f, |
emilmont | 1:fdd22bb7aa52 | 180 | -0.190808995376544800f, -0.207911690817759120f, -0.224951054343864810f, |
emilmont | 1:fdd22bb7aa52 | 181 | -0.241921895599667790f, -0.258819045102520850f, -0.275637355816999050f, |
emilmont | 1:fdd22bb7aa52 | 182 | -0.292371704722736660f, -0.309016994374947340f, |
emilmont | 1:fdd22bb7aa52 | 183 | -0.325568154457156420f, -0.342020143325668710f, -0.358367949545300270f, |
emilmont | 1:fdd22bb7aa52 | 184 | -0.374606593415912070f, -0.390731128489273600f, -0.406736643075800100f, |
emilmont | 1:fdd22bb7aa52 | 185 | -0.422618261740699330f, -0.438371146789077510f, |
emilmont | 1:fdd22bb7aa52 | 186 | -0.453990499739546750f, -0.469471562785890530f, -0.484809620246337000f, |
emilmont | 1:fdd22bb7aa52 | 187 | -0.499999999999999780f, -0.515038074910054270f, -0.529919264233204790f, |
emilmont | 1:fdd22bb7aa52 | 188 | -0.544639035015027080f, -0.559192903470746680f, |
emilmont | 1:fdd22bb7aa52 | 189 | -0.573576436351045830f, -0.587785252292473030f, -0.601815023152048380f, |
emilmont | 1:fdd22bb7aa52 | 190 | -0.615661475325658290f, -0.629320391049837280f, -0.642787609686539360f, |
emilmont | 1:fdd22bb7aa52 | 191 | -0.656059028990507500f, -0.669130606358858240f, |
emilmont | 1:fdd22bb7aa52 | 192 | -0.681998360062498370f, -0.694658370458997030f, -0.707106781186547460f, |
emilmont | 1:fdd22bb7aa52 | 193 | -0.719339800338651300f, -0.731353701619170460f, -0.743144825477394130f, |
emilmont | 1:fdd22bb7aa52 | 194 | -0.754709580222772010f, -0.766044443118977900f, |
emilmont | 1:fdd22bb7aa52 | 195 | -0.777145961456970680f, -0.788010753606721900f, -0.798635510047292940f, |
emilmont | 1:fdd22bb7aa52 | 196 | -0.809016994374947340f, -0.819152044288991580f, -0.829037572555041620f, |
emilmont | 1:fdd22bb7aa52 | 197 | -0.838670567945424160f, -0.848048096156425960f, |
emilmont | 1:fdd22bb7aa52 | 198 | -0.857167300702112220f, -0.866025403784438710f, -0.874619707139395740f, |
emilmont | 1:fdd22bb7aa52 | 199 | -0.882947592858926770f, -0.891006524188367790f, -0.898794046299167040f, |
emilmont | 1:fdd22bb7aa52 | 200 | -0.906307787036649940f, -0.913545457642600760f, |
emilmont | 1:fdd22bb7aa52 | 201 | -0.920504853452440150f, -0.927183854566787310f, -0.933580426497201740f, |
emilmont | 1:fdd22bb7aa52 | 202 | -0.939692620785908320f, -0.945518575599316740f, -0.951056516295153530f, |
emilmont | 1:fdd22bb7aa52 | 203 | -0.956304755963035440f, -0.961261695938318670f, |
emilmont | 1:fdd22bb7aa52 | 204 | -0.965925826289068200f, -0.970295726275996470f, -0.974370064785235250f, |
emilmont | 1:fdd22bb7aa52 | 205 | -0.978147600733805690f, -0.981627183447663980f, -0.984807753012208020f, |
emilmont | 1:fdd22bb7aa52 | 206 | -0.987688340595137660f, -0.990268068741570250f, |
emilmont | 1:fdd22bb7aa52 | 207 | -0.992546151641321980f, -0.994521895368273290f, -0.996194698091745550f, |
emilmont | 1:fdd22bb7aa52 | 208 | -0.997564050259824200f, -0.998629534754573830f, -0.999390827019095760f, |
emilmont | 1:fdd22bb7aa52 | 209 | -0.999847695156391270f, -1.000000000000000000f |
emilmont | 1:fdd22bb7aa52 | 210 | }; |
emilmont | 1:fdd22bb7aa52 | 211 | |
emilmont | 1:fdd22bb7aa52 | 212 | /** |
emilmont | 1:fdd22bb7aa52 | 213 | * \par |
emilmont | 1:fdd22bb7aa52 | 214 | * Sine Table is generated from following loop |
emilmont | 1:fdd22bb7aa52 | 215 | * <pre>for(i = 0; i < 360; i++) |
emilmont | 1:fdd22bb7aa52 | 216 | * { |
emilmont | 1:fdd22bb7aa52 | 217 | * sinTable[i]= sin((i-180) * PI/180.0); |
emilmont | 1:fdd22bb7aa52 | 218 | * } </pre> |
emilmont | 1:fdd22bb7aa52 | 219 | */ |
emilmont | 1:fdd22bb7aa52 | 220 | |
emilmont | 1:fdd22bb7aa52 | 221 | |
emilmont | 1:fdd22bb7aa52 | 222 | static const float32_t sinTable[360] = { |
emilmont | 1:fdd22bb7aa52 | 223 | -0.017452406437283439f, -0.034899496702500699f, -0.052335956242943807f, |
emilmont | 1:fdd22bb7aa52 | 224 | -0.069756473744125524f, -0.087155742747658638f, -0.104528463267653730f, |
emilmont | 1:fdd22bb7aa52 | 225 | -0.121869343405147550f, -0.139173100960065740f, |
emilmont | 1:fdd22bb7aa52 | 226 | -0.156434465040230980f, -0.173648177666930280f, -0.190808995376544970f, |
emilmont | 1:fdd22bb7aa52 | 227 | -0.207911690817759310f, -0.224951054343864780f, -0.241921895599667730f, |
emilmont | 1:fdd22bb7aa52 | 228 | -0.258819045102521020f, -0.275637355816999660f, |
emilmont | 1:fdd22bb7aa52 | 229 | -0.292371704722737050f, -0.309016994374947510f, -0.325568154457156980f, |
emilmont | 1:fdd22bb7aa52 | 230 | -0.342020143325668880f, -0.358367949545300210f, -0.374606593415912240f, |
emilmont | 1:fdd22bb7aa52 | 231 | -0.390731128489274160f, -0.406736643075800430f, |
emilmont | 1:fdd22bb7aa52 | 232 | -0.422618261740699500f, -0.438371146789077290f, -0.453990499739546860f, |
emilmont | 1:fdd22bb7aa52 | 233 | -0.469471562785891080f, -0.484809620246337170f, -0.499999999999999940f, |
emilmont | 1:fdd22bb7aa52 | 234 | -0.515038074910054380f, -0.529919264233204900f, |
emilmont | 1:fdd22bb7aa52 | 235 | -0.544639035015026860f, -0.559192903470746900f, -0.573576436351046380f, |
emilmont | 1:fdd22bb7aa52 | 236 | -0.587785252292473250f, -0.601815023152048160f, -0.615661475325658400f, |
emilmont | 1:fdd22bb7aa52 | 237 | -0.629320391049837720f, -0.642787609686539470f, |
emilmont | 1:fdd22bb7aa52 | 238 | -0.656059028990507280f, -0.669130606358858350f, -0.681998360062498590f, |
emilmont | 1:fdd22bb7aa52 | 239 | -0.694658370458997140f, -0.707106781186547570f, -0.719339800338651410f, |
emilmont | 1:fdd22bb7aa52 | 240 | -0.731353701619170570f, -0.743144825477394240f, |
emilmont | 1:fdd22bb7aa52 | 241 | -0.754709580222771790f, -0.766044443118978010f, -0.777145961456971010f, |
emilmont | 1:fdd22bb7aa52 | 242 | -0.788010753606722010f, -0.798635510047292720f, -0.809016994374947450f, |
emilmont | 1:fdd22bb7aa52 | 243 | -0.819152044288992020f, -0.829037572555041740f, |
emilmont | 1:fdd22bb7aa52 | 244 | -0.838670567945424050f, -0.848048096156426070f, -0.857167300702112330f, |
emilmont | 1:fdd22bb7aa52 | 245 | -0.866025403784438710f, -0.874619707139395850f, -0.882947592858927100f, |
emilmont | 1:fdd22bb7aa52 | 246 | -0.891006524188367900f, -0.898794046299166930f, |
emilmont | 1:fdd22bb7aa52 | 247 | -0.906307787036650050f, -0.913545457642600980f, -0.920504853452440370f, |
emilmont | 1:fdd22bb7aa52 | 248 | -0.927183854566787420f, -0.933580426497201740f, -0.939692620785908430f, |
emilmont | 1:fdd22bb7aa52 | 249 | -0.945518575599316850f, -0.951056516295153640f, |
emilmont | 1:fdd22bb7aa52 | 250 | -0.956304755963035550f, -0.961261695938318890f, -0.965925826289068310f, |
emilmont | 1:fdd22bb7aa52 | 251 | -0.970295726275996470f, -0.974370064785235250f, -0.978147600733805690f, |
emilmont | 1:fdd22bb7aa52 | 252 | -0.981627183447663980f, -0.984807753012208020f, |
emilmont | 1:fdd22bb7aa52 | 253 | -0.987688340595137660f, -0.990268068741570360f, -0.992546151641322090f, |
emilmont | 1:fdd22bb7aa52 | 254 | -0.994521895368273400f, -0.996194698091745550f, -0.997564050259824200f, |
emilmont | 1:fdd22bb7aa52 | 255 | -0.998629534754573830f, -0.999390827019095760f, |
emilmont | 1:fdd22bb7aa52 | 256 | -0.999847695156391270f, -1.000000000000000000f, -0.999847695156391270f, |
emilmont | 1:fdd22bb7aa52 | 257 | -0.999390827019095760f, -0.998629534754573830f, -0.997564050259824200f, |
emilmont | 1:fdd22bb7aa52 | 258 | -0.996194698091745550f, -0.994521895368273290f, |
emilmont | 1:fdd22bb7aa52 | 259 | -0.992546151641321980f, -0.990268068741570250f, -0.987688340595137770f, |
emilmont | 1:fdd22bb7aa52 | 260 | -0.984807753012208020f, -0.981627183447663980f, -0.978147600733805580f, |
emilmont | 1:fdd22bb7aa52 | 261 | -0.974370064785235250f, -0.970295726275996470f, |
emilmont | 1:fdd22bb7aa52 | 262 | -0.965925826289068310f, -0.961261695938318890f, -0.956304755963035440f, |
emilmont | 1:fdd22bb7aa52 | 263 | -0.951056516295153530f, -0.945518575599316740f, -0.939692620785908320f, |
emilmont | 1:fdd22bb7aa52 | 264 | -0.933580426497201740f, -0.927183854566787420f, |
emilmont | 1:fdd22bb7aa52 | 265 | -0.920504853452440260f, -0.913545457642600870f, -0.906307787036649940f, |
emilmont | 1:fdd22bb7aa52 | 266 | -0.898794046299167040f, -0.891006524188367790f, -0.882947592858926880f, |
emilmont | 1:fdd22bb7aa52 | 267 | -0.874619707139395740f, -0.866025403784438600f, |
emilmont | 1:fdd22bb7aa52 | 268 | -0.857167300702112220f, -0.848048096156426070f, -0.838670567945423940f, |
emilmont | 1:fdd22bb7aa52 | 269 | -0.829037572555041740f, -0.819152044288991800f, -0.809016994374947450f, |
emilmont | 1:fdd22bb7aa52 | 270 | -0.798635510047292830f, -0.788010753606722010f, |
emilmont | 1:fdd22bb7aa52 | 271 | -0.777145961456970790f, -0.766044443118978010f, -0.754709580222772010f, |
emilmont | 1:fdd22bb7aa52 | 272 | -0.743144825477394240f, -0.731353701619170460f, -0.719339800338651080f, |
emilmont | 1:fdd22bb7aa52 | 273 | -0.707106781186547460f, -0.694658370458997250f, |
emilmont | 1:fdd22bb7aa52 | 274 | -0.681998360062498480f, -0.669130606358858240f, -0.656059028990507160f, |
emilmont | 1:fdd22bb7aa52 | 275 | -0.642787609686539250f, -0.629320391049837390f, -0.615661475325658180f, |
emilmont | 1:fdd22bb7aa52 | 276 | -0.601815023152048270f, -0.587785252292473140f, |
emilmont | 1:fdd22bb7aa52 | 277 | -0.573576436351046050f, -0.559192903470746900f, -0.544639035015027080f, |
emilmont | 1:fdd22bb7aa52 | 278 | -0.529919264233204900f, -0.515038074910054160f, -0.499999999999999940f, |
emilmont | 1:fdd22bb7aa52 | 279 | -0.484809620246337060f, -0.469471562785890810f, |
emilmont | 1:fdd22bb7aa52 | 280 | -0.453990499739546750f, -0.438371146789077400f, -0.422618261740699440f, |
emilmont | 1:fdd22bb7aa52 | 281 | -0.406736643075800150f, -0.390731128489273720f, -0.374606593415912010f, |
emilmont | 1:fdd22bb7aa52 | 282 | -0.358367949545300270f, -0.342020143325668710f, |
emilmont | 1:fdd22bb7aa52 | 283 | -0.325568154457156640f, -0.309016994374947400f, -0.292371704722736770f, |
emilmont | 1:fdd22bb7aa52 | 284 | -0.275637355816999160f, -0.258819045102520740f, -0.241921895599667730f, |
emilmont | 1:fdd22bb7aa52 | 285 | -0.224951054343865000f, -0.207911690817759310f, |
emilmont | 1:fdd22bb7aa52 | 286 | -0.190808995376544800f, -0.173648177666930330f, -0.156434465040230870f, |
emilmont | 1:fdd22bb7aa52 | 287 | -0.139173100960065440f, -0.121869343405147480f, -0.104528463267653460f, |
emilmont | 1:fdd22bb7aa52 | 288 | -0.087155742747658166f, -0.069756473744125302f, |
emilmont | 1:fdd22bb7aa52 | 289 | -0.052335956242943828f, -0.034899496702500969f, -0.017452406437283512f, |
emilmont | 1:fdd22bb7aa52 | 290 | 0.000000000000000000f, 0.017452406437283512f, 0.034899496702500969f, |
emilmont | 1:fdd22bb7aa52 | 291 | 0.052335956242943828f, 0.069756473744125302f, |
emilmont | 1:fdd22bb7aa52 | 292 | 0.087155742747658166f, 0.104528463267653460f, 0.121869343405147480f, |
emilmont | 1:fdd22bb7aa52 | 293 | 0.139173100960065440f, 0.156434465040230870f, 0.173648177666930330f, |
emilmont | 1:fdd22bb7aa52 | 294 | 0.190808995376544800f, 0.207911690817759310f, |
emilmont | 1:fdd22bb7aa52 | 295 | 0.224951054343865000f, 0.241921895599667730f, 0.258819045102520740f, |
emilmont | 1:fdd22bb7aa52 | 296 | 0.275637355816999160f, 0.292371704722736770f, 0.309016994374947400f, |
emilmont | 1:fdd22bb7aa52 | 297 | 0.325568154457156640f, 0.342020143325668710f, |
emilmont | 1:fdd22bb7aa52 | 298 | 0.358367949545300270f, 0.374606593415912010f, 0.390731128489273720f, |
emilmont | 1:fdd22bb7aa52 | 299 | 0.406736643075800150f, 0.422618261740699440f, 0.438371146789077400f, |
emilmont | 1:fdd22bb7aa52 | 300 | 0.453990499739546750f, 0.469471562785890810f, |
emilmont | 1:fdd22bb7aa52 | 301 | 0.484809620246337060f, 0.499999999999999940f, 0.515038074910054160f, |
emilmont | 1:fdd22bb7aa52 | 302 | 0.529919264233204900f, 0.544639035015027080f, 0.559192903470746900f, |
emilmont | 1:fdd22bb7aa52 | 303 | 0.573576436351046050f, 0.587785252292473140f, |
emilmont | 1:fdd22bb7aa52 | 304 | 0.601815023152048270f, 0.615661475325658180f, 0.629320391049837390f, |
emilmont | 1:fdd22bb7aa52 | 305 | 0.642787609686539250f, 0.656059028990507160f, 0.669130606358858240f, |
emilmont | 1:fdd22bb7aa52 | 306 | 0.681998360062498480f, 0.694658370458997250f, |
emilmont | 1:fdd22bb7aa52 | 307 | 0.707106781186547460f, 0.719339800338651080f, 0.731353701619170460f, |
emilmont | 1:fdd22bb7aa52 | 308 | 0.743144825477394240f, 0.754709580222772010f, 0.766044443118978010f, |
emilmont | 1:fdd22bb7aa52 | 309 | 0.777145961456970790f, 0.788010753606722010f, |
emilmont | 1:fdd22bb7aa52 | 310 | 0.798635510047292830f, 0.809016994374947450f, 0.819152044288991800f, |
emilmont | 1:fdd22bb7aa52 | 311 | 0.829037572555041740f, 0.838670567945423940f, 0.848048096156426070f, |
emilmont | 1:fdd22bb7aa52 | 312 | 0.857167300702112220f, 0.866025403784438600f, |
emilmont | 1:fdd22bb7aa52 | 313 | 0.874619707139395740f, 0.882947592858926880f, 0.891006524188367790f, |
emilmont | 1:fdd22bb7aa52 | 314 | 0.898794046299167040f, 0.906307787036649940f, 0.913545457642600870f, |
emilmont | 1:fdd22bb7aa52 | 315 | 0.920504853452440260f, 0.927183854566787420f, |
emilmont | 1:fdd22bb7aa52 | 316 | 0.933580426497201740f, 0.939692620785908320f, 0.945518575599316740f, |
emilmont | 1:fdd22bb7aa52 | 317 | 0.951056516295153530f, 0.956304755963035440f, 0.961261695938318890f, |
emilmont | 1:fdd22bb7aa52 | 318 | 0.965925826289068310f, 0.970295726275996470f, |
emilmont | 1:fdd22bb7aa52 | 319 | 0.974370064785235250f, 0.978147600733805580f, 0.981627183447663980f, |
emilmont | 1:fdd22bb7aa52 | 320 | 0.984807753012208020f, 0.987688340595137770f, 0.990268068741570250f, |
emilmont | 1:fdd22bb7aa52 | 321 | 0.992546151641321980f, 0.994521895368273290f, |
emilmont | 1:fdd22bb7aa52 | 322 | 0.996194698091745550f, 0.997564050259824200f, 0.998629534754573830f, |
emilmont | 1:fdd22bb7aa52 | 323 | 0.999390827019095760f, 0.999847695156391270f, 1.000000000000000000f, |
emilmont | 1:fdd22bb7aa52 | 324 | 0.999847695156391270f, 0.999390827019095760f, |
emilmont | 1:fdd22bb7aa52 | 325 | 0.998629534754573830f, 0.997564050259824200f, 0.996194698091745550f, |
emilmont | 1:fdd22bb7aa52 | 326 | 0.994521895368273400f, 0.992546151641322090f, 0.990268068741570360f, |
emilmont | 1:fdd22bb7aa52 | 327 | 0.987688340595137660f, 0.984807753012208020f, |
emilmont | 1:fdd22bb7aa52 | 328 | 0.981627183447663980f, 0.978147600733805690f, 0.974370064785235250f, |
emilmont | 1:fdd22bb7aa52 | 329 | 0.970295726275996470f, 0.965925826289068310f, 0.961261695938318890f, |
emilmont | 1:fdd22bb7aa52 | 330 | 0.956304755963035550f, 0.951056516295153640f, |
emilmont | 1:fdd22bb7aa52 | 331 | 0.945518575599316850f, 0.939692620785908430f, 0.933580426497201740f, |
emilmont | 1:fdd22bb7aa52 | 332 | 0.927183854566787420f, 0.920504853452440370f, 0.913545457642600980f, |
emilmont | 1:fdd22bb7aa52 | 333 | 0.906307787036650050f, 0.898794046299166930f, |
emilmont | 1:fdd22bb7aa52 | 334 | 0.891006524188367900f, 0.882947592858927100f, 0.874619707139395850f, |
emilmont | 1:fdd22bb7aa52 | 335 | 0.866025403784438710f, 0.857167300702112330f, 0.848048096156426070f, |
emilmont | 1:fdd22bb7aa52 | 336 | 0.838670567945424050f, 0.829037572555041740f, |
emilmont | 1:fdd22bb7aa52 | 337 | 0.819152044288992020f, 0.809016994374947450f, 0.798635510047292720f, |
emilmont | 1:fdd22bb7aa52 | 338 | 0.788010753606722010f, 0.777145961456971010f, 0.766044443118978010f, |
emilmont | 1:fdd22bb7aa52 | 339 | 0.754709580222771790f, 0.743144825477394240f, |
emilmont | 1:fdd22bb7aa52 | 340 | 0.731353701619170570f, 0.719339800338651410f, 0.707106781186547570f, |
emilmont | 1:fdd22bb7aa52 | 341 | 0.694658370458997140f, 0.681998360062498590f, 0.669130606358858350f, |
emilmont | 1:fdd22bb7aa52 | 342 | 0.656059028990507280f, 0.642787609686539470f, |
emilmont | 1:fdd22bb7aa52 | 343 | 0.629320391049837720f, 0.615661475325658400f, 0.601815023152048160f, |
emilmont | 1:fdd22bb7aa52 | 344 | 0.587785252292473250f, 0.573576436351046380f, 0.559192903470746900f, |
emilmont | 1:fdd22bb7aa52 | 345 | 0.544639035015026860f, 0.529919264233204900f, |
emilmont | 1:fdd22bb7aa52 | 346 | 0.515038074910054380f, 0.499999999999999940f, 0.484809620246337170f, |
emilmont | 1:fdd22bb7aa52 | 347 | 0.469471562785891080f, 0.453990499739546860f, 0.438371146789077290f, |
emilmont | 1:fdd22bb7aa52 | 348 | 0.422618261740699500f, 0.406736643075800430f, |
emilmont | 1:fdd22bb7aa52 | 349 | 0.390731128489274160f, 0.374606593415912240f, 0.358367949545300210f, |
emilmont | 1:fdd22bb7aa52 | 350 | 0.342020143325668880f, 0.325568154457156980f, 0.309016994374947510f, |
emilmont | 1:fdd22bb7aa52 | 351 | 0.292371704722737050f, 0.275637355816999660f, |
emilmont | 1:fdd22bb7aa52 | 352 | 0.258819045102521020f, 0.241921895599667730f, 0.224951054343864780f, |
emilmont | 1:fdd22bb7aa52 | 353 | 0.207911690817759310f, 0.190808995376544970f, 0.173648177666930280f, |
emilmont | 1:fdd22bb7aa52 | 354 | 0.156434465040230980f, 0.139173100960065740f, |
emilmont | 1:fdd22bb7aa52 | 355 | 0.121869343405147550f, 0.104528463267653730f, 0.087155742747658638f, |
emilmont | 1:fdd22bb7aa52 | 356 | 0.069756473744125524f, 0.052335956242943807f, 0.034899496702500699f, |
emilmont | 1:fdd22bb7aa52 | 357 | 0.017452406437283439f, 0.000000000000000122f |
emilmont | 1:fdd22bb7aa52 | 358 | }; |
emilmont | 1:fdd22bb7aa52 | 359 | |
emilmont | 1:fdd22bb7aa52 | 360 | |
emilmont | 1:fdd22bb7aa52 | 361 | /** |
emilmont | 1:fdd22bb7aa52 | 362 | * @brief Floating-point sin_cos function. |
emilmont | 1:fdd22bb7aa52 | 363 | * @param[in] theta input value in degrees |
emilmont | 1:fdd22bb7aa52 | 364 | * @param[out] *pSinVal points to the processed sine output. |
emilmont | 1:fdd22bb7aa52 | 365 | * @param[out] *pCosVal points to the processed cos output. |
emilmont | 1:fdd22bb7aa52 | 366 | * @return none. |
emilmont | 1:fdd22bb7aa52 | 367 | */ |
emilmont | 1:fdd22bb7aa52 | 368 | |
emilmont | 1:fdd22bb7aa52 | 369 | |
emilmont | 1:fdd22bb7aa52 | 370 | void arm_sin_cos_f32( |
emilmont | 1:fdd22bb7aa52 | 371 | float32_t theta, |
emilmont | 1:fdd22bb7aa52 | 372 | float32_t * pSinVal, |
emilmont | 1:fdd22bb7aa52 | 373 | float32_t * pCosVal) |
emilmont | 1:fdd22bb7aa52 | 374 | { |
emilmont | 1:fdd22bb7aa52 | 375 | int32_t i; /* Index for reading nearwst output values */ |
emilmont | 1:fdd22bb7aa52 | 376 | float32_t x1 = -179.0f; /* Initial input value */ |
emilmont | 1:fdd22bb7aa52 | 377 | float32_t y0, y1; /* nearest output values */ |
emilmont | 1:fdd22bb7aa52 | 378 | float32_t y2, y3; |
emilmont | 1:fdd22bb7aa52 | 379 | float32_t fract; /* fractional part of input */ |
emilmont | 1:fdd22bb7aa52 | 380 | |
emilmont | 1:fdd22bb7aa52 | 381 | /* Calculation of fractional part */ |
emilmont | 1:fdd22bb7aa52 | 382 | if(theta > 0.0f) |
emilmont | 1:fdd22bb7aa52 | 383 | { |
emilmont | 1:fdd22bb7aa52 | 384 | fract = theta - (float32_t) ((int32_t) theta); |
emilmont | 1:fdd22bb7aa52 | 385 | } |
emilmont | 1:fdd22bb7aa52 | 386 | else |
emilmont | 1:fdd22bb7aa52 | 387 | { |
emilmont | 1:fdd22bb7aa52 | 388 | fract = (theta - (float32_t) ((int32_t) theta)) + 1.0f; |
emilmont | 1:fdd22bb7aa52 | 389 | } |
emilmont | 1:fdd22bb7aa52 | 390 | |
emilmont | 1:fdd22bb7aa52 | 391 | /* index calculation for reading nearest output values */ |
emilmont | 1:fdd22bb7aa52 | 392 | i = (uint32_t) (theta - x1); |
emilmont | 1:fdd22bb7aa52 | 393 | |
emilmont | 1:fdd22bb7aa52 | 394 | /* Checking min and max index of table */ |
emilmont | 1:fdd22bb7aa52 | 395 | if(i < 0) |
emilmont | 1:fdd22bb7aa52 | 396 | { |
emilmont | 1:fdd22bb7aa52 | 397 | i = 0; |
emilmont | 1:fdd22bb7aa52 | 398 | } |
emilmont | 1:fdd22bb7aa52 | 399 | else if(i >= 359) |
emilmont | 1:fdd22bb7aa52 | 400 | { |
emilmont | 1:fdd22bb7aa52 | 401 | i = 358; |
emilmont | 1:fdd22bb7aa52 | 402 | } |
emilmont | 1:fdd22bb7aa52 | 403 | |
emilmont | 1:fdd22bb7aa52 | 404 | /* reading nearest sine output values */ |
emilmont | 1:fdd22bb7aa52 | 405 | y0 = sinTable[i]; |
emilmont | 1:fdd22bb7aa52 | 406 | y1 = sinTable[i + 1u]; |
emilmont | 1:fdd22bb7aa52 | 407 | |
emilmont | 1:fdd22bb7aa52 | 408 | /* reading nearest cosine output values */ |
emilmont | 1:fdd22bb7aa52 | 409 | y2 = cosTable[i]; |
emilmont | 1:fdd22bb7aa52 | 410 | y3 = cosTable[i + 1u]; |
emilmont | 1:fdd22bb7aa52 | 411 | |
emilmont | 1:fdd22bb7aa52 | 412 | y1 = y1 - y0; |
emilmont | 1:fdd22bb7aa52 | 413 | y3 = y3 - y2; |
emilmont | 1:fdd22bb7aa52 | 414 | |
emilmont | 1:fdd22bb7aa52 | 415 | y1 = fract * y1; |
emilmont | 1:fdd22bb7aa52 | 416 | y3 = fract * y3; |
emilmont | 1:fdd22bb7aa52 | 417 | |
emilmont | 1:fdd22bb7aa52 | 418 | /* Calculation of sine value */ |
emilmont | 1:fdd22bb7aa52 | 419 | *pSinVal = y0 + y1; |
emilmont | 1:fdd22bb7aa52 | 420 | |
emilmont | 1:fdd22bb7aa52 | 421 | /* Calculation of cosine value */ |
emilmont | 1:fdd22bb7aa52 | 422 | *pCosVal = y2 + y3; |
emilmont | 1:fdd22bb7aa52 | 423 | |
emilmont | 1:fdd22bb7aa52 | 424 | } |
emilmont | 1:fdd22bb7aa52 | 425 | |
emilmont | 1:fdd22bb7aa52 | 426 | /** |
emilmont | 1:fdd22bb7aa52 | 427 | * @} end of SinCos group |
emilmont | 1:fdd22bb7aa52 | 428 | */ |