Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /* ---------------------------------------------------------------------- |
| 2 | * Copyright (C) 2010-2014 ARM Limited. All rights reserved. |
||
| 3 | * |
||
| 4 | * $Date: 19. March 2015 |
||
| 5 | * $Revision: V.1.4.5 |
||
| 6 | * |
||
| 7 | * Project: CMSIS DSP Library |
||
| 8 | * Title: arm_rfft_init_f32.c |
||
| 9 | * |
||
| 10 | * Description: RFFT & RIFFT Floating point initialisation function |
||
| 11 | * |
||
| 12 | * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 |
||
| 13 | * |
||
| 14 | * Redistribution and use in source and binary forms, with or without |
||
| 15 | * modification, are permitted provided that the following conditions |
||
| 16 | * are met: |
||
| 17 | * - Redistributions of source code must retain the above copyright |
||
| 18 | * notice, this list of conditions and the following disclaimer. |
||
| 19 | * - Redistributions in binary form must reproduce the above copyright |
||
| 20 | * notice, this list of conditions and the following disclaimer in |
||
| 21 | * the documentation and/or other materials provided with the |
||
| 22 | * distribution. |
||
| 23 | * - Neither the name of ARM LIMITED nor the names of its contributors |
||
| 24 | * may be used to endorse or promote products derived from this |
||
| 25 | * software without specific prior written permission. |
||
| 26 | * |
||
| 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
| 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
| 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
||
| 30 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
||
| 31 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
| 32 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
||
| 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
| 34 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
| 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
||
| 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
||
| 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
| 38 | * POSSIBILITY OF SUCH DAMAGE. |
||
| 39 | * -------------------------------------------------------------------- */ |
||
| 40 | |||
| 41 | |||
| 42 | #include "arm_math.h" |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @ingroup groupTransforms |
||
| 46 | */ |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @addtogroup RealFFT |
||
| 50 | * @{ |
||
| 51 | */ |
||
| 52 | |||
| 53 | /** |
||
| 54 | * \par |
||
| 55 | * Generation of realCoefA array: |
||
| 56 | * \par |
||
| 57 | * n = 4096 |
||
| 58 | * <pre>for (i = 0; i < n; i++) |
||
| 59 | * { |
||
| 60 | * pATable[2 * i] = 0.5 * (1.0 - sin (2 * PI / (double) (2 * n) * (double) i)); |
||
| 61 | * pATable[2 * i + 1] = 0.5 * (-1.0 * cos (2 * PI / (double) (2 * n) * (double) i)); |
||
| 62 | * } </pre> |
||
| 63 | *//** |
||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | * n = 4096 |
||
| 68 | * <pre>for (i = 0; i < n; i++) |
||
| 69 | * { |
||
| 70 | * pBTable[2 * i] = 0.5 * (1.0 + sin (2 * PI / (double) (2 * n) * (double) i)); |
||
| 71 | * pBTable[2 * i + 1] = 0.5 * (1.0 * cos (2 * PI / (double) (2 * n) * (double) i)); |
||
| 72 | * } </pre> |
||
| 73 | * |
||
| 74 | *//** |
||
| 75 | * @brief Initialization function for the floating-point RFFT/RIFFT. |
||
| 76 | * @deprecated Do not use this function. It has been superceded by \ref arm_rfft_fast_init_f32 and will be removed |
||
| 77 | * in the future. |
||
| 78 | * @param[in,out] *S points to an instance of the floating-point RFFT/RIFFT structure. |
||
| 79 | * @param[in,out] *S_CFFT points to an instance of the floating-point CFFT/CIFFT structure. |
||
| 80 | * @param[in] fftLenReal length of the FFT. |
||
| 81 | * @param[in] ifftFlagR flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. |
||
| 82 | * @param[in] bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. |
||
| 83 | * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported value. |
||
| 84 | * |
||
| 85 | * \par Description: |
||
| 86 | * \par |
||
| 87 | * The parameter <code>fftLenReal</code> Specifies length of RFFT/RIFFT Process. Supported FFT Lengths are 128, 512, 2048. |
||
| 88 | * \par |
||
| 89 | * The parameter <code>ifftFlagR</code> controls whether a forward or inverse transform is computed. |
||
| 90 | * Set(=1) ifftFlagR to calculate RIFFT, otherwise RFFT is calculated. |
||
| 91 | * \par |
||
| 92 | * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order. |
||
| 93 | * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order. |
||
| 94 | * \par |
||
| 95 | * This function also initializes Twiddle factor table. |
||
| 96 | */ |
||
| 97 | |||
| 98 | arm_status arm_rfft_init_f32( |
||
| 99 | arm_rfft_instance_f32 * S, |
||
| 100 | arm_cfft_radix4_instance_f32 * S_CFFT, |
||
| 101 | uint32_t fftLenReal, |
||
| 102 | uint32_t ifftFlagR, |
||
| 103 | uint32_t bitReverseFlag) |
||
| 104 | { |
||
| 105 | |||
| 106 | /* Initialise the default arm status */ |
||
| 107 | arm_status status = ARM_MATH_SUCCESS; |
||
| 108 | |||
| 109 | /* Initialize the Real FFT length */ |
||
| 110 | S->fftLenReal = (uint16_t) fftLenReal; |
||
| 111 | |||
| 112 | /* Initialize the Complex FFT length */ |
||
| 113 | S->fftLenBy2 = (uint16_t) fftLenReal / 2u; |
||
| 114 | |||
| 115 | /* Initialize the Twiddle coefficientA pointer */ |
||
| 116 | S->pTwiddleAReal = (float32_t *) realCoefA; |
||
| 117 | |||
| 118 | /* Initialize the Twiddle coefficientB pointer */ |
||
| 119 | S->pTwiddleBReal = (float32_t *) realCoefB; |
||
| 120 | |||
| 121 | /* Initialize the Flag for selection of RFFT or RIFFT */ |
||
| 122 | S->ifftFlagR = (uint8_t) ifftFlagR; |
||
| 123 | |||
| 124 | /* Initialize the Flag for calculation Bit reversal or not */ |
||
| 125 | S->bitReverseFlagR = (uint8_t) bitReverseFlag; |
||
| 126 | |||
| 127 | /* Initializations of structure parameters depending on the FFT length */ |
||
| 128 | switch (S->fftLenReal) |
||
| 129 | { |
||
| 130 | /* Init table modifier value */ |
||
| 131 | case 8192u: |
||
| 132 | S->twidCoefRModifier = 1u; |
||
| 133 | break; |
||
| 134 | case 2048u: |
||
| 135 | S->twidCoefRModifier = 4u; |
||
| 136 | break; |
||
| 137 | case 512u: |
||
| 138 | S->twidCoefRModifier = 16u; |
||
| 139 | break; |
||
| 140 | case 128u: |
||
| 141 | S->twidCoefRModifier = 64u; |
||
| 142 | break; |
||
| 143 | default: |
||
| 144 | /* Reporting argument error if rfftSize is not valid value */ |
||
| 145 | status = ARM_MATH_ARGUMENT_ERROR; |
||
| 146 | break; |
||
| 147 | } |
||
| 148 | |||
| 149 | /* Init Complex FFT Instance */ |
||
| 150 | S->pCfft = S_CFFT; |
||
| 151 | |||
| 152 | if(S->ifftFlagR) |
||
| 153 | { |
||
| 154 | /* Initializes the CIFFT Module for fftLenreal/2 length */ |
||
| 155 | arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 1u, 0u); |
||
| 156 | } |
||
| 157 | else |
||
| 158 | { |
||
| 159 | /* Initializes the CFFT Module for fftLenreal/2 length */ |
||
| 160 | arm_cfft_radix4_init_f32(S->pCfft, S->fftLenBy2, 0u, 0u); |
||
| 161 | } |
||
| 162 | |||
| 163 | /* return the status of RFFT Init function */ |
||
| 164 | return (status); |
||
| 165 | |||
| 166 | } |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @} end of RealFFT group |
||
| 170 | */ |
||
| 171 | |||
| 172 |