Robert Lopez / CMSIS5
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers arm_rfft_fast_init_f32.c Source File

arm_rfft_fast_init_f32.c

00001 /* ----------------------------------------------------------------------
00002  * Project:      CMSIS DSP Library
00003  * Title:        arm_cfft_init_f32.c
00004  * Description:  Split Radix Decimation in Frequency CFFT Floating point processing function
00005  *
00006  * $Date:        27. January 2017
00007  * $Revision:    V.1.5.1
00008  *
00009  * Target Processor: Cortex-M cores
00010  * -------------------------------------------------------------------- */
00011 /*
00012  * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
00013  *
00014  * SPDX-License-Identifier: Apache-2.0
00015  *
00016  * Licensed under the Apache License, Version 2.0 (the License); you may
00017  * not use this file except in compliance with the License.
00018  * You may obtain a copy of the License at
00019  *
00020  * www.apache.org/licenses/LICENSE-2.0
00021  *
00022  * Unless required by applicable law or agreed to in writing, software
00023  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00024  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00025  * See the License for the specific language governing permissions and
00026  * limitations under the License.
00027  */
00028 
00029 #include "arm_math.h"
00030 #include "arm_common_tables.h"
00031 
00032 /**
00033  * @ingroup groupTransforms
00034  */
00035 
00036 /**
00037  * @addtogroup RealFFT
00038  * @{
00039  */
00040 
00041 /**
00042 * @brief  Initialization function for the floating-point real FFT.
00043 * @param[in,out] *S             points to an arm_rfft_fast_instance_f32 structure.
00044 * @param[in]     fftLen         length of the Real Sequence.
00045 * @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.
00046 *
00047 * \par Description:
00048 * \par
00049 * The parameter <code>fftLen</code> Specifies length of RFFT/CIFFT process. Supported FFT Lengths are 32, 64, 128, 256, 512, 1024, 2048, 4096.
00050 * \par
00051 * This Function also initializes Twiddle factor table pointer and Bit reversal table pointer.
00052 */
00053 arm_status arm_rfft_fast_init_f32(
00054   arm_rfft_fast_instance_f32 * S,
00055   uint16_t fftLen)
00056 {
00057   arm_cfft_instance_f32 * Sint;
00058   /*  Initialise the default arm status */
00059   arm_status status = ARM_MATH_SUCCESS;
00060   /*  Initialise the FFT length */
00061   Sint = &(S->Sint);
00062   Sint->fftLen = fftLen/2;
00063   S->fftLenRFFT = fftLen;
00064 
00065   /*  Initializations of structure parameters depending on the FFT length */
00066   switch (Sint->fftLen)
00067   {
00068   case 2048U:
00069     /*  Initializations of structure parameters for 2048 point FFT */
00070     /*  Initialise the bit reversal table length */
00071     Sint->bitRevLength = ARMBITREVINDEXTABLE_2048_TABLE_LENGTH;
00072     /*  Initialise the bit reversal table pointer */
00073     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable2048;
00074     /*  Initialise the Twiddle coefficient pointers */
00075         Sint->pTwiddle     = (float32_t *) twiddleCoef_2048 ;
00076         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_4096;
00077     break;
00078   case 1024U:
00079     Sint->bitRevLength = ARMBITREVINDEXTABLE_1024_TABLE_LENGTH;
00080     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable1024;
00081         Sint->pTwiddle     = (float32_t *) twiddleCoef_1024 ;
00082         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_2048;
00083     break;
00084   case 512U:
00085     Sint->bitRevLength = ARMBITREVINDEXTABLE_512_TABLE_LENGTH;
00086     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable512;
00087         Sint->pTwiddle     = (float32_t *) twiddleCoef_512 ;
00088         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_1024;
00089     break;
00090   case 256U:
00091     Sint->bitRevLength = ARMBITREVINDEXTABLE_256_TABLE_LENGTH;
00092     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable256;
00093         Sint->pTwiddle     = (float32_t *) twiddleCoef_256 ;
00094         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_512;
00095     break;
00096   case 128U:
00097     Sint->bitRevLength = ARMBITREVINDEXTABLE_128_TABLE_LENGTH;
00098     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable128;
00099         Sint->pTwiddle     = (float32_t *) twiddleCoef_128 ;
00100         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_256;
00101     break;
00102   case 64U:
00103     Sint->bitRevLength = ARMBITREVINDEXTABLE_64_TABLE_LENGTH;
00104     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable64;
00105         Sint->pTwiddle     = (float32_t *) twiddleCoef_64 ;
00106         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_128;
00107     break;
00108   case 32U:
00109     Sint->bitRevLength = ARMBITREVINDEXTABLE_32_TABLE_LENGTH;
00110     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable32;
00111         Sint->pTwiddle     = (float32_t *) twiddleCoef_32 ;
00112         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_64;
00113     break;
00114   case 16U:
00115     Sint->bitRevLength = ARMBITREVINDEXTABLE_16_TABLE_LENGTH;
00116     Sint->pBitRevTable = (uint16_t *)armBitRevIndexTable16;
00117         Sint->pTwiddle     = (float32_t *) twiddleCoef_16 ;
00118         S->pTwiddleRFFT    = (float32_t *) twiddleCoef_rfft_32;
00119     break;
00120   default:
00121     /*  Reporting argument error if fftSize is not valid value */
00122     status = ARM_MATH_ARGUMENT_ERROR;
00123     break;
00124   }
00125 
00126   return (status);
00127 }
00128 
00129 /**
00130  * @} end of RealFFT group
00131  */
00132