Subversion Repositories dashGPS

Rev

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

  1. /* ----------------------------------------------------------------------
  2.  * Project:      CMSIS DSP Library
  3.  * Title:        arm_cfft_radix4_init_q15.c
  4.  * Description:  Radix-4 Decimation in Frequency Q15 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. /**
  38.  * @addtogroup ComplexFFT
  39.  * @{
  40.  */
  41.  
  42.  
  43. /**
  44. * @brief Initialization function for the Q15 CFFT/CIFFT.
  45. * @deprecated Do not use this function.  It has been superseded by \ref arm_cfft_q15 and will be removed
  46. * @param[in,out] *S             points to an instance of the Q15 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_radix4_init_q15(
  66.   arm_cfft_radix4_instance_q15 * 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.   /*  Initialise the FFT length */
  74.   S->fftLen = fftLen;
  75.   /*  Initialise the Twiddle coefficient pointer */
  76.   S->pTwiddle = (q15_t *) twiddleCoef_4096_q15;
  77.   /*  Initialise the Flag for selection of CFFT or CIFFT */
  78.   S->ifftFlag = ifftFlag;
  79.   /*  Initialise the Flag for calculation Bit reversal or not */
  80.   S->bitReverseFlag = bitReverseFlag;
  81.  
  82.   /*  Initializations of structure parameters depending on the FFT length */
  83.   switch (S->fftLen)
  84.   {
  85.   case 4096U:
  86.     /*  Initializations of structure parameters for 4096 point FFT */
  87.  
  88.     /*  Initialise the twiddle coef modifier value */
  89.     S->twidCoefModifier = 1U;
  90.     /*  Initialise the bit reversal table modifier */
  91.     S->bitRevFactor = 1U;
  92.     /*  Initialise the bit reversal table pointer */
  93.     S->pBitRevTable = (uint16_t *) armBitRevTable;
  94.  
  95.     break;
  96.  
  97.   case 1024U:
  98.     /*  Initializations of structure parameters for 1024 point FFT */
  99.     S->twidCoefModifier = 4U;
  100.     S->bitRevFactor = 4U;
  101.     S->pBitRevTable = (uint16_t *) & armBitRevTable[3];
  102.  
  103.     break;
  104.  
  105.   case 256U:
  106.     /*  Initializations of structure parameters for 256 point FFT */
  107.     S->twidCoefModifier = 16U;
  108.     S->bitRevFactor = 16U;
  109.     S->pBitRevTable = (uint16_t *) & armBitRevTable[15];
  110.  
  111.     break;
  112.  
  113.   case 64U:
  114.     /*  Initializations of structure parameters for 64 point FFT */
  115.     S->twidCoefModifier = 64U;
  116.     S->bitRevFactor = 64U;
  117.     S->pBitRevTable = (uint16_t *) & armBitRevTable[63];
  118.  
  119.     break;
  120.  
  121.   case 16U:
  122.     /*  Initializations of structure parameters for 16 point FFT */
  123.     S->twidCoefModifier = 256U;
  124.     S->bitRevFactor = 256U;
  125.     S->pBitRevTable = (uint16_t *) & armBitRevTable[255];
  126.  
  127.     break;
  128.  
  129.   default:
  130.     /*  Reporting argument error if fftSize is not valid value */
  131.     status = ARM_MATH_ARGUMENT_ERROR;
  132.     break;
  133.   }
  134.  
  135.   return (status);
  136. }
  137.  
  138. /**
  139.  * @} end of ComplexFFT group
  140.  */
  141.