Subversion Repositories dashGPS

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /* ----------------------------------------------------------------------
  2.  * Project:      CMSIS DSP Library
  3.  * Title:        arm_cfft_radix2_init_q31.c
  4.  * Description:  Radix-2 Decimation in Frequency Fixed-point CFFT & CIFFT Initialization function
  5.  *
  6.  * $Date:        27. January 2017
  7.  * $Revision:    V.1.5.1
  8.  *
  9.  * Target Processor: Cortex-M cores
  10.  * -------------------------------------------------------------------- */
  11. /*
  12.  * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
  13.  *
  14.  * SPDX-License-Identifier: Apache-2.0
  15.  *
  16.  * Licensed under the Apache License, Version 2.0 (the License); you may
  17.  * not use this file except in compliance with the License.
  18.  * You may obtain a copy of the License at
  19.  *
  20.  * www.apache.org/licenses/LICENSE-2.0
  21.  *
  22.  * Unless required by applicable law or agreed to in writing, software
  23.  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24.  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25.  * See the License for the specific language governing permissions and
  26.  * limitations under the License.
  27.  */
  28.  
  29. #include "arm_math.h"
  30. #include "arm_common_tables.h"
  31.  
  32. /**
  33.  * @ingroup groupTransforms
  34.  */
  35.  
  36. /**
  37.  * @addtogroup ComplexFFT
  38.  * @{
  39.  */
  40.  
  41.  
  42. /**
  43. *
  44. * @brief  Initialization function for the Q31 CFFT/CIFFT.
  45. * @deprecated Do not use this function.  It has been superseded by \ref arm_cfft_q31 and will be removed
  46. * @param[in,out] *S             points to an instance of the Q31 CFFT/CIFFT structure.
  47. * @param[in]     fftLen         length of the FFT.
  48. * @param[in]     ifftFlag       flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
  49. * @param[in]     bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
  50. * @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.
  51. *
  52. * \par Description:
  53. * \par
  54. * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
  55. * Set(=1) ifftFlag for calculation of CIFFT otherwise  CFFT is calculated
  56. * \par
  57. * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
  58. * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
  59. * \par
  60. * The parameter <code>fftLen</code>     Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
  61. * \par
  62. * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  63. */
  64.  
  65. arm_status arm_cfft_radix2_init_q31(
  66.   arm_cfft_radix2_instance_q31 * S,
  67.   uint16_t fftLen,
  68.   uint8_t ifftFlag,
  69.   uint8_t bitReverseFlag)
  70. {
  71.   /*  Initialise the default arm status */
  72.   arm_status status = ARM_MATH_SUCCESS;
  73.  
  74.   /*  Initialise the FFT length */
  75.   S->fftLen = fftLen;
  76.  
  77.   /*  Initialise the Twiddle coefficient pointer */
  78.   S->pTwiddle = (q31_t *) twiddleCoef_4096_q31;
  79.   /*  Initialise the Flag for selection of CFFT or CIFFT */
  80.   S->ifftFlag = ifftFlag;
  81.   /*  Initialise the Flag for calculation Bit reversal or not */
  82.   S->bitReverseFlag = bitReverseFlag;
  83.  
  84.   /*  Initializations of Instance structure depending on the FFT length */
  85.   switch (S->fftLen)
  86.   {
  87.     /*  Initializations of structure parameters for 4096 point FFT */
  88.   case 4096U:
  89.     /*  Initialise the twiddle coef modifier value */
  90.     S->twidCoefModifier = 1U;
  91.     /*  Initialise the bit reversal table modifier */
  92.     S->bitRevFactor = 1U;
  93.     /*  Initialise the bit reversal table pointer */
  94.     S->pBitRevTable = (uint16_t *) armBitRevTable;
  95.     break;
  96.  
  97.     /*  Initializations of structure parameters for 2048 point FFT */
  98.   case 2048U:
  99.     /*  Initialise the twiddle coef modifier value */
  100.     S->twidCoefModifier = 2U;
  101.     /*  Initialise the bit reversal table modifier */
  102.     S->bitRevFactor = 2U;
  103.     /*  Initialise the bit reversal table pointer */
  104.     S->pBitRevTable = (uint16_t *) & armBitRevTable[1];
  105.     break;
  106.  
  107.     /*  Initializations of structure parameters for 1024 point FFT */
  108.   case 1024U:
  109.     /*  Initialise the twiddle coef modifier value */
  110.     S->twidCoefModifier = 4U;
  111.     /*  Initialise the bit reversal table modifier */
  112.     S->bitRevFactor = 4U;
  113.     /*  Initialise the bit reversal table pointer */
  114.     S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
  115.     break;
  116.  
  117.     /*  Initializations of structure parameters for 512 point FFT */
  118.   case 512U:
  119.     /*  Initialise the twiddle coef modifier value */
  120.     S->twidCoefModifier = 8U;
  121.     /*  Initialise the bit reversal table modifier */
  122.     S->bitRevFactor = 8U;
  123.     /*  Initialise the bit reversal table pointer */
  124.     S->pBitRevTable = (uint16_t *) & armBitRevTable[7];
  125.     break;
  126.  
  127.   case 256U:
  128.     /*  Initializations of structure parameters for 256 point FFT */
  129.     S->twidCoefModifier = 16U;
  130.     S->bitRevFactor = 16U;
  131.     S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
  132.     break;
  133.  
  134.   case 128U:
  135.     /*  Initializations of structure parameters for 128 point FFT */
  136.     S->twidCoefModifier = 32U;
  137.     S->bitRevFactor = 32U;
  138.     S->pBitRevTable = (uint16_t *) & armBitRevTable[31];
  139.     break;
  140.  
  141.   case 64U:
  142.     /*  Initializations of structure parameters for 64 point FFT */
  143.     S->twidCoefModifier = 64U;
  144.     S->bitRevFactor = 64U;
  145.     S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
  146.     break;
  147.  
  148.   case 32U:
  149.     /*  Initializations of structure parameters for 32 point FFT */
  150.     S->twidCoefModifier = 128U;
  151.     S->bitRevFactor = 128U;
  152.     S->pBitRevTable = (uint16_t *) & armBitRevTable[127];
  153.     break;
  154.  
  155.   case 16U:
  156.     /*  Initializations of structure parameters for 16 point FFT */
  157.     S->twidCoefModifier = 256U;
  158.     S->bitRevFactor = 256U;
  159.     S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
  160.     break;
  161.  
  162.  
  163.   default:
  164.     /*  Reporting argument error if fftSize is not valid value */
  165.     status = ARM_MATH_ARGUMENT_ERROR;
  166.     break;
  167.   }
  168.  
  169.   return (status);
  170. }
  171.  
  172. /**
  173.  * @} end of ComplexFFT group
  174.  */
  175.