BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:55:34 2018 +0000
Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
bluetooth

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gustavatmel 1:9c5af431a1f1 1 /* ----------------------------------------------------------------------
gustavatmel 1:9c5af431a1f1 2 * Copyright (C) 2010-2014 ARM Limited. All rights reserved.
gustavatmel 1:9c5af431a1f1 3 *
gustavatmel 1:9c5af431a1f1 4 * $Date: 19. March 2015
gustavatmel 1:9c5af431a1f1 5 * $Revision: V.1.4.5
gustavatmel 1:9c5af431a1f1 6 *
gustavatmel 1:9c5af431a1f1 7 * Project: CMSIS DSP Library
gustavatmel 1:9c5af431a1f1 8 * Title: arm_cfft_radix4_init_q31.c
gustavatmel 1:9c5af431a1f1 9 *
gustavatmel 1:9c5af431a1f1 10 * Description: Radix-4 Decimation in Frequency Q31 FFT & IFFT initialization function
gustavatmel 1:9c5af431a1f1 11 *
gustavatmel 1:9c5af431a1f1 12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
gustavatmel 1:9c5af431a1f1 13 *
gustavatmel 1:9c5af431a1f1 14 * Redistribution and use in source and binary forms, with or without
gustavatmel 1:9c5af431a1f1 15 * modification, are permitted provided that the following conditions
gustavatmel 1:9c5af431a1f1 16 * are met:
gustavatmel 1:9c5af431a1f1 17 * - Redistributions of source code must retain the above copyright
gustavatmel 1:9c5af431a1f1 18 * notice, this list of conditions and the following disclaimer.
gustavatmel 1:9c5af431a1f1 19 * - Redistributions in binary form must reproduce the above copyright
gustavatmel 1:9c5af431a1f1 20 * notice, this list of conditions and the following disclaimer in
gustavatmel 1:9c5af431a1f1 21 * the documentation and/or other materials provided with the
gustavatmel 1:9c5af431a1f1 22 * distribution.
gustavatmel 1:9c5af431a1f1 23 * - Neither the name of ARM LIMITED nor the names of its contributors
gustavatmel 1:9c5af431a1f1 24 * may be used to endorse or promote products derived from this
gustavatmel 1:9c5af431a1f1 25 * software without specific prior written permission.
gustavatmel 1:9c5af431a1f1 26 *
gustavatmel 1:9c5af431a1f1 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
gustavatmel 1:9c5af431a1f1 28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
gustavatmel 1:9c5af431a1f1 29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
gustavatmel 1:9c5af431a1f1 30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
gustavatmel 1:9c5af431a1f1 31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
gustavatmel 1:9c5af431a1f1 32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
gustavatmel 1:9c5af431a1f1 33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
gustavatmel 1:9c5af431a1f1 34 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
gustavatmel 1:9c5af431a1f1 35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
gustavatmel 1:9c5af431a1f1 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
gustavatmel 1:9c5af431a1f1 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
gustavatmel 1:9c5af431a1f1 38 * POSSIBILITY OF SUCH DAMAGE.
gustavatmel 1:9c5af431a1f1 39 * -------------------------------------------------------------------- */
gustavatmel 1:9c5af431a1f1 40
gustavatmel 1:9c5af431a1f1 41 #include "arm_math.h"
gustavatmel 1:9c5af431a1f1 42 #include "arm_common_tables.h"
gustavatmel 1:9c5af431a1f1 43
gustavatmel 1:9c5af431a1f1 44 /**
gustavatmel 1:9c5af431a1f1 45 * @ingroup groupTransforms
gustavatmel 1:9c5af431a1f1 46 */
gustavatmel 1:9c5af431a1f1 47
gustavatmel 1:9c5af431a1f1 48 /**
gustavatmel 1:9c5af431a1f1 49 * @addtogroup ComplexFFT
gustavatmel 1:9c5af431a1f1 50 * @{
gustavatmel 1:9c5af431a1f1 51 */
gustavatmel 1:9c5af431a1f1 52
gustavatmel 1:9c5af431a1f1 53 /**
gustavatmel 1:9c5af431a1f1 54 *
gustavatmel 1:9c5af431a1f1 55 * @brief Initialization function for the Q31 CFFT/CIFFT.
gustavatmel 1:9c5af431a1f1 56 * @deprecated Do not use this function. It has been superseded by \ref arm_cfft_q31 and will be removed
gustavatmel 1:9c5af431a1f1 57 * @param[in,out] *S points to an instance of the Q31 CFFT/CIFFT structure.
gustavatmel 1:9c5af431a1f1 58 * @param[in] fftLen length of the FFT.
gustavatmel 1:9c5af431a1f1 59 * @param[in] ifftFlag flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
gustavatmel 1:9c5af431a1f1 60 * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
gustavatmel 1:9c5af431a1f1 61 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLen</code> is not a supported value.
gustavatmel 1:9c5af431a1f1 62 *
gustavatmel 1:9c5af431a1f1 63 * \par Description:
gustavatmel 1:9c5af431a1f1 64 * \par
gustavatmel 1:9c5af431a1f1 65 * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
gustavatmel 1:9c5af431a1f1 66 * Set(=1) ifftFlag for calculation of CIFFT otherwise CFFT is calculated
gustavatmel 1:9c5af431a1f1 67 * \par
gustavatmel 1:9c5af431a1f1 68 * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
gustavatmel 1:9c5af431a1f1 69 * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
gustavatmel 1:9c5af431a1f1 70 * \par
gustavatmel 1:9c5af431a1f1 71 * The parameter <code>fftLen</code> Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
gustavatmel 1:9c5af431a1f1 72 * \par
gustavatmel 1:9c5af431a1f1 73 * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
gustavatmel 1:9c5af431a1f1 74 */
gustavatmel 1:9c5af431a1f1 75
gustavatmel 1:9c5af431a1f1 76 arm_status arm_cfft_radix4_init_q31(
gustavatmel 1:9c5af431a1f1 77 arm_cfft_radix4_instance_q31 * S,
gustavatmel 1:9c5af431a1f1 78 uint16_t fftLen,
gustavatmel 1:9c5af431a1f1 79 uint8_t ifftFlag,
gustavatmel 1:9c5af431a1f1 80 uint8_t bitReverseFlag)
gustavatmel 1:9c5af431a1f1 81 {
gustavatmel 1:9c5af431a1f1 82 /* Initialise the default arm status */
gustavatmel 1:9c5af431a1f1 83 arm_status status = ARM_MATH_SUCCESS;
gustavatmel 1:9c5af431a1f1 84 /* Initialise the FFT length */
gustavatmel 1:9c5af431a1f1 85 S->fftLen = fftLen;
gustavatmel 1:9c5af431a1f1 86 /* Initialise the Twiddle coefficient pointer */
gustavatmel 1:9c5af431a1f1 87 S->pTwiddle = (q31_t *) twiddleCoef_4096_q31;
gustavatmel 1:9c5af431a1f1 88 /* Initialise the Flag for selection of CFFT or CIFFT */
gustavatmel 1:9c5af431a1f1 89 S->ifftFlag = ifftFlag;
gustavatmel 1:9c5af431a1f1 90 /* Initialise the Flag for calculation Bit reversal or not */
gustavatmel 1:9c5af431a1f1 91 S->bitReverseFlag = bitReverseFlag;
gustavatmel 1:9c5af431a1f1 92
gustavatmel 1:9c5af431a1f1 93 /* Initializations of Instance structure depending on the FFT length */
gustavatmel 1:9c5af431a1f1 94 switch (S->fftLen)
gustavatmel 1:9c5af431a1f1 95 {
gustavatmel 1:9c5af431a1f1 96 /* Initializations of structure parameters for 4096 point FFT */
gustavatmel 1:9c5af431a1f1 97 case 4096u:
gustavatmel 1:9c5af431a1f1 98 /* Initialise the twiddle coef modifier value */
gustavatmel 1:9c5af431a1f1 99 S->twidCoefModifier = 1u;
gustavatmel 1:9c5af431a1f1 100 /* Initialise the bit reversal table modifier */
gustavatmel 1:9c5af431a1f1 101 S->bitRevFactor = 1u;
gustavatmel 1:9c5af431a1f1 102 /* Initialise the bit reversal table pointer */
gustavatmel 1:9c5af431a1f1 103 S->pBitRevTable = (uint16_t *) armBitRevTable;
gustavatmel 1:9c5af431a1f1 104 break;
gustavatmel 1:9c5af431a1f1 105
gustavatmel 1:9c5af431a1f1 106 /* Initializations of structure parameters for 1024 point FFT */
gustavatmel 1:9c5af431a1f1 107 case 1024u:
gustavatmel 1:9c5af431a1f1 108 /* Initialise the twiddle coef modifier value */
gustavatmel 1:9c5af431a1f1 109 S->twidCoefModifier = 4u;
gustavatmel 1:9c5af431a1f1 110 /* Initialise the bit reversal table modifier */
gustavatmel 1:9c5af431a1f1 111 S->bitRevFactor = 4u;
gustavatmel 1:9c5af431a1f1 112 /* Initialise the bit reversal table pointer */
gustavatmel 1:9c5af431a1f1 113 S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
gustavatmel 1:9c5af431a1f1 114 break;
gustavatmel 1:9c5af431a1f1 115
gustavatmel 1:9c5af431a1f1 116 case 256u:
gustavatmel 1:9c5af431a1f1 117 /* Initializations of structure parameters for 256 point FFT */
gustavatmel 1:9c5af431a1f1 118 S->twidCoefModifier = 16u;
gustavatmel 1:9c5af431a1f1 119 S->bitRevFactor = 16u;
gustavatmel 1:9c5af431a1f1 120 S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
gustavatmel 1:9c5af431a1f1 121 break;
gustavatmel 1:9c5af431a1f1 122
gustavatmel 1:9c5af431a1f1 123 case 64u:
gustavatmel 1:9c5af431a1f1 124 /* Initializations of structure parameters for 64 point FFT */
gustavatmel 1:9c5af431a1f1 125 S->twidCoefModifier = 64u;
gustavatmel 1:9c5af431a1f1 126 S->bitRevFactor = 64u;
gustavatmel 1:9c5af431a1f1 127 S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
gustavatmel 1:9c5af431a1f1 128 break;
gustavatmel 1:9c5af431a1f1 129
gustavatmel 1:9c5af431a1f1 130 case 16u:
gustavatmel 1:9c5af431a1f1 131 /* Initializations of structure parameters for 16 point FFT */
gustavatmel 1:9c5af431a1f1 132 S->twidCoefModifier = 256u;
gustavatmel 1:9c5af431a1f1 133 S->bitRevFactor = 256u;
gustavatmel 1:9c5af431a1f1 134 S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
gustavatmel 1:9c5af431a1f1 135 break;
gustavatmel 1:9c5af431a1f1 136
gustavatmel 1:9c5af431a1f1 137 default:
gustavatmel 1:9c5af431a1f1 138 /* Reporting argument error if fftSize is not valid value */
gustavatmel 1:9c5af431a1f1 139 status = ARM_MATH_ARGUMENT_ERROR;
gustavatmel 1:9c5af431a1f1 140 break;
gustavatmel 1:9c5af431a1f1 141 }
gustavatmel 1:9c5af431a1f1 142
gustavatmel 1:9c5af431a1f1 143 return (status);
gustavatmel 1:9c5af431a1f1 144 }
gustavatmel 1:9c5af431a1f1 145
gustavatmel 1:9c5af431a1f1 146 /**
gustavatmel 1:9c5af431a1f1 147 * @} end of ComplexFFT group
gustavatmel 1:9c5af431a1f1 148 */