Subversion Repositories AFRtranscoder

Rev

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

  1. /* ----------------------------------------------------------------------
  2.  * Project:      CMSIS DSP Library
  3.  * Title:        arm_cfft_init_f32.c
  4.  * Description:  Split Radix Decimation in Frequency CFFT Floating point processing 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 RealFFT
  38.  * @{
  39.  */
  40.  
  41. /**
  42. * @brief  Initialization function for the floating-point real FFT.
  43. * @param[in,out] *S             points to an arm_rfft_fast_instance_f32 structure.
  44. * @param[in]     fftLen         length of the Real Sequence.
  45. * @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.
  46. *
  47. * \par Description:
  48. * \par
  49. * The parameter <code>fftLen</code>     Specifies length of RFFT/CIFFT process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
  50. * \par
  51. * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
  52. */
  53. arm_status arm_rfft_fast_init_f32(
  54.   arm_rfft_fast_instance_f32 * S,
  55.   uint16_t fftLen)
  56. {
  57.   arm_cfft_instance_f32 * Sint;
  58.   /*  Initialise the default arm status */
  59.   arm_status status = ARM_MATH_SUCCESS;
  60.   /*  Initialise the FFT length */
  61.   Sint = &(S->Sint);
  62.   Sint->fftLen = fftLen/2;
  63.   S->fftLenRFFT = fftLen;
  64.  
  65.   /*  Initializations of structure parameters depending on the FFT length */
  66.   switch (Sint->fftLen)
  67.   {
  68.   case 2048U:
  69.     /*  Initializations of structure parameters for 2048 point FFT */
  70.     /*  Initialise the bit reversal table length */
  71.     Sint->bitRevLength = ARMBITREVINDEXTABLE_2048_TABLE_LENGTH;
  72.     /*  Initialise the bit reversal table pointer */
  73.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable2048;
  74.     /*  Initialise the Twiddle coefficient pointers */
  75.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_2048;
  76.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_4096;
  77.     break;
  78.   case 1024U:
  79.     Sint->bitRevLength = ARMBITREVINDEXTABLE_1024_TABLE_LENGTH;
  80.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable1024;
  81.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_1024;
  82.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_2048;
  83.     break;
  84.   case 512U:
  85.     Sint->bitRevLength = ARMBITREVINDEXTABLE_512_TABLE_LENGTH;
  86.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable512;
  87.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_512;
  88.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_1024;
  89.     break;
  90.   case 256U:
  91.     Sint->bitRevLength = ARMBITREVINDEXTABLE_256_TABLE_LENGTH;
  92.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable256;
  93.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_256;
  94.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_512;
  95.     break;
  96.   case 128U:
  97.     Sint->bitRevLength = ARMBITREVINDEXTABLE_128_TABLE_LENGTH;
  98.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable128;
  99.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_128;
  100.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_256;
  101.     break;
  102.   case 64U:
  103.     Sint->bitRevLength = ARMBITREVINDEXTABLE_64_TABLE_LENGTH;
  104.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable64;
  105.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_64;
  106.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_128;
  107.     break;
  108.   case 32U:
  109.     Sint->bitRevLength = ARMBITREVINDEXTABLE_32_TABLE_LENGTH;
  110.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable32;
  111.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_32;
  112.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_64;
  113.     break;
  114.   case 16U:
  115.     Sint->bitRevLength = ARMBITREVINDEXTABLE_16_TABLE_LENGTH;
  116.     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable16;
  117.                 Sint->pTwiddle     = (float32_t *) twiddleCoef_16;
  118.                 S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_32;
  119.     break;
  120.   default:
  121.     /*  Reporting argument error if fftSize is not valid value */
  122.     status = ARM_MATH_ARGUMENT_ERROR;
  123.     break;
  124.   }
  125.  
  126.   return (status);
  127. }
  128.  
  129. /**
  130.  * @} end of RealFFT group
  131.  */
  132.