| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- /* ----------------------------------------------------------------------
- * Project: CMSIS DSP Python Wrapper
- * Title: fftinit.c
- * Description: FFT init functions for the Python wrapper
- *
- * $Date: 25. March 2019
- * $Revision: V0.0.1
- *
- * Target Processor: Cortex-M cores
- * -------------------------------------------------------------------- */
- /*
- * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the License); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include "arm_math.h"
- #include "arm_common_tables.h"
- #include "arm_const_structs.h"
- #define FFTINIT(SIZE) \
- S->bitRevLength = arm_cfft_sR_f32_len##SIZE.bitRevLength; \
- S->pBitRevTable = arm_cfft_sR_f32_len##SIZE.pBitRevTable; \
- S->pTwiddle = arm_cfft_sR_f32_len##SIZE.pTwiddle;
- #define FFTFXTINIT(EXT,SIZE) \
- S->bitRevLength = arm_cfft_sR_##EXT##_len##SIZE.bitRevLength; \
- S->pBitRevTable = arm_cfft_sR_##EXT##_len##SIZE.pBitRevTable; \
- S->pTwiddle = arm_cfft_sR_##EXT##_len##SIZE.pTwiddle;
- arm_status arm_cfft_init_f32(
- arm_cfft_instance_f32 * S,
- uint16_t fftLen)
- {
- /* Initialise the default arm status */
- arm_status status = ARM_MATH_SUCCESS;
-
- /* Initialise the FFT length */
- S->fftLen = fftLen;
-
- /* Initialise the Twiddle coefficient pointer */
- S->pTwiddle = (float32_t *)twiddleCoef_4096;
-
-
- /* Initializations of Instance structure depending on the FFT length */
- switch (S->fftLen) {
- /* Initializations of structure parameters for 4096 point FFT */
- case 4096U:
- /* Initialise the bit reversal table modifier */
- FFTINIT(4096);
- break;
-
- /* Initializations of structure parameters for 2048 point FFT */
- case 2048U:
- /* Initialise the bit reversal table modifier */
- FFTINIT(2048);
-
- break;
-
- /* Initializations of structure parameters for 1024 point FFT */
- case 1024U:
- /* Initialise the bit reversal table modifier */
- FFTINIT(1024);
-
- break;
-
- /* Initializations of structure parameters for 512 point FFT */
- case 512U:
- /* Initialise the bit reversal table modifier */
- FFTINIT(512);
- break;
-
- case 256U:
- FFTINIT(256);
- break;
-
- case 128U:
- FFTINIT(128);
- break;
-
- case 64U:
- FFTINIT(64);
- break;
-
- case 32U:
- FFTINIT(32);
- break;
-
- case 16U:
- /* Initializations of structure parameters for 16 point FFT */
- FFTINIT(16);
- break;
-
-
- default:
- /* Reporting argument error if fftSize is not valid value */
- status = ARM_MATH_ARGUMENT_ERROR;
- break;
- }
-
-
- return (status);
- }
- arm_status arm_cfft_init_q31(
- arm_cfft_instance_q31 * S,
- uint16_t fftLen)
- {
- /* Initialise the default arm status */
- arm_status status = ARM_MATH_SUCCESS;
-
- /* Initialise the FFT length */
- S->fftLen = fftLen;
-
- /* Initialise the Twiddle coefficient pointer */
- S->pTwiddle = (float32_t *)twiddleCoef_4096;
-
-
- /* Initializations of Instance structure depending on the FFT length */
- switch (S->fftLen) {
- /* Initializations of structure parameters for 4096 point FFT */
- case 4096U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q31,4096);
- break;
-
- /* Initializations of structure parameters for 2048 point FFT */
- case 2048U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q31,2048);
-
- break;
-
- /* Initializations of structure parameters for 1024 point FFT */
- case 1024U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q31,1024);
-
- break;
-
- /* Initializations of structure parameters for 512 point FFT */
- case 512U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q31,512);
- break;
-
- case 256U:
- FFTFXTINIT(q31,256);
- break;
-
- case 128U:
- FFTFXTINIT(q31,128);
- break;
-
- case 64U:
- FFTFXTINIT(q31,64);
- break;
-
- case 32U:
- FFTFXTINIT(q31,32);
- break;
-
- case 16U:
- /* Initializations of structure parameters for 16 point FFT */
- FFTFXTINIT(q31,16);
- break;
-
-
- default:
- /* Reporting argument error if fftSize is not valid value */
- status = ARM_MATH_ARGUMENT_ERROR;
- break;
- }
-
-
- return (status);
- }
- arm_status arm_cfft_init_q15(
- arm_cfft_instance_q15 * S,
- uint16_t fftLen)
- {
- /* Initialise the default arm status */
- arm_status status = ARM_MATH_SUCCESS;
-
- /* Initialise the FFT length */
- S->fftLen = fftLen;
-
- /* Initialise the Twiddle coefficient pointer */
- S->pTwiddle = (float32_t *)twiddleCoef_4096;
-
-
- /* Initializations of Instance structure depending on the FFT length */
- switch (S->fftLen) {
- /* Initializations of structure parameters for 4096 point FFT */
- case 4096U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q15,4096);
- break;
-
- /* Initializations of structure parameters for 2048 point FFT */
- case 2048U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q15,2048);
-
- break;
-
- /* Initializations of structure parameters for 1024 point FFT */
- case 1024U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q15,1024);
-
- break;
-
- /* Initializations of structure parameters for 512 point FFT */
- case 512U:
- /* Initialise the bit reversal table modifier */
- FFTFXTINIT(q15,512);
- break;
-
- case 256U:
- FFTFXTINIT(q15,256);
- break;
-
- case 128U:
- FFTFXTINIT(q15,128);
- break;
-
- case 64U:
- FFTFXTINIT(q15,64);
- break;
-
- case 32U:
- FFTFXTINIT(q15,32);
- break;
-
- case 16U:
- /* Initializations of structure parameters for 16 point FFT */
- FFTFXTINIT(q15,16);
- break;
-
-
- default:
- /* Reporting argument error if fftSize is not valid value */
- status = ARM_MATH_ARGUMENT_ERROR;
- break;
- }
-
-
- return (status);
- }
|