Subversion Repositories AFRtranscoder

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* ----------------------------------------------------------------------
  2.  * Project:      CMSIS DSP Library
  3.  * Title:        arm_cfft_radix4_init_q31.c
  4.  * Description:  Radix-4 Decimation in Frequency Q31 FFT & IFFT 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. * @brief  Initialization function for the Q31 CFFT/CIFFT.
  44. * @deprecated Do not use this function.  It has been superseded by \ref arm_cfft_q31 and will be removed
  45. * @param[in,out] *S             points to an instance of the Q31 CFFT/CIFFT structure.
  46. * @param[in]     fftLen         length of the FFT.
  47. * @param[in]     ifftFlag       flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform.
  48. * @param[in]     bitReverseFlag flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output.
  49. * @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.
  50. *
  51. * \par Description:
  52. * \par
  53. * The parameter <code>ifftFlag</code> controls whether a forward or inverse transform is computed.
  54. * Set(=1) ifftFlag for calculation of CIFFT otherwise  CFFT is calculated
  55. * \par
  56. * The parameter <code>bitReverseFlag</code> controls whether output is in normal order or bit reversed order.
  57. * Set(=1) bitReverseFlag for output to be in normal order otherwise output is in bit reversed order.
  58. * \par
  59. * The parameter <code>fftLen</code>     Specifies length of CFFT/CIFFT process. Supported FFT Lengths are 16, 64, 256, 1024.
  60. * \par
  61. * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  62. */
  63.  
  64. arm_status arm_cfft_radix4_init_q31(
  65.   arm_cfft_radix4_instance_q31 * S,
  66.   uint16_t fftLen,
  67.   uint8_t ifftFlag,
  68.   uint8_t bitReverseFlag)
  69. {
  70.   /*  Initialise the default arm status */
  71.   arm_status status = ARM_MATH_SUCCESS;
  72.   /*  Initialise the FFT length */
  73.   S->fftLen = fftLen;
  74.   /*  Initialise the Twiddle coefficient pointer */
  75.   S->pTwiddle = (q31_t *) twiddleCoef_4096_q31;
  76.   /*  Initialise the Flag for selection of CFFT or CIFFT */
  77.   S->ifftFlag = ifftFlag;
  78.   /*  Initialise the Flag for calculation Bit reversal or not */
  79.   S->bitReverseFlag = bitReverseFlag;
  80.  
  81.   /*  Initializations of Instance structure depending on the FFT length */
  82.   switch (S->fftLen)
  83.   {
  84.     /*  Initializations of structure parameters for 4096 point FFT */
  85.   case 4096U:
  86.     /*  Initialise the twiddle coef modifier value */
  87.     S->twidCoefModifier = 1U;
  88.     /*  Initialise the bit reversal table modifier */
  89.     S->bitRevFactor = 1U;
  90.     /*  Initialise the bit reversal table pointer */
  91.     S->pBitRevTable = (uint16_t *) armBitRevTable;
  92.     break;
  93.  
  94.     /*  Initializations of structure parameters for 1024 point FFT */
  95.   case 1024U:
  96.     /*  Initialise the twiddle coef modifier value */
  97.     S->twidCoefModifier = 4U;
  98.     /*  Initialise the bit reversal table modifier */
  99.     S->bitRevFactor = 4U;
  100.     /*  Initialise the bit reversal table pointer */
  101.     S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
  102.     break;
  103.  
  104.   case 256U:
  105.     /*  Initializations of structure parameters for 256 point FFT */
  106.     S->twidCoefModifier = 16U;
  107.     S->bitRevFactor = 16U;
  108.     S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
  109.     break;
  110.  
  111.   case 64U:
  112.     /*  Initializations of structure parameters for 64 point FFT */
  113.     S->twidCoefModifier = 64U;
  114.     S->bitRevFactor = 64U;
  115.     S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
  116.     break;
  117.  
  118.   case 16U:
  119.     /*  Initializations of structure parameters for 16 point FFT */
  120.     S->twidCoefModifier = 256U;
  121.     S->bitRevFactor = 256U;
  122.     S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
  123.     break;
  124.  
  125.   default:
  126.     /*  Reporting argument error if fftSize is not valid value */
  127.     status = ARM_MATH_ARGUMENT_ERROR;
  128.     break;
  129.   }
  130.  
  131.   return (status);
  132. }
  133.  
  134. /**
  135.  * @} end of ComplexFFT group
  136.  */
  137.