CMSIS DSP Lib

Fork of mbed-dsp by mbed official

Committer:
mbed_official
Date:
Mon Jun 23 09:30:09 2014 +0100
Revision:
4:9cee975aadce
Parent:
3:7a284390b0ce
Synchronized with git revision 6e7c7bcec41226f536474daae3c13d49e4c0e865

Full URL: https://github.com/mbedmicro/mbed/commit/6e7c7bcec41226f536474daae3c13d49e4c0e865/

Fix signed unsigned compare in dsp library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 1:fdd22bb7aa52 1 /* ----------------------------------------------------------------------
mbed_official 3:7a284390b0ce 2 * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
emilmont 1:fdd22bb7aa52 3 *
mbed_official 3:7a284390b0ce 4 * $Date: 17. January 2013
mbed_official 3:7a284390b0ce 5 * $Revision: V1.4.1
emilmont 1:fdd22bb7aa52 6 *
emilmont 2:da51fb522205 7 * Project: CMSIS DSP Library
emilmont 2:da51fb522205 8 * Title: arm_sin_cos_q31.c
emilmont 1:fdd22bb7aa52 9 *
emilmont 2:da51fb522205 10 * Description: Cosine & Sine calculation for Q31 values.
emilmont 1:fdd22bb7aa52 11 *
emilmont 1:fdd22bb7aa52 12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
emilmont 1:fdd22bb7aa52 13 *
mbed_official 3:7a284390b0ce 14 * Redistribution and use in source and binary forms, with or without
mbed_official 3:7a284390b0ce 15 * modification, are permitted provided that the following conditions
mbed_official 3:7a284390b0ce 16 * are met:
mbed_official 3:7a284390b0ce 17 * - Redistributions of source code must retain the above copyright
mbed_official 3:7a284390b0ce 18 * notice, this list of conditions and the following disclaimer.
mbed_official 3:7a284390b0ce 19 * - Redistributions in binary form must reproduce the above copyright
mbed_official 3:7a284390b0ce 20 * notice, this list of conditions and the following disclaimer in
mbed_official 3:7a284390b0ce 21 * the documentation and/or other materials provided with the
mbed_official 3:7a284390b0ce 22 * distribution.
mbed_official 3:7a284390b0ce 23 * - Neither the name of ARM LIMITED nor the names of its contributors
mbed_official 3:7a284390b0ce 24 * may be used to endorse or promote products derived from this
mbed_official 3:7a284390b0ce 25 * software without specific prior written permission.
mbed_official 3:7a284390b0ce 26 *
mbed_official 3:7a284390b0ce 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
mbed_official 3:7a284390b0ce 28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
mbed_official 3:7a284390b0ce 29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
mbed_official 3:7a284390b0ce 30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
mbed_official 3:7a284390b0ce 31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
mbed_official 3:7a284390b0ce 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
mbed_official 3:7a284390b0ce 33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 3:7a284390b0ce 34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 3:7a284390b0ce 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
mbed_official 3:7a284390b0ce 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
mbed_official 3:7a284390b0ce 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
mbed_official 3:7a284390b0ce 38 * POSSIBILITY OF SUCH DAMAGE.
emilmont 1:fdd22bb7aa52 39 * -------------------------------------------------------------------- */
emilmont 1:fdd22bb7aa52 40
emilmont 1:fdd22bb7aa52 41 #include "arm_math.h"
emilmont 1:fdd22bb7aa52 42
emilmont 1:fdd22bb7aa52 43 /**
emilmont 1:fdd22bb7aa52 44 * @ingroup groupController
emilmont 1:fdd22bb7aa52 45 */
emilmont 1:fdd22bb7aa52 46
emilmont 1:fdd22bb7aa52 47 /**
emilmont 1:fdd22bb7aa52 48 * @addtogroup SinCos
emilmont 1:fdd22bb7aa52 49 * @{
emilmont 1:fdd22bb7aa52 50 */
emilmont 1:fdd22bb7aa52 51
emilmont 1:fdd22bb7aa52 52 /**
emilmont 1:fdd22bb7aa52 53 * \par
emilmont 1:fdd22bb7aa52 54 * Sine Table is generated from following loop
emilmont 1:fdd22bb7aa52 55 * <pre>for(i = 0; i < 360; i++)
emilmont 1:fdd22bb7aa52 56 * {
emilmont 1:fdd22bb7aa52 57 * sinTable[i]= sin((i-180) * PI/180.0);
emilmont 1:fdd22bb7aa52 58 * } </pre>
emilmont 1:fdd22bb7aa52 59 * Convert above coefficients to fixed point 1.31 format.
emilmont 1:fdd22bb7aa52 60 */
emilmont 1:fdd22bb7aa52 61
emilmont 1:fdd22bb7aa52 62 static const int32_t sinTableQ31[360] = {
emilmont 1:fdd22bb7aa52 63
emilmont 1:fdd22bb7aa52 64 0x0, 0xfdc41e9b, 0xfb8869ce, 0xf94d0e2e, 0xf7123849, 0xf4d814a4, 0xf29ecfb2,
emilmont 1:fdd22bb7aa52 65 0xf06695da,
emilmont 1:fdd22bb7aa52 66 0xee2f9369, 0xebf9f498, 0xe9c5e582, 0xe7939223, 0xe5632654, 0xe334cdc9,
emilmont 1:fdd22bb7aa52 67 0xe108b40d, 0xdedf047d,
emilmont 1:fdd22bb7aa52 68 0xdcb7ea46, 0xda939061, 0xd8722192, 0xd653c860, 0xd438af17, 0xd220ffc0,
emilmont 1:fdd22bb7aa52 69 0xd00ce422, 0xcdfc85bb,
emilmont 1:fdd22bb7aa52 70 0xcbf00dbe, 0xc9e7a512, 0xc7e3744b, 0xc5e3a3a9, 0xc3e85b18, 0xc1f1c224,
emilmont 1:fdd22bb7aa52 71 0xc0000000, 0xbe133b7c,
emilmont 1:fdd22bb7aa52 72 0xbc2b9b05, 0xba4944a2, 0xb86c5df0, 0xb6950c1e, 0xb4c373ee, 0xb2f7b9af,
emilmont 1:fdd22bb7aa52 73 0xb1320139, 0xaf726def,
emilmont 1:fdd22bb7aa52 74 0xadb922b7, 0xac0641fb, 0xaa59eda4, 0xa8b4471a, 0xa7156f3c, 0xa57d8666,
emilmont 1:fdd22bb7aa52 75 0xa3ecac65, 0xa263007d,
emilmont 1:fdd22bb7aa52 76 0xa0e0a15f, 0x9f65ad2d, 0x9df24175, 0x9c867b2c, 0x9b2276b0, 0x99c64fc5,
emilmont 1:fdd22bb7aa52 77 0x98722192, 0x9726069c,
emilmont 1:fdd22bb7aa52 78 0x95e218c9, 0x94a6715d, 0x937328f5, 0x92485786, 0x9126145f, 0x900c7621,
emilmont 1:fdd22bb7aa52 79 0x8efb92c2, 0x8df37f8b,
emilmont 1:fdd22bb7aa52 80 0x8cf45113, 0x8bfe1b3f, 0x8b10f144, 0x8a2ce59f, 0x89520a1a, 0x88806fc4,
emilmont 1:fdd22bb7aa52 81 0x87b826f7, 0x86f93f50,
emilmont 1:fdd22bb7aa52 82 0x8643c7b3, 0x8597ce46, 0x84f56073, 0x845c8ae3, 0x83cd5982, 0x8347d77b,
emilmont 1:fdd22bb7aa52 83 0x82cc0f36, 0x825a0a5b,
emilmont 1:fdd22bb7aa52 84 0x81f1d1ce, 0x81936daf, 0x813ee55b, 0x80f43f69, 0x80b381ac, 0x807cb130,
emilmont 1:fdd22bb7aa52 85 0x804fd23a, 0x802ce84c,
emilmont 1:fdd22bb7aa52 86 0x8013f61d, 0x8004fda0, 0x80000000, 0x8004fda0, 0x8013f61d, 0x802ce84c,
emilmont 1:fdd22bb7aa52 87 0x804fd23a, 0x807cb130,
emilmont 1:fdd22bb7aa52 88 0x80b381ac, 0x80f43f69, 0x813ee55b, 0x81936daf, 0x81f1d1ce, 0x825a0a5b,
emilmont 1:fdd22bb7aa52 89 0x82cc0f36, 0x8347d77b,
emilmont 1:fdd22bb7aa52 90 0x83cd5982, 0x845c8ae3, 0x84f56073, 0x8597ce46, 0x8643c7b3, 0x86f93f50,
emilmont 1:fdd22bb7aa52 91 0x87b826f7, 0x88806fc4,
emilmont 1:fdd22bb7aa52 92 0x89520a1a, 0x8a2ce59f, 0x8b10f144, 0x8bfe1b3f, 0x8cf45113, 0x8df37f8b,
emilmont 1:fdd22bb7aa52 93 0x8efb92c2, 0x900c7621,
emilmont 1:fdd22bb7aa52 94 0x9126145f, 0x92485786, 0x937328f5, 0x94a6715d, 0x95e218c9, 0x9726069c,
emilmont 1:fdd22bb7aa52 95 0x98722192, 0x99c64fc5,
emilmont 1:fdd22bb7aa52 96 0x9b2276b0, 0x9c867b2c, 0x9df24175, 0x9f65ad2d, 0xa0e0a15f, 0xa263007d,
emilmont 1:fdd22bb7aa52 97 0xa3ecac65, 0xa57d8666,
emilmont 1:fdd22bb7aa52 98 0xa7156f3c, 0xa8b4471a, 0xaa59eda4, 0xac0641fb, 0xadb922b7, 0xaf726def,
emilmont 1:fdd22bb7aa52 99 0xb1320139, 0xb2f7b9af,
emilmont 1:fdd22bb7aa52 100 0xb4c373ee, 0xb6950c1e, 0xb86c5df0, 0xba4944a2, 0xbc2b9b05, 0xbe133b7c,
emilmont 1:fdd22bb7aa52 101 0xc0000000, 0xc1f1c224,
emilmont 1:fdd22bb7aa52 102 0xc3e85b18, 0xc5e3a3a9, 0xc7e3744b, 0xc9e7a512, 0xcbf00dbe, 0xcdfc85bb,
emilmont 1:fdd22bb7aa52 103 0xd00ce422, 0xd220ffc0,
emilmont 1:fdd22bb7aa52 104 0xd438af17, 0xd653c860, 0xd8722192, 0xda939061, 0xdcb7ea46, 0xdedf047d,
emilmont 1:fdd22bb7aa52 105 0xe108b40d, 0xe334cdc9,
emilmont 1:fdd22bb7aa52 106 0xe5632654, 0xe7939223, 0xe9c5e582, 0xebf9f498, 0xee2f9369, 0xf06695da,
emilmont 1:fdd22bb7aa52 107 0xf29ecfb2, 0xf4d814a4,
emilmont 1:fdd22bb7aa52 108 0xf7123849, 0xf94d0e2e, 0xfb8869ce, 0xfdc41e9b, 0x0, 0x23be165, 0x4779632,
emilmont 1:fdd22bb7aa52 109 0x6b2f1d2,
emilmont 1:fdd22bb7aa52 110 0x8edc7b7, 0xb27eb5c, 0xd61304e, 0xf996a26, 0x11d06c97, 0x14060b68,
emilmont 1:fdd22bb7aa52 111 0x163a1a7e, 0x186c6ddd,
emilmont 1:fdd22bb7aa52 112 0x1a9cd9ac, 0x1ccb3237, 0x1ef74bf3, 0x2120fb83, 0x234815ba, 0x256c6f9f,
emilmont 1:fdd22bb7aa52 113 0x278dde6e, 0x29ac37a0,
emilmont 1:fdd22bb7aa52 114 0x2bc750e9, 0x2ddf0040, 0x2ff31bde, 0x32037a45, 0x340ff242, 0x36185aee,
emilmont 1:fdd22bb7aa52 115 0x381c8bb5, 0x3a1c5c57,
emilmont 1:fdd22bb7aa52 116 0x3c17a4e8, 0x3e0e3ddc, 0x40000000, 0x41ecc484, 0x43d464fb, 0x45b6bb5e,
emilmont 1:fdd22bb7aa52 117 0x4793a210, 0x496af3e2,
emilmont 1:fdd22bb7aa52 118 0x4b3c8c12, 0x4d084651, 0x4ecdfec7, 0x508d9211, 0x5246dd49, 0x53f9be05,
emilmont 1:fdd22bb7aa52 119 0x55a6125c, 0x574bb8e6,
emilmont 1:fdd22bb7aa52 120 0x58ea90c4, 0x5a82799a, 0x5c13539b, 0x5d9cff83, 0x5f1f5ea1, 0x609a52d3,
emilmont 1:fdd22bb7aa52 121 0x620dbe8b, 0x637984d4,
emilmont 1:fdd22bb7aa52 122 0x64dd8950, 0x6639b03b, 0x678dde6e, 0x68d9f964, 0x6a1de737, 0x6b598ea3,
emilmont 1:fdd22bb7aa52 123 0x6c8cd70b, 0x6db7a87a,
emilmont 1:fdd22bb7aa52 124 0x6ed9eba1, 0x6ff389df, 0x71046d3e, 0x720c8075, 0x730baeed, 0x7401e4c1,
emilmont 1:fdd22bb7aa52 125 0x74ef0ebc, 0x75d31a61,
emilmont 1:fdd22bb7aa52 126 0x76adf5e6, 0x777f903c, 0x7847d909, 0x7906c0b0, 0x79bc384d, 0x7a6831ba,
emilmont 1:fdd22bb7aa52 127 0x7b0a9f8d, 0x7ba3751d,
emilmont 1:fdd22bb7aa52 128 0x7c32a67e, 0x7cb82885, 0x7d33f0ca, 0x7da5f5a5, 0x7e0e2e32, 0x7e6c9251,
emilmont 1:fdd22bb7aa52 129 0x7ec11aa5, 0x7f0bc097,
emilmont 1:fdd22bb7aa52 130 0x7f4c7e54, 0x7f834ed0, 0x7fb02dc6, 0x7fd317b4, 0x7fec09e3, 0x7ffb0260,
emilmont 1:fdd22bb7aa52 131 0x7fffffff, 0x7ffb0260,
emilmont 1:fdd22bb7aa52 132 0x7fec09e3, 0x7fd317b4, 0x7fb02dc6, 0x7f834ed0, 0x7f4c7e54, 0x7f0bc097,
emilmont 1:fdd22bb7aa52 133 0x7ec11aa5, 0x7e6c9251,
emilmont 1:fdd22bb7aa52 134 0x7e0e2e32, 0x7da5f5a5, 0x7d33f0ca, 0x7cb82885, 0x7c32a67e, 0x7ba3751d,
emilmont 1:fdd22bb7aa52 135 0x7b0a9f8d, 0x7a6831ba,
emilmont 1:fdd22bb7aa52 136 0x79bc384d, 0x7906c0b0, 0x7847d909, 0x777f903c, 0x76adf5e6, 0x75d31a61,
emilmont 1:fdd22bb7aa52 137 0x74ef0ebc, 0x7401e4c1,
emilmont 1:fdd22bb7aa52 138 0x730baeed, 0x720c8075, 0x71046d3e, 0x6ff389df, 0x6ed9eba1, 0x6db7a87a,
emilmont 1:fdd22bb7aa52 139 0x6c8cd70b, 0x6b598ea3,
emilmont 1:fdd22bb7aa52 140 0x6a1de737, 0x68d9f964, 0x678dde6e, 0x6639b03b, 0x64dd8950, 0x637984d4,
emilmont 1:fdd22bb7aa52 141 0x620dbe8b, 0x609a52d3,
emilmont 1:fdd22bb7aa52 142 0x5f1f5ea1, 0x5d9cff83, 0x5c13539b, 0x5a82799a, 0x58ea90c4, 0x574bb8e6,
emilmont 1:fdd22bb7aa52 143 0x55a6125c, 0x53f9be05,
emilmont 1:fdd22bb7aa52 144 0x5246dd49, 0x508d9211, 0x4ecdfec7, 0x4d084651, 0x4b3c8c12, 0x496af3e2,
emilmont 1:fdd22bb7aa52 145 0x4793a210, 0x45b6bb5e,
emilmont 1:fdd22bb7aa52 146 0x43d464fb, 0x41ecc484, 0x40000000, 0x3e0e3ddc, 0x3c17a4e8, 0x3a1c5c57,
emilmont 1:fdd22bb7aa52 147 0x381c8bb5, 0x36185aee,
emilmont 1:fdd22bb7aa52 148 0x340ff242, 0x32037a45, 0x2ff31bde, 0x2ddf0040, 0x2bc750e9, 0x29ac37a0,
emilmont 1:fdd22bb7aa52 149 0x278dde6e, 0x256c6f9f,
emilmont 1:fdd22bb7aa52 150 0x234815ba, 0x2120fb83, 0x1ef74bf3, 0x1ccb3237, 0x1a9cd9ac, 0x186c6ddd,
emilmont 1:fdd22bb7aa52 151 0x163a1a7e, 0x14060b68,
emilmont 1:fdd22bb7aa52 152 0x11d06c97, 0xf996a26, 0xd61304e, 0xb27eb5c, 0x8edc7b7, 0x6b2f1d2,
emilmont 1:fdd22bb7aa52 153 0x4779632, 0x23be165,
emilmont 1:fdd22bb7aa52 154
emilmont 1:fdd22bb7aa52 155
emilmont 1:fdd22bb7aa52 156 };
emilmont 1:fdd22bb7aa52 157
emilmont 1:fdd22bb7aa52 158 /**
emilmont 1:fdd22bb7aa52 159 * \par
emilmont 1:fdd22bb7aa52 160 * Cosine Table is generated from following loop
emilmont 1:fdd22bb7aa52 161 * <pre>for(i = 0; i < 360; i++)
emilmont 1:fdd22bb7aa52 162 * {
emilmont 1:fdd22bb7aa52 163 * cosTable[i]= cos((i-180) * PI/180.0);
emilmont 1:fdd22bb7aa52 164 * } </pre>
emilmont 1:fdd22bb7aa52 165 * \par
emilmont 1:fdd22bb7aa52 166 * Convert above coefficients to fixed point 1.31 format.
emilmont 1:fdd22bb7aa52 167 */
emilmont 1:fdd22bb7aa52 168 static const int32_t cosTableQ31[360] = {
emilmont 1:fdd22bb7aa52 169 0x80000000, 0x8004fda0, 0x8013f61d, 0x802ce84c, 0x804fd23a, 0x807cb130,
emilmont 1:fdd22bb7aa52 170 0x80b381ac, 0x80f43f69,
emilmont 1:fdd22bb7aa52 171 0x813ee55b, 0x81936daf, 0x81f1d1ce, 0x825a0a5b, 0x82cc0f36, 0x8347d77b,
emilmont 1:fdd22bb7aa52 172 0x83cd5982, 0x845c8ae3,
emilmont 1:fdd22bb7aa52 173 0x84f56073, 0x8597ce46, 0x8643c7b3, 0x86f93f50, 0x87b826f7, 0x88806fc4,
emilmont 1:fdd22bb7aa52 174 0x89520a1a, 0x8a2ce59f,
emilmont 1:fdd22bb7aa52 175 0x8b10f144, 0x8bfe1b3f, 0x8cf45113, 0x8df37f8b, 0x8efb92c2, 0x900c7621,
emilmont 1:fdd22bb7aa52 176 0x9126145f, 0x92485786,
emilmont 1:fdd22bb7aa52 177 0x937328f5, 0x94a6715d, 0x95e218c9, 0x9726069c, 0x98722192, 0x99c64fc5,
emilmont 1:fdd22bb7aa52 178 0x9b2276b0, 0x9c867b2c,
emilmont 1:fdd22bb7aa52 179 0x9df24175, 0x9f65ad2d, 0xa0e0a15f, 0xa263007d, 0xa3ecac65, 0xa57d8666,
emilmont 1:fdd22bb7aa52 180 0xa7156f3c, 0xa8b4471a,
emilmont 1:fdd22bb7aa52 181 0xaa59eda4, 0xac0641fb, 0xadb922b7, 0xaf726def, 0xb1320139, 0xb2f7b9af,
emilmont 1:fdd22bb7aa52 182 0xb4c373ee, 0xb6950c1e,
emilmont 1:fdd22bb7aa52 183 0xb86c5df0, 0xba4944a2, 0xbc2b9b05, 0xbe133b7c, 0xc0000000, 0xc1f1c224,
emilmont 1:fdd22bb7aa52 184 0xc3e85b18, 0xc5e3a3a9,
emilmont 1:fdd22bb7aa52 185 0xc7e3744b, 0xc9e7a512, 0xcbf00dbe, 0xcdfc85bb, 0xd00ce422, 0xd220ffc0,
emilmont 1:fdd22bb7aa52 186 0xd438af17, 0xd653c860,
emilmont 1:fdd22bb7aa52 187 0xd8722192, 0xda939061, 0xdcb7ea46, 0xdedf047d, 0xe108b40d, 0xe334cdc9,
emilmont 1:fdd22bb7aa52 188 0xe5632654, 0xe7939223,
emilmont 1:fdd22bb7aa52 189 0xe9c5e582, 0xebf9f498, 0xee2f9369, 0xf06695da, 0xf29ecfb2, 0xf4d814a4,
emilmont 1:fdd22bb7aa52 190 0xf7123849, 0xf94d0e2e,
emilmont 1:fdd22bb7aa52 191 0xfb8869ce, 0xfdc41e9b, 0x0, 0x23be165, 0x4779632, 0x6b2f1d2, 0x8edc7b7,
emilmont 1:fdd22bb7aa52 192 0xb27eb5c,
emilmont 1:fdd22bb7aa52 193 0xd61304e, 0xf996a26, 0x11d06c97, 0x14060b68, 0x163a1a7e, 0x186c6ddd,
emilmont 1:fdd22bb7aa52 194 0x1a9cd9ac, 0x1ccb3237,
emilmont 1:fdd22bb7aa52 195 0x1ef74bf3, 0x2120fb83, 0x234815ba, 0x256c6f9f, 0x278dde6e, 0x29ac37a0,
emilmont 1:fdd22bb7aa52 196 0x2bc750e9, 0x2ddf0040,
emilmont 1:fdd22bb7aa52 197 0x2ff31bde, 0x32037a45, 0x340ff242, 0x36185aee, 0x381c8bb5, 0x3a1c5c57,
emilmont 1:fdd22bb7aa52 198 0x3c17a4e8, 0x3e0e3ddc,
emilmont 1:fdd22bb7aa52 199 0x40000000, 0x41ecc484, 0x43d464fb, 0x45b6bb5e, 0x4793a210, 0x496af3e2,
emilmont 1:fdd22bb7aa52 200 0x4b3c8c12, 0x4d084651,
emilmont 1:fdd22bb7aa52 201 0x4ecdfec7, 0x508d9211, 0x5246dd49, 0x53f9be05, 0x55a6125c, 0x574bb8e6,
emilmont 1:fdd22bb7aa52 202 0x58ea90c4, 0x5a82799a,
emilmont 1:fdd22bb7aa52 203 0x5c13539b, 0x5d9cff83, 0x5f1f5ea1, 0x609a52d3, 0x620dbe8b, 0x637984d4,
emilmont 1:fdd22bb7aa52 204 0x64dd8950, 0x6639b03b,
emilmont 1:fdd22bb7aa52 205 0x678dde6e, 0x68d9f964, 0x6a1de737, 0x6b598ea3, 0x6c8cd70b, 0x6db7a87a,
emilmont 1:fdd22bb7aa52 206 0x6ed9eba1, 0x6ff389df,
emilmont 1:fdd22bb7aa52 207 0x71046d3e, 0x720c8075, 0x730baeed, 0x7401e4c1, 0x74ef0ebc, 0x75d31a61,
emilmont 1:fdd22bb7aa52 208 0x76adf5e6, 0x777f903c,
emilmont 1:fdd22bb7aa52 209 0x7847d909, 0x7906c0b0, 0x79bc384d, 0x7a6831ba, 0x7b0a9f8d, 0x7ba3751d,
emilmont 1:fdd22bb7aa52 210 0x7c32a67e, 0x7cb82885,
emilmont 1:fdd22bb7aa52 211 0x7d33f0ca, 0x7da5f5a5, 0x7e0e2e32, 0x7e6c9251, 0x7ec11aa5, 0x7f0bc097,
emilmont 1:fdd22bb7aa52 212 0x7f4c7e54, 0x7f834ed0,
emilmont 1:fdd22bb7aa52 213 0x7fb02dc6, 0x7fd317b4, 0x7fec09e3, 0x7ffb0260, 0x7fffffff, 0x7ffb0260,
emilmont 1:fdd22bb7aa52 214 0x7fec09e3, 0x7fd317b4,
emilmont 1:fdd22bb7aa52 215 0x7fb02dc6, 0x7f834ed0, 0x7f4c7e54, 0x7f0bc097, 0x7ec11aa5, 0x7e6c9251,
emilmont 1:fdd22bb7aa52 216 0x7e0e2e32, 0x7da5f5a5,
emilmont 1:fdd22bb7aa52 217 0x7d33f0ca, 0x7cb82885, 0x7c32a67e, 0x7ba3751d, 0x7b0a9f8d, 0x7a6831ba,
emilmont 1:fdd22bb7aa52 218 0x79bc384d, 0x7906c0b0,
emilmont 1:fdd22bb7aa52 219 0x7847d909, 0x777f903c, 0x76adf5e6, 0x75d31a61, 0x74ef0ebc, 0x7401e4c1,
emilmont 1:fdd22bb7aa52 220 0x730baeed, 0x720c8075,
emilmont 1:fdd22bb7aa52 221 0x71046d3e, 0x6ff389df, 0x6ed9eba1, 0x6db7a87a, 0x6c8cd70b, 0x6b598ea3,
emilmont 1:fdd22bb7aa52 222 0x6a1de737, 0x68d9f964,
emilmont 1:fdd22bb7aa52 223 0x678dde6e, 0x6639b03b, 0x64dd8950, 0x637984d4, 0x620dbe8b, 0x609a52d3,
emilmont 1:fdd22bb7aa52 224 0x5f1f5ea1, 0x5d9cff83,
emilmont 1:fdd22bb7aa52 225 0x5c13539b, 0x5a82799a, 0x58ea90c4, 0x574bb8e6, 0x55a6125c, 0x53f9be05,
emilmont 1:fdd22bb7aa52 226 0x5246dd49, 0x508d9211,
emilmont 1:fdd22bb7aa52 227 0x4ecdfec7, 0x4d084651, 0x4b3c8c12, 0x496af3e2, 0x4793a210, 0x45b6bb5e,
emilmont 1:fdd22bb7aa52 228 0x43d464fb, 0x41ecc484,
emilmont 1:fdd22bb7aa52 229 0x40000000, 0x3e0e3ddc, 0x3c17a4e8, 0x3a1c5c57, 0x381c8bb5, 0x36185aee,
emilmont 1:fdd22bb7aa52 230 0x340ff242, 0x32037a45,
emilmont 1:fdd22bb7aa52 231 0x2ff31bde, 0x2ddf0040, 0x2bc750e9, 0x29ac37a0, 0x278dde6e, 0x256c6f9f,
emilmont 1:fdd22bb7aa52 232 0x234815ba, 0x2120fb83,
emilmont 1:fdd22bb7aa52 233 0x1ef74bf3, 0x1ccb3237, 0x1a9cd9ac, 0x186c6ddd, 0x163a1a7e, 0x14060b68,
emilmont 1:fdd22bb7aa52 234 0x11d06c97, 0xf996a26,
emilmont 1:fdd22bb7aa52 235 0xd61304e, 0xb27eb5c, 0x8edc7b7, 0x6b2f1d2, 0x4779632, 0x23be165, 0x0,
emilmont 1:fdd22bb7aa52 236 0xfdc41e9b,
emilmont 1:fdd22bb7aa52 237 0xfb8869ce, 0xf94d0e2e, 0xf7123849, 0xf4d814a4, 0xf29ecfb2, 0xf06695da,
emilmont 1:fdd22bb7aa52 238 0xee2f9369, 0xebf9f498,
emilmont 1:fdd22bb7aa52 239 0xe9c5e582, 0xe7939223, 0xe5632654, 0xe334cdc9, 0xe108b40d, 0xdedf047d,
emilmont 1:fdd22bb7aa52 240 0xdcb7ea46, 0xda939061,
emilmont 1:fdd22bb7aa52 241 0xd8722192, 0xd653c860, 0xd438af17, 0xd220ffc0, 0xd00ce422, 0xcdfc85bb,
emilmont 1:fdd22bb7aa52 242 0xcbf00dbe, 0xc9e7a512,
emilmont 1:fdd22bb7aa52 243 0xc7e3744b, 0xc5e3a3a9, 0xc3e85b18, 0xc1f1c224, 0xc0000000, 0xbe133b7c,
emilmont 1:fdd22bb7aa52 244 0xbc2b9b05, 0xba4944a2,
emilmont 1:fdd22bb7aa52 245 0xb86c5df0, 0xb6950c1e, 0xb4c373ee, 0xb2f7b9af, 0xb1320139, 0xaf726def,
emilmont 1:fdd22bb7aa52 246 0xadb922b7, 0xac0641fb,
emilmont 1:fdd22bb7aa52 247 0xaa59eda4, 0xa8b4471a, 0xa7156f3c, 0xa57d8666, 0xa3ecac65, 0xa263007d,
emilmont 1:fdd22bb7aa52 248 0xa0e0a15f, 0x9f65ad2d,
emilmont 1:fdd22bb7aa52 249 0x9df24175, 0x9c867b2c, 0x9b2276b0, 0x99c64fc5, 0x98722192, 0x9726069c,
emilmont 1:fdd22bb7aa52 250 0x95e218c9, 0x94a6715d,
emilmont 1:fdd22bb7aa52 251 0x937328f5, 0x92485786, 0x9126145f, 0x900c7621, 0x8efb92c2, 0x8df37f8b,
emilmont 1:fdd22bb7aa52 252 0x8cf45113, 0x8bfe1b3f,
emilmont 1:fdd22bb7aa52 253 0x8b10f144, 0x8a2ce59f, 0x89520a1a, 0x88806fc4, 0x87b826f7, 0x86f93f50,
emilmont 1:fdd22bb7aa52 254 0x8643c7b3, 0x8597ce46,
emilmont 1:fdd22bb7aa52 255 0x84f56073, 0x845c8ae3, 0x83cd5982, 0x8347d77b, 0x82cc0f36, 0x825a0a5b,
emilmont 1:fdd22bb7aa52 256 0x81f1d1ce, 0x81936daf,
emilmont 1:fdd22bb7aa52 257 0x813ee55b, 0x80f43f69, 0x80b381ac, 0x807cb130, 0x804fd23a, 0x802ce84c,
emilmont 1:fdd22bb7aa52 258 0x8013f61d, 0x8004fda0,
emilmont 1:fdd22bb7aa52 259
emilmont 1:fdd22bb7aa52 260 };
emilmont 1:fdd22bb7aa52 261
emilmont 1:fdd22bb7aa52 262
emilmont 1:fdd22bb7aa52 263 /**
emilmont 1:fdd22bb7aa52 264 * @brief Q31 sin_cos function.
emilmont 1:fdd22bb7aa52 265 * @param[in] theta scaled input value in degrees
emilmont 1:fdd22bb7aa52 266 * @param[out] *pSinVal points to the processed sine output.
emilmont 1:fdd22bb7aa52 267 * @param[out] *pCosVal points to the processed cosine output.
emilmont 1:fdd22bb7aa52 268 * @return none.
emilmont 1:fdd22bb7aa52 269 *
emilmont 1:fdd22bb7aa52 270 * The Q31 input value is in the range [-1 0.999999] and is mapped to a degree value in the range [-180 179].
emilmont 1:fdd22bb7aa52 271 *
emilmont 1:fdd22bb7aa52 272 */
emilmont 1:fdd22bb7aa52 273
emilmont 1:fdd22bb7aa52 274
emilmont 1:fdd22bb7aa52 275 void arm_sin_cos_q31(
emilmont 1:fdd22bb7aa52 276 q31_t theta,
emilmont 1:fdd22bb7aa52 277 q31_t * pSinVal,
emilmont 1:fdd22bb7aa52 278 q31_t * pCosVal)
emilmont 1:fdd22bb7aa52 279 {
emilmont 1:fdd22bb7aa52 280 q31_t x0; /* Nearest input value */
emilmont 1:fdd22bb7aa52 281 q31_t y0, y1; /* Nearest output values */
emilmont 1:fdd22bb7aa52 282 q31_t xSpacing = INPUT_SPACING; /* Spaing between inputs */
mbed_official 3:7a284390b0ce 283 uint32_t i; /* Index */
emilmont 1:fdd22bb7aa52 284 q31_t oneByXSpacing; /* 1/ xSpacing value */
emilmont 1:fdd22bb7aa52 285 q31_t out; /* temporary variable */
emilmont 1:fdd22bb7aa52 286 uint32_t sign_bits; /* No.of sign bits */
emilmont 1:fdd22bb7aa52 287 uint32_t firstX = 0x80000000; /* First X value */
emilmont 1:fdd22bb7aa52 288
emilmont 1:fdd22bb7aa52 289 /* Calculation of index */
emilmont 1:fdd22bb7aa52 290 i = ((uint32_t) theta - firstX) / (uint32_t) xSpacing;
emilmont 1:fdd22bb7aa52 291
emilmont 1:fdd22bb7aa52 292 /* Checking min and max index of table */
mbed_official 3:7a284390b0ce 293 if(i >= 359)
emilmont 1:fdd22bb7aa52 294 {
emilmont 1:fdd22bb7aa52 295 i = 358;
emilmont 1:fdd22bb7aa52 296 }
emilmont 1:fdd22bb7aa52 297
emilmont 1:fdd22bb7aa52 298 /* Calculation of first nearest input value */
emilmont 1:fdd22bb7aa52 299 x0 = (q31_t) firstX + ((q31_t) i * xSpacing);
emilmont 1:fdd22bb7aa52 300
emilmont 1:fdd22bb7aa52 301 /* Reading nearest sine output values from table */
emilmont 1:fdd22bb7aa52 302 y0 = sinTableQ31[i];
emilmont 1:fdd22bb7aa52 303 y1 = sinTableQ31[i + 1u];
emilmont 1:fdd22bb7aa52 304
emilmont 1:fdd22bb7aa52 305 /* Calculation of 1/(x1-x0) */
emilmont 1:fdd22bb7aa52 306 /* (x1-x0) is xSpacing which is fixed value */
emilmont 1:fdd22bb7aa52 307 sign_bits = 8u;
emilmont 1:fdd22bb7aa52 308 oneByXSpacing = 0x5A000000;
emilmont 1:fdd22bb7aa52 309
emilmont 1:fdd22bb7aa52 310 /* Calculation of (theta - x0)/(x1-x0) */
emilmont 1:fdd22bb7aa52 311 out =
emilmont 1:fdd22bb7aa52 312 (((q31_t) (((q63_t) (theta - x0) * oneByXSpacing) >> 32)) << sign_bits);
emilmont 1:fdd22bb7aa52 313
emilmont 1:fdd22bb7aa52 314 /* Calculation of y0 + (y1 - y0) * ((theta - x0)/(x1-x0)) */
emilmont 1:fdd22bb7aa52 315 *pSinVal = __QADD(y0, ((q31_t) (((q63_t) (y1 - y0) * out) >> 30)));
emilmont 1:fdd22bb7aa52 316
emilmont 1:fdd22bb7aa52 317 /* Reading nearest cosine output values from table */
emilmont 1:fdd22bb7aa52 318 y0 = cosTableQ31[i];
emilmont 1:fdd22bb7aa52 319 y1 = cosTableQ31[i + 1u];
emilmont 1:fdd22bb7aa52 320
emilmont 1:fdd22bb7aa52 321 /* Calculation of y0 + (y1 - y0) * ((theta - x0)/(x1-x0)) */
emilmont 1:fdd22bb7aa52 322 *pCosVal = __QADD(y0, ((q31_t) (((q63_t) (y1 - y0) * out) >> 30)));
emilmont 1:fdd22bb7aa52 323
emilmont 1:fdd22bb7aa52 324 }
emilmont 1:fdd22bb7aa52 325
emilmont 1:fdd22bb7aa52 326 /**
emilmont 1:fdd22bb7aa52 327 * @} end of SinCos group
emilmont 1:fdd22bb7aa52 328 */