Fork of mbed-dsp. CMSIS-DSP library of supporting NEON
Dependents: mbed-os-example-cmsis_dsp_neon
Fork of mbed-dsp by
arm_math.h
00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 12. March 2014 00005 * $Revision: V1.4.3 00006 * 00007 * Project: CMSIS DSP Library 00008 * Title: arm_math.h 00009 * 00010 * Description: Public header file for CMSIS DSP Library 00011 * 00012 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions 00016 * are met: 00017 * - Redistributions of source code must retain the above copyright 00018 * notice, this list of conditions and the following disclaimer. 00019 * - Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in 00021 * the documentation and/or other materials provided with the 00022 * distribution. 00023 * - Neither the name of ARM LIMITED nor the names of its contributors 00024 * may be used to endorse or promote products derived from this 00025 * software without specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00028 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00029 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00030 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00031 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00033 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00034 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00036 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00037 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00038 * POSSIBILITY OF SUCH DAMAGE. 00039 * -------------------------------------------------------------------- */ 00040 00041 /** 00042 \mainpage CMSIS DSP Software Library 00043 * 00044 * Introduction 00045 * ------------ 00046 * 00047 * This user manual describes the CMSIS DSP software library, 00048 * a suite of common signal processing functions for use on Cortex-M processor based devices. 00049 * 00050 * The library is divided into a number of functions each covering a specific category: 00051 * - Basic math functions 00052 * - Fast math functions 00053 * - Complex math functions 00054 * - Filters 00055 * - Matrix functions 00056 * - Transforms 00057 * - Motor control functions 00058 * - Statistical functions 00059 * - Support functions 00060 * - Interpolation functions 00061 * 00062 * The library has separate functions for operating on 8-bit integers, 16-bit integers, 00063 * 32-bit integer and 32-bit floating-point values. 00064 * 00065 * Using the Library 00066 * ------------ 00067 * 00068 * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder. 00069 * - arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4) 00070 * - arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4) 00071 * - arm_cortexM4l_math.lib (Little endian on Cortex-M4) 00072 * - arm_cortexM4b_math.lib (Big endian on Cortex-M4) 00073 * - arm_cortexM3l_math.lib (Little endian on Cortex-M3) 00074 * - arm_cortexM3b_math.lib (Big endian on Cortex-M3) 00075 * - arm_cortexM0l_math.lib (Little endian on Cortex-M0) 00076 * - arm_cortexM0b_math.lib (Big endian on Cortex-M3) 00077 * 00078 * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder. 00079 * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single 00080 * public header file <code> arm_math.h</code> for Cortex-M4/M3/M0 with little endian and big endian. Same header file will be used for floating point unit(FPU) variants. 00081 * Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or 00082 * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application. 00083 * 00084 * Examples 00085 * -------- 00086 * 00087 * The library ships with a number of examples which demonstrate how to use the library functions. 00088 * 00089 * Toolchain Support 00090 * ------------ 00091 * 00092 * The library has been developed and tested with MDK-ARM version 4.60. 00093 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly. 00094 * 00095 * Building the Library 00096 * ------------ 00097 * 00098 * The library installer contains a project file to re build libraries on MDK-ARM Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder. 00099 * - arm_cortexM_math.uvproj 00100 * 00101 * 00102 * The libraries can be built by opening the arm_cortexM_math.uvproj project in MDK-ARM, selecting a specific target, and defining the optional pre processor MACROs detailed above. 00103 * 00104 * Pre-processor Macros 00105 * ------------ 00106 * 00107 * Each library project have differant pre-processor macros. 00108 * 00109 * - UNALIGNED_SUPPORT_DISABLE: 00110 * 00111 * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access 00112 * 00113 * - ARM_MATH_BIG_ENDIAN: 00114 * 00115 * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets. 00116 * 00117 * - ARM_MATH_MATRIX_CHECK: 00118 * 00119 * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices 00120 * 00121 * - ARM_MATH_ROUNDING: 00122 * 00123 * Define macro ARM_MATH_ROUNDING for rounding on support functions 00124 * 00125 * - ARM_MATH_CMx: 00126 * 00127 * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target 00128 * and ARM_MATH_CM0 for building library on cortex-M0 target, ARM_MATH_CM0PLUS for building library on cortex-M0+ target. 00129 * 00130 * - __FPU_PRESENT: 00131 * 00132 * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries 00133 * 00134 * <hr> 00135 * CMSIS-DSP in ARM::CMSIS Pack 00136 * ----------------------------- 00137 * 00138 * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories: 00139 * |File/Folder |Content | 00140 * |------------------------------|------------------------------------------------------------------------| 00141 * |\b CMSIS\\Documentation\\DSP | This documentation | 00142 * |\b CMSIS\\DSP_Lib | Software license agreement (license.txt) | 00143 * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions | 00144 * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library | 00145 * 00146 * <hr> 00147 * Revision History of CMSIS-DSP 00148 * ------------ 00149 * Please refer to \ref ChangeLog_pg. 00150 * 00151 * Copyright Notice 00152 * ------------ 00153 * 00154 * Copyright (C) 2010-2014 ARM Limited. All rights reserved. 00155 */ 00156 00157 00158 /** 00159 * @defgroup groupMath Basic Math Functions 00160 */ 00161 00162 /** 00163 * @defgroup groupFastMath Fast Math Functions 00164 * This set of functions provides a fast approximation to sine, cosine, and square root. 00165 * As compared to most of the other functions in the CMSIS math library, the fast math functions 00166 * operate on individual values and not arrays. 00167 * There are separate functions for Q15, Q31, and floating-point data. 00168 * 00169 */ 00170 00171 /** 00172 * @defgroup groupCmplxMath Complex Math Functions 00173 * This set of functions operates on complex data vectors. 00174 * The data in the complex arrays is stored in an interleaved fashion 00175 * (real, imag, real, imag, ...). 00176 * In the API functions, the number of samples in a complex array refers 00177 * to the number of complex values; the array contains twice this number of 00178 * real values. 00179 */ 00180 00181 /** 00182 * @defgroup groupFilters Filtering Functions 00183 */ 00184 00185 /** 00186 * @defgroup groupMatrix Matrix Functions 00187 * 00188 * This set of functions provides basic matrix math operations. 00189 * The functions operate on matrix data structures. For example, 00190 * the type 00191 * definition for the floating-point matrix structure is shown 00192 * below: 00193 * <pre> 00194 * typedef struct 00195 * { 00196 * uint16_t numRows; // number of rows of the matrix. 00197 * uint16_t numCols; // number of columns of the matrix. 00198 * float32_t *pData; // points to the data of the matrix. 00199 * } arm_matrix_instance_f32; 00200 * </pre> 00201 * There are similar definitions for Q15 and Q31 data types. 00202 * 00203 * The structure specifies the size of the matrix and then points to 00204 * an array of data. The array is of size <code>numRows X numCols</code> 00205 * and the values are arranged in row order. That is, the 00206 * matrix element (i, j) is stored at: 00207 * <pre> 00208 * pData[i*numCols + j] 00209 * </pre> 00210 * 00211 * \par Init Functions 00212 * There is an associated initialization function for each type of matrix 00213 * data structure. 00214 * The initialization function sets the values of the internal structure fields. 00215 * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code> 00216 * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively. 00217 * 00218 * \par 00219 * Use of the initialization function is optional. However, if initialization function is used 00220 * then the instance structure cannot be placed into a const data section. 00221 * To place the instance structure in a const data 00222 * section, manually initialize the data structure. For example: 00223 * <pre> 00224 * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code> 00225 * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code> 00226 * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code> 00227 * </pre> 00228 * where <code>nRows</code> specifies the number of rows, <code>nColumns</code> 00229 * specifies the number of columns, and <code>pData</code> points to the 00230 * data array. 00231 * 00232 * \par Size Checking 00233 * By default all of the matrix functions perform size checking on the input and 00234 * output matrices. For example, the matrix addition function verifies that the 00235 * two input matrices and the output matrix all have the same number of rows and 00236 * columns. If the size check fails the functions return: 00237 * <pre> 00238 * ARM_MATH_SIZE_MISMATCH 00239 * </pre> 00240 * Otherwise the functions return 00241 * <pre> 00242 * ARM_MATH_SUCCESS 00243 * </pre> 00244 * There is some overhead associated with this matrix size checking. 00245 * The matrix size checking is enabled via the \#define 00246 * <pre> 00247 * ARM_MATH_MATRIX_CHECK 00248 * </pre> 00249 * within the library project settings. By default this macro is defined 00250 * and size checking is enabled. By changing the project settings and 00251 * undefining this macro size checking is eliminated and the functions 00252 * run a bit faster. With size checking disabled the functions always 00253 * return <code>ARM_MATH_SUCCESS</code>. 00254 */ 00255 00256 /** 00257 * @defgroup groupTransforms Transform Functions 00258 */ 00259 00260 /** 00261 * @defgroup groupController Controller Functions 00262 */ 00263 00264 /** 00265 * @defgroup groupStats Statistics Functions 00266 */ 00267 /** 00268 * @defgroup groupSupport Support Functions 00269 */ 00270 00271 /** 00272 * @defgroup groupInterpolation Interpolation Functions 00273 * These functions perform 1- and 2-dimensional interpolation of data. 00274 * Linear interpolation is used for 1-dimensional data and 00275 * bilinear interpolation is used for 2-dimensional data. 00276 */ 00277 00278 /** 00279 * @defgroup groupExamples Examples 00280 */ 00281 #ifndef _ARM_MATH_H 00282 #define _ARM_MATH_H 00283 00284 #define __CMSIS_GENERIC /* disable NVIC and Systick functions */ 00285 00286 #if 0 00287 #if defined (ARM_MATH_CM4) 00288 #include "core_cm4.h" 00289 #elif defined (ARM_MATH_CM3) 00290 #include "core_cm3.h" 00291 #elif defined (ARM_MATH_CM0) 00292 #include "core_cm0.h" 00293 #define ARM_MATH_CM0_FAMILY 00294 #elif defined (ARM_MATH_CM0PLUS) 00295 #include "core_cm0plus.h" 00296 #define ARM_MATH_CM0_FAMILY 00297 #elif defined (ARM_MATH_CA9) 00298 #include "core_ca9.h" 00299 #else 00300 #include "ARMCM4.h" 00301 #warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on ARM_MATH_CM4....." 00302 #endif 00303 #else 00304 #include <arm_neon.h> 00305 #if !defined(__CC_ARM) 00306 #define ARM_MATH_CM0_FAMILY 00307 #endif 00308 #define __FPU_USED 1 00309 #define __INLINE __inline 00310 #if defined(__CC_ARM) 00311 #define __QADD __qadd 00312 #define __QSUB __qsub 00313 #define __QSUB16 __qsub16 00314 #define __QSUB8 __qsub8 00315 #define __CLZ __clz 00316 #define __SSAT __ssat 00317 #define __SMUAD __smuad 00318 #define __SMLALD __smlald 00319 #define __QADD16 __qadd16 00320 #define __SHADD16 __shadd16 00321 #define __SMUADX __smuadx 00322 #define __SMUSD __smusd 00323 #define __SMUSDX __smusdx 00324 #define __QASX __qasx 00325 #define __QSAX __qsax 00326 #define __SHASX __shasx 00327 #define __SHSAX __shsax 00328 #define __SHSUB16 __shsub16 00329 #define __SMLAD __smlad 00330 #define __SMLADX __smladx 00331 #define __SMLSDX __smlsdx 00332 #define __ROR __ror 00333 #define __SXTB16 __sxtb16 00334 #define __SMLALDX __smlaldx 00335 #define __QADD8 __qadd8 00336 #endif 00337 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \ 00338 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) ) 00339 #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \ 00340 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) ) 00341 #endif 00342 00343 #undef __CMSIS_GENERIC /* enable NVIC and Systick functions */ 00344 #include "string.h" 00345 #include "math.h" 00346 #ifdef __cplusplus 00347 extern "C" 00348 { 00349 #endif 00350 00351 00352 /** 00353 * @brief Macros required for reciprocal calculation in Normalized LMS 00354 */ 00355 00356 #define DELTA_Q31 (0x100) 00357 #define DELTA_Q15 0x5 00358 #define INDEX_MASK 0x0000003F 00359 #ifndef PI 00360 #define PI 3.14159265358979f 00361 #endif 00362 00363 /** 00364 * @brief Macros required for SINE and COSINE Fast math approximations 00365 */ 00366 00367 #define FAST_MATH_TABLE_SIZE 512 00368 #define FAST_MATH_Q31_SHIFT (32 - 10) 00369 #define FAST_MATH_Q15_SHIFT (16 - 10) 00370 #define CONTROLLER_Q31_SHIFT (32 - 9) 00371 #define TABLE_SIZE 256 00372 #define TABLE_SPACING_Q31 0x400000 00373 #define TABLE_SPACING_Q15 0x80 00374 00375 /** 00376 * @brief Macros required for SINE and COSINE Controller functions 00377 */ 00378 /* 1.31(q31) Fixed value of 2/360 */ 00379 /* -1 to +1 is divided into 360 values so total spacing is (2/360) */ 00380 #define INPUT_SPACING 0xB60B61 00381 00382 /** 00383 * @brief Macro for Unaligned Support 00384 */ 00385 #ifndef UNALIGNED_SUPPORT_DISABLE 00386 #define ALIGN4 00387 #else 00388 #if defined (__GNUC__) 00389 #define ALIGN4 __attribute__((aligned(4))) 00390 #else 00391 #define ALIGN4 __align(4) 00392 #endif 00393 #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */ 00394 00395 /** 00396 * @brief Error status returned by some functions in the library. 00397 */ 00398 00399 typedef enum 00400 { 00401 ARM_MATH_SUCCESS = 0, /**< No error */ 00402 ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */ 00403 ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */ 00404 ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */ 00405 ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */ 00406 ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */ 00407 ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */ 00408 } arm_status; 00409 00410 /** 00411 * @brief 8-bit fractional data type in 1.7 format. 00412 */ 00413 typedef int8_t q7_t; 00414 00415 /** 00416 * @brief 16-bit fractional data type in 1.15 format. 00417 */ 00418 typedef int16_t q15_t; 00419 00420 /** 00421 * @brief 32-bit fractional data type in 1.31 format. 00422 */ 00423 typedef int32_t q31_t; 00424 00425 /** 00426 * @brief 64-bit fractional data type in 1.63 format. 00427 */ 00428 typedef int64_t q63_t; 00429 00430 /** 00431 * @brief 32-bit floating-point type definition. 00432 */ 00433 typedef float float32_t; 00434 00435 /** 00436 * @brief 64-bit floating-point type definition. 00437 */ 00438 typedef double float64_t; 00439 00440 /** 00441 * @brief definition to read/write two 16 bit values. 00442 */ 00443 #if defined __CC_ARM 00444 #define __SIMD32_TYPE int32_t __packed 00445 #define CMSIS_UNUSED __attribute__((unused)) 00446 #elif defined __ICCARM__ 00447 #define CMSIS_UNUSED 00448 #define __SIMD32_TYPE int32_t __packed 00449 #elif defined __GNUC__ 00450 #define __SIMD32_TYPE int32_t 00451 #define CMSIS_UNUSED __attribute__((unused)) 00452 #elif defined __CSMC__ /* Cosmic */ 00453 #define CMSIS_UNUSED 00454 #define __SIMD32_TYPE int32_t 00455 #else 00456 #error Unknown compiler 00457 #endif 00458 00459 #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr)) 00460 #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr)) 00461 00462 #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr)) 00463 00464 #define __SIMD64(addr) (*(int64_t **) & (addr)) 00465 00466 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) 00467 /** 00468 * @brief definition to pack two 16 bit values. 00469 */ 00470 #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \ 00471 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) ) 00472 #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \ 00473 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) ) 00474 00475 #endif 00476 00477 00478 /** 00479 * @brief definition to pack four 8 bit values. 00480 */ 00481 #ifndef ARM_MATH_BIG_ENDIAN 00482 00483 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \ 00484 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \ 00485 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \ 00486 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) ) 00487 #else 00488 00489 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \ 00490 (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \ 00491 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \ 00492 (((int32_t)(v0) << 24) & (int32_t)0xFF000000) ) 00493 00494 #endif 00495 00496 00497 /** 00498 * @brief Clips Q63 to Q31 values. 00499 */ 00500 static __INLINE q31_t clip_q63_to_q31( 00501 q63_t x) 00502 { 00503 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? 00504 ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x; 00505 } 00506 00507 /** 00508 * @brief Clips Q63 to Q15 values. 00509 */ 00510 static __INLINE q15_t clip_q63_to_q15( 00511 q63_t x) 00512 { 00513 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? 00514 ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15); 00515 } 00516 00517 /** 00518 * @brief Clips Q31 to Q7 values. 00519 */ 00520 static __INLINE q7_t clip_q31_to_q7( 00521 q31_t x) 00522 { 00523 return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ? 00524 ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x; 00525 } 00526 00527 /** 00528 * @brief Clips Q31 to Q15 values. 00529 */ 00530 static __INLINE q15_t clip_q31_to_q15( 00531 q31_t x) 00532 { 00533 return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ? 00534 ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x; 00535 } 00536 00537 /** 00538 * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format. 00539 */ 00540 00541 static __INLINE q63_t mult32x64( 00542 q63_t x, 00543 q31_t y) 00544 { 00545 return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) + 00546 (((q63_t) (x >> 32) * y))); 00547 } 00548 00549 00550 #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM ) 00551 #define __CLZ __clz 00552 #endif 00553 00554 /* #if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) || defined (__TASKING__) ) */ 00555 #if !defined(__CLZ) 00556 00557 static __INLINE uint32_t __CLZ( 00558 q31_t data); 00559 00560 00561 static __INLINE uint32_t __CLZ( 00562 q31_t data) 00563 { 00564 uint32_t count = 0; 00565 uint32_t mask = 0x80000000; 00566 00567 while((data & mask) == 0) 00568 { 00569 count += 1u; 00570 mask = mask >> 1u; 00571 } 00572 00573 return (count); 00574 00575 } 00576 00577 #endif 00578 00579 /** 00580 * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type. 00581 */ 00582 00583 static __INLINE uint32_t arm_recip_q31( 00584 q31_t in, 00585 q31_t * dst, 00586 q31_t * pRecipTable) 00587 { 00588 00589 uint32_t out, tempVal; 00590 uint32_t index, i; 00591 uint32_t signBits; 00592 00593 if(in > 0) 00594 { 00595 signBits = __CLZ(in) - 1; 00596 } 00597 else 00598 { 00599 signBits = __CLZ(-in) - 1; 00600 } 00601 00602 /* Convert input sample to 1.31 format */ 00603 in = in << signBits; 00604 00605 /* calculation of index for initial approximated Val */ 00606 index = (uint32_t) (in >> 24u); 00607 index = (index & INDEX_MASK); 00608 00609 /* 1.31 with exp 1 */ 00610 out = pRecipTable[index]; 00611 00612 /* calculation of reciprocal value */ 00613 /* running approximation for two iterations */ 00614 for (i = 0u; i < 2u; i++) 00615 { 00616 tempVal = (q31_t) (((q63_t) in * out) >> 31u); 00617 tempVal = 0x7FFFFFFF - tempVal; 00618 /* 1.31 with exp 1 */ 00619 //out = (q31_t) (((q63_t) out * tempVal) >> 30u); 00620 out = (q31_t) clip_q63_to_q31(((q63_t) out * tempVal) >> 30u); 00621 } 00622 00623 /* write output */ 00624 *dst = out; 00625 00626 /* return num of signbits of out = 1/in value */ 00627 return (signBits + 1u); 00628 00629 } 00630 00631 /** 00632 * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type. 00633 */ 00634 static __INLINE uint32_t arm_recip_q15( 00635 q15_t in, 00636 q15_t * dst, 00637 q15_t * pRecipTable) 00638 { 00639 00640 uint32_t out = 0, tempVal = 0; 00641 uint32_t index = 0, i = 0; 00642 uint32_t signBits = 0; 00643 00644 if(in > 0) 00645 { 00646 signBits = __CLZ(in) - 17; 00647 } 00648 else 00649 { 00650 signBits = __CLZ(-in) - 17; 00651 } 00652 00653 /* Convert input sample to 1.15 format */ 00654 in = in << signBits; 00655 00656 /* calculation of index for initial approximated Val */ 00657 index = in >> 8; 00658 index = (index & INDEX_MASK); 00659 00660 /* 1.15 with exp 1 */ 00661 out = pRecipTable[index]; 00662 00663 /* calculation of reciprocal value */ 00664 /* running approximation for two iterations */ 00665 for (i = 0; i < 2; i++) 00666 { 00667 tempVal = (q15_t) (((q31_t) in * out) >> 15); 00668 tempVal = 0x7FFF - tempVal; 00669 /* 1.15 with exp 1 */ 00670 out = (q15_t) (((q31_t) out * tempVal) >> 14); 00671 } 00672 00673 /* write output */ 00674 *dst = out; 00675 00676 /* return num of signbits of out = 1/in value */ 00677 return (signBits + 1); 00678 00679 } 00680 00681 00682 /* 00683 * @brief C custom defined intrinisic function for only M0 processors 00684 */ 00685 #if defined(ARM_MATH_CM0_FAMILY) 00686 00687 static __INLINE q31_t __SSAT( 00688 q31_t x, 00689 uint32_t y) 00690 { 00691 int32_t posMax, negMin; 00692 uint32_t i; 00693 00694 posMax = 1; 00695 for (i = 0; i < (y - 1); i++) 00696 { 00697 posMax = posMax * 2; 00698 } 00699 00700 if(x > 0) 00701 { 00702 posMax = (posMax - 1); 00703 00704 if(x > posMax) 00705 { 00706 x = posMax; 00707 } 00708 } 00709 else 00710 { 00711 negMin = -posMax; 00712 00713 if(x < negMin) 00714 { 00715 x = negMin; 00716 } 00717 } 00718 return (x); 00719 00720 00721 } 00722 00723 #endif /* end of ARM_MATH_CM0_FAMILY */ 00724 00725 00726 00727 /* 00728 * @brief C custom defined intrinsic function for M3 and M0 processors 00729 */ 00730 #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) 00731 00732 /* 00733 * @brief C custom defined QADD8 for M3 and M0 processors 00734 */ 00735 static __INLINE q31_t __QADD8( 00736 q31_t x, 00737 q31_t y) 00738 { 00739 00740 q31_t sum; 00741 q7_t r, s, t, u; 00742 00743 r = (q7_t) x; 00744 s = (q7_t) y; 00745 00746 r = __SSAT((q31_t) (r + s), 8); 00747 s = __SSAT(((q31_t) (((x << 16) >> 24) + ((y << 16) >> 24))), 8); 00748 t = __SSAT(((q31_t) (((x << 8) >> 24) + ((y << 8) >> 24))), 8); 00749 u = __SSAT(((q31_t) ((x >> 24) + (y >> 24))), 8); 00750 00751 sum = 00752 (((q31_t) u << 24) & 0xFF000000) | (((q31_t) t << 16) & 0x00FF0000) | 00753 (((q31_t) s << 8) & 0x0000FF00) | (r & 0x000000FF); 00754 00755 return sum; 00756 00757 } 00758 00759 /* 00760 * @brief C custom defined QSUB8 for M3 and M0 processors 00761 */ 00762 static __INLINE q31_t __QSUB8( 00763 q31_t x, 00764 q31_t y) 00765 { 00766 00767 q31_t sum; 00768 q31_t r, s, t, u; 00769 00770 r = (q7_t) x; 00771 s = (q7_t) y; 00772 00773 r = __SSAT((r - s), 8); 00774 s = __SSAT(((q31_t) (((x << 16) >> 24) - ((y << 16) >> 24))), 8) << 8; 00775 t = __SSAT(((q31_t) (((x << 8) >> 24) - ((y << 8) >> 24))), 8) << 16; 00776 u = __SSAT(((q31_t) ((x >> 24) - (y >> 24))), 8) << 24; 00777 00778 sum = 00779 (u & 0xFF000000) | (t & 0x00FF0000) | (s & 0x0000FF00) | (r & 00780 0x000000FF); 00781 00782 return sum; 00783 } 00784 00785 /* 00786 * @brief C custom defined QADD16 for M3 and M0 processors 00787 */ 00788 00789 /* 00790 * @brief C custom defined QADD16 for M3 and M0 processors 00791 */ 00792 static __INLINE q31_t __QADD16( 00793 q31_t x, 00794 q31_t y) 00795 { 00796 00797 q31_t sum; 00798 q31_t r, s; 00799 00800 r = (q15_t) x; 00801 s = (q15_t) y; 00802 00803 r = __SSAT(r + s, 16); 00804 s = __SSAT(((q31_t) ((x >> 16) + (y >> 16))), 16) << 16; 00805 00806 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00807 00808 return sum; 00809 00810 } 00811 00812 /* 00813 * @brief C custom defined SHADD16 for M3 and M0 processors 00814 */ 00815 static __INLINE q31_t __SHADD16( 00816 q31_t x, 00817 q31_t y) 00818 { 00819 00820 q31_t sum; 00821 q31_t r, s; 00822 00823 r = (q15_t) x; 00824 s = (q15_t) y; 00825 00826 r = ((r >> 1) + (s >> 1)); 00827 s = ((q31_t) ((x >> 17) + (y >> 17))) << 16; 00828 00829 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00830 00831 return sum; 00832 00833 } 00834 00835 /* 00836 * @brief C custom defined QSUB16 for M3 and M0 processors 00837 */ 00838 static __INLINE q31_t __QSUB16( 00839 q31_t x, 00840 q31_t y) 00841 { 00842 00843 q31_t sum; 00844 q31_t r, s; 00845 00846 r = (q15_t) x; 00847 s = (q15_t) y; 00848 00849 r = __SSAT(r - s, 16); 00850 s = __SSAT(((q31_t) ((x >> 16) - (y >> 16))), 16) << 16; 00851 00852 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00853 00854 return sum; 00855 } 00856 00857 /* 00858 * @brief C custom defined SHSUB16 for M3 and M0 processors 00859 */ 00860 static __INLINE q31_t __SHSUB16( 00861 q31_t x, 00862 q31_t y) 00863 { 00864 00865 q31_t diff; 00866 q31_t r, s; 00867 00868 r = (q15_t) x; 00869 s = (q15_t) y; 00870 00871 r = ((r >> 1) - (s >> 1)); 00872 s = (((x >> 17) - (y >> 17)) << 16); 00873 00874 diff = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00875 00876 return diff; 00877 } 00878 00879 /* 00880 * @brief C custom defined QASX for M3 and M0 processors 00881 */ 00882 static __INLINE q31_t __QASX( 00883 q31_t x, 00884 q31_t y) 00885 { 00886 00887 q31_t sum = 0; 00888 00889 sum = 00890 ((sum + 00891 clip_q31_to_q15((q31_t) ((q15_t) (x >> 16) + (q15_t) y))) << 16) + 00892 clip_q31_to_q15((q31_t) ((q15_t) x - (q15_t) (y >> 16))); 00893 00894 return sum; 00895 } 00896 00897 /* 00898 * @brief C custom defined SHASX for M3 and M0 processors 00899 */ 00900 static __INLINE q31_t __SHASX( 00901 q31_t x, 00902 q31_t y) 00903 { 00904 00905 q31_t sum; 00906 q31_t r, s; 00907 00908 r = (q15_t) x; 00909 s = (q15_t) y; 00910 00911 r = ((r >> 1) - (y >> 17)); 00912 s = (((x >> 17) + (s >> 1)) << 16); 00913 00914 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00915 00916 return sum; 00917 } 00918 00919 00920 /* 00921 * @brief C custom defined QSAX for M3 and M0 processors 00922 */ 00923 static __INLINE q31_t __QSAX( 00924 q31_t x, 00925 q31_t y) 00926 { 00927 00928 q31_t sum = 0; 00929 00930 sum = 00931 ((sum + 00932 clip_q31_to_q15((q31_t) ((q15_t) (x >> 16) - (q15_t) y))) << 16) + 00933 clip_q31_to_q15((q31_t) ((q15_t) x + (q15_t) (y >> 16))); 00934 00935 return sum; 00936 } 00937 00938 /* 00939 * @brief C custom defined SHSAX for M3 and M0 processors 00940 */ 00941 static __INLINE q31_t __SHSAX( 00942 q31_t x, 00943 q31_t y) 00944 { 00945 00946 q31_t sum; 00947 q31_t r, s; 00948 00949 r = (q15_t) x; 00950 s = (q15_t) y; 00951 00952 r = ((r >> 1) + (y >> 17)); 00953 s = (((x >> 17) - (s >> 1)) << 16); 00954 00955 sum = (s & 0xFFFF0000) | (r & 0x0000FFFF); 00956 00957 return sum; 00958 } 00959 00960 /* 00961 * @brief C custom defined SMUSDX for M3 and M0 processors 00962 */ 00963 static __INLINE q31_t __SMUSDX( 00964 q31_t x, 00965 q31_t y) 00966 { 00967 00968 return ((q31_t) (((q15_t) x * (q15_t) (y >> 16)) - 00969 ((q15_t) (x >> 16) * (q15_t) y))); 00970 } 00971 00972 /* 00973 * @brief C custom defined SMUADX for M3 and M0 processors 00974 */ 00975 static __INLINE q31_t __SMUADX( 00976 q31_t x, 00977 q31_t y) 00978 { 00979 00980 return ((q31_t) (((q15_t) x * (q15_t) (y >> 16)) + 00981 ((q15_t) (x >> 16) * (q15_t) y))); 00982 } 00983 00984 /* 00985 * @brief C custom defined QADD for M3 and M0 processors 00986 */ 00987 static __INLINE q31_t __QADD( 00988 q31_t x, 00989 q31_t y) 00990 { 00991 return clip_q63_to_q31((q63_t) x + y); 00992 } 00993 00994 /* 00995 * @brief C custom defined QSUB for M3 and M0 processors 00996 */ 00997 static __INLINE q31_t __QSUB( 00998 q31_t x, 00999 q31_t y) 01000 { 01001 return clip_q63_to_q31((q63_t) x - y); 01002 } 01003 01004 /* 01005 * @brief C custom defined SMLAD for M3 and M0 processors 01006 */ 01007 static __INLINE q31_t __SMLAD( 01008 q31_t x, 01009 q31_t y, 01010 q31_t sum) 01011 { 01012 01013 return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + 01014 ((q15_t) x * (q15_t) y)); 01015 } 01016 01017 /* 01018 * @brief C custom defined SMLADX for M3 and M0 processors 01019 */ 01020 static __INLINE q31_t __SMLADX( 01021 q31_t x, 01022 q31_t y, 01023 q31_t sum) 01024 { 01025 01026 return (sum + ((q15_t) (x >> 16) * (q15_t) (y)) + 01027 ((q15_t) x * (q15_t) (y >> 16))); 01028 } 01029 01030 /* 01031 * @brief C custom defined SMLSDX for M3 and M0 processors 01032 */ 01033 static __INLINE q31_t __SMLSDX( 01034 q31_t x, 01035 q31_t y, 01036 q31_t sum) 01037 { 01038 01039 return (sum - ((q15_t) (x >> 16) * (q15_t) (y)) + 01040 ((q15_t) x * (q15_t) (y >> 16))); 01041 } 01042 01043 /* 01044 * @brief C custom defined SMLALD for M3 and M0 processors 01045 */ 01046 static __INLINE q63_t __SMLALD( 01047 q31_t x, 01048 q31_t y, 01049 q63_t sum) 01050 { 01051 01052 return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + 01053 ((q15_t) x * (q15_t) y)); 01054 } 01055 01056 /* 01057 * @brief C custom defined SMLALDX for M3 and M0 processors 01058 */ 01059 static __INLINE q63_t __SMLALDX( 01060 q31_t x, 01061 q31_t y, 01062 q63_t sum) 01063 { 01064 01065 return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + 01066 ((q15_t) x * (q15_t) (y >> 16)); 01067 } 01068 01069 /* 01070 * @brief C custom defined SMUAD for M3 and M0 processors 01071 */ 01072 static __INLINE q31_t __SMUAD( 01073 q31_t x, 01074 q31_t y) 01075 { 01076 01077 return (((x >> 16) * (y >> 16)) + 01078 (((x << 16) >> 16) * ((y << 16) >> 16))); 01079 } 01080 01081 /* 01082 * @brief C custom defined SMUSD for M3 and M0 processors 01083 */ 01084 static __INLINE q31_t __SMUSD( 01085 q31_t x, 01086 q31_t y) 01087 { 01088 01089 return (-((x >> 16) * (y >> 16)) + 01090 (((x << 16) >> 16) * ((y << 16) >> 16))); 01091 } 01092 01093 01094 /* 01095 * @brief C custom defined SXTB16 for M3 and M0 processors 01096 */ 01097 static __INLINE q31_t __SXTB16( 01098 q31_t x) 01099 { 01100 01101 return ((((x << 24) >> 24) & 0x0000FFFF) | 01102 (((x << 8) >> 8) & 0xFFFF0000)); 01103 } 01104 01105 01106 #endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */ 01107 01108 01109 /** 01110 * @brief Instance structure for the Q7 FIR filter. 01111 */ 01112 typedef struct 01113 { 01114 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 01115 q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 01116 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 01117 } arm_fir_instance_q7; 01118 01119 /** 01120 * @brief Instance structure for the Q15 FIR filter. 01121 */ 01122 typedef struct 01123 { 01124 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 01125 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 01126 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 01127 } arm_fir_instance_q15; 01128 01129 /** 01130 * @brief Instance structure for the Q31 FIR filter. 01131 */ 01132 typedef struct 01133 { 01134 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 01135 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 01136 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 01137 } arm_fir_instance_q31; 01138 01139 /** 01140 * @brief Instance structure for the floating-point FIR filter. 01141 */ 01142 typedef struct 01143 { 01144 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 01145 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 01146 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 01147 } arm_fir_instance_f32; 01148 01149 01150 /** 01151 * @brief Processing function for the Q7 FIR filter. 01152 * @param[in] *S points to an instance of the Q7 FIR filter structure. 01153 * @param[in] *pSrc points to the block of input data. 01154 * @param[out] *pDst points to the block of output data. 01155 * @param[in] blockSize number of samples to process. 01156 * @return none. 01157 */ 01158 void arm_fir_q7( 01159 const arm_fir_instance_q7 * S, 01160 q7_t * pSrc, 01161 q7_t * pDst, 01162 uint32_t blockSize); 01163 01164 01165 /** 01166 * @brief Initialization function for the Q7 FIR filter. 01167 * @param[in,out] *S points to an instance of the Q7 FIR structure. 01168 * @param[in] numTaps Number of filter coefficients in the filter. 01169 * @param[in] *pCoeffs points to the filter coefficients. 01170 * @param[in] *pState points to the state buffer. 01171 * @param[in] blockSize number of samples that are processed. 01172 * @return none 01173 */ 01174 void arm_fir_init_q7( 01175 arm_fir_instance_q7 * S, 01176 uint16_t numTaps, 01177 q7_t * pCoeffs, 01178 q7_t * pState, 01179 uint32_t blockSize); 01180 01181 01182 /** 01183 * @brief Processing function for the Q15 FIR filter. 01184 * @param[in] *S points to an instance of the Q15 FIR structure. 01185 * @param[in] *pSrc points to the block of input data. 01186 * @param[out] *pDst points to the block of output data. 01187 * @param[in] blockSize number of samples to process. 01188 * @return none. 01189 */ 01190 void arm_fir_q15( 01191 const arm_fir_instance_q15 * S, 01192 q15_t * pSrc, 01193 q15_t * pDst, 01194 uint32_t blockSize); 01195 01196 /** 01197 * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4. 01198 * @param[in] *S points to an instance of the Q15 FIR filter structure. 01199 * @param[in] *pSrc points to the block of input data. 01200 * @param[out] *pDst points to the block of output data. 01201 * @param[in] blockSize number of samples to process. 01202 * @return none. 01203 */ 01204 void arm_fir_fast_q15( 01205 const arm_fir_instance_q15 * S, 01206 q15_t * pSrc, 01207 q15_t * pDst, 01208 uint32_t blockSize); 01209 01210 /** 01211 * @brief Initialization function for the Q15 FIR filter. 01212 * @param[in,out] *S points to an instance of the Q15 FIR filter structure. 01213 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4. 01214 * @param[in] *pCoeffs points to the filter coefficients. 01215 * @param[in] *pState points to the state buffer. 01216 * @param[in] blockSize number of samples that are processed at a time. 01217 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if 01218 * <code>numTaps</code> is not a supported value. 01219 */ 01220 01221 arm_status arm_fir_init_q15( 01222 arm_fir_instance_q15 * S, 01223 uint16_t numTaps, 01224 q15_t * pCoeffs, 01225 q15_t * pState, 01226 uint32_t blockSize); 01227 01228 /** 01229 * @brief Processing function for the Q31 FIR filter. 01230 * @param[in] *S points to an instance of the Q31 FIR filter structure. 01231 * @param[in] *pSrc points to the block of input data. 01232 * @param[out] *pDst points to the block of output data. 01233 * @param[in] blockSize number of samples to process. 01234 * @return none. 01235 */ 01236 void arm_fir_q31( 01237 const arm_fir_instance_q31 * S, 01238 q31_t * pSrc, 01239 q31_t * pDst, 01240 uint32_t blockSize); 01241 01242 /** 01243 * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4. 01244 * @param[in] *S points to an instance of the Q31 FIR structure. 01245 * @param[in] *pSrc points to the block of input data. 01246 * @param[out] *pDst points to the block of output data. 01247 * @param[in] blockSize number of samples to process. 01248 * @return none. 01249 */ 01250 void arm_fir_fast_q31( 01251 const arm_fir_instance_q31 * S, 01252 q31_t * pSrc, 01253 q31_t * pDst, 01254 uint32_t blockSize); 01255 01256 /** 01257 * @brief Initialization function for the Q31 FIR filter. 01258 * @param[in,out] *S points to an instance of the Q31 FIR structure. 01259 * @param[in] numTaps Number of filter coefficients in the filter. 01260 * @param[in] *pCoeffs points to the filter coefficients. 01261 * @param[in] *pState points to the state buffer. 01262 * @param[in] blockSize number of samples that are processed at a time. 01263 * @return none. 01264 */ 01265 void arm_fir_init_q31( 01266 arm_fir_instance_q31 * S, 01267 uint16_t numTaps, 01268 q31_t * pCoeffs, 01269 q31_t * pState, 01270 uint32_t blockSize); 01271 01272 /** 01273 * @brief Processing function for the floating-point FIR filter. 01274 * @param[in] *S points to an instance of the floating-point FIR structure. 01275 * @param[in] *pSrc points to the block of input data. 01276 * @param[out] *pDst points to the block of output data. 01277 * @param[in] blockSize number of samples to process. 01278 * @return none. 01279 */ 01280 void arm_fir_f32( 01281 const arm_fir_instance_f32 * S, 01282 float32_t * pSrc, 01283 float32_t * pDst, 01284 uint32_t blockSize); 01285 01286 /** 01287 * @brief Initialization function for the floating-point FIR filter. 01288 * @param[in,out] *S points to an instance of the floating-point FIR filter structure. 01289 * @param[in] numTaps Number of filter coefficients in the filter. 01290 * @param[in] *pCoeffs points to the filter coefficients. 01291 * @param[in] *pState points to the state buffer. 01292 * @param[in] blockSize number of samples that are processed at a time. 01293 * @return none. 01294 */ 01295 void arm_fir_init_f32( 01296 arm_fir_instance_f32 * S, 01297 uint16_t numTaps, 01298 float32_t * pCoeffs, 01299 float32_t * pState, 01300 uint32_t blockSize); 01301 01302 01303 /** 01304 * @brief Instance structure for the Q15 Biquad cascade filter. 01305 */ 01306 typedef struct 01307 { 01308 int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 01309 q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 01310 q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 01311 int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ 01312 01313 } arm_biquad_casd_df1_inst_q15; 01314 01315 01316 /** 01317 * @brief Instance structure for the Q31 Biquad cascade filter. 01318 */ 01319 typedef struct 01320 { 01321 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 01322 q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 01323 q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 01324 uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ 01325 01326 } arm_biquad_casd_df1_inst_q31; 01327 01328 /** 01329 * @brief Instance structure for the floating-point Biquad cascade filter. 01330 */ 01331 typedef struct 01332 { 01333 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 01334 float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 01335 float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 01336 01337 01338 } arm_biquad_casd_df1_inst_f32; 01339 01340 01341 01342 /** 01343 * @brief Processing function for the Q15 Biquad cascade filter. 01344 * @param[in] *S points to an instance of the Q15 Biquad cascade structure. 01345 * @param[in] *pSrc points to the block of input data. 01346 * @param[out] *pDst points to the block of output data. 01347 * @param[in] blockSize number of samples to process. 01348 * @return none. 01349 */ 01350 01351 void arm_biquad_cascade_df1_q15( 01352 const arm_biquad_casd_df1_inst_q15 * S, 01353 q15_t * pSrc, 01354 q15_t * pDst, 01355 uint32_t blockSize); 01356 01357 /** 01358 * @brief Initialization function for the Q15 Biquad cascade filter. 01359 * @param[in,out] *S points to an instance of the Q15 Biquad cascade structure. 01360 * @param[in] numStages number of 2nd order stages in the filter. 01361 * @param[in] *pCoeffs points to the filter coefficients. 01362 * @param[in] *pState points to the state buffer. 01363 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format 01364 * @return none 01365 */ 01366 01367 void arm_biquad_cascade_df1_init_q15( 01368 arm_biquad_casd_df1_inst_q15 * S, 01369 uint8_t numStages, 01370 q15_t * pCoeffs, 01371 q15_t * pState, 01372 int8_t postShift); 01373 01374 01375 /** 01376 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4. 01377 * @param[in] *S points to an instance of the Q15 Biquad cascade structure. 01378 * @param[in] *pSrc points to the block of input data. 01379 * @param[out] *pDst points to the block of output data. 01380 * @param[in] blockSize number of samples to process. 01381 * @return none. 01382 */ 01383 01384 void arm_biquad_cascade_df1_fast_q15( 01385 const arm_biquad_casd_df1_inst_q15 * S, 01386 q15_t * pSrc, 01387 q15_t * pDst, 01388 uint32_t blockSize); 01389 01390 01391 /** 01392 * @brief Processing function for the Q31 Biquad cascade filter 01393 * @param[in] *S points to an instance of the Q31 Biquad cascade structure. 01394 * @param[in] *pSrc points to the block of input data. 01395 * @param[out] *pDst points to the block of output data. 01396 * @param[in] blockSize number of samples to process. 01397 * @return none. 01398 */ 01399 01400 void arm_biquad_cascade_df1_q31( 01401 const arm_biquad_casd_df1_inst_q31 * S, 01402 q31_t * pSrc, 01403 q31_t * pDst, 01404 uint32_t blockSize); 01405 01406 /** 01407 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4. 01408 * @param[in] *S points to an instance of the Q31 Biquad cascade structure. 01409 * @param[in] *pSrc points to the block of input data. 01410 * @param[out] *pDst points to the block of output data. 01411 * @param[in] blockSize number of samples to process. 01412 * @return none. 01413 */ 01414 01415 void arm_biquad_cascade_df1_fast_q31( 01416 const arm_biquad_casd_df1_inst_q31 * S, 01417 q31_t * pSrc, 01418 q31_t * pDst, 01419 uint32_t blockSize); 01420 01421 /** 01422 * @brief Initialization function for the Q31 Biquad cascade filter. 01423 * @param[in,out] *S points to an instance of the Q31 Biquad cascade structure. 01424 * @param[in] numStages number of 2nd order stages in the filter. 01425 * @param[in] *pCoeffs points to the filter coefficients. 01426 * @param[in] *pState points to the state buffer. 01427 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format 01428 * @return none 01429 */ 01430 01431 void arm_biquad_cascade_df1_init_q31( 01432 arm_biquad_casd_df1_inst_q31 * S, 01433 uint8_t numStages, 01434 q31_t * pCoeffs, 01435 q31_t * pState, 01436 int8_t postShift); 01437 01438 /** 01439 * @brief Processing function for the floating-point Biquad cascade filter. 01440 * @param[in] *S points to an instance of the floating-point Biquad cascade structure. 01441 * @param[in] *pSrc points to the block of input data. 01442 * @param[out] *pDst points to the block of output data. 01443 * @param[in] blockSize number of samples to process. 01444 * @return none. 01445 */ 01446 01447 void arm_biquad_cascade_df1_f32( 01448 const arm_biquad_casd_df1_inst_f32 * S, 01449 float32_t * pSrc, 01450 float32_t * pDst, 01451 uint32_t blockSize); 01452 01453 /** 01454 * @brief Initialization function for the floating-point Biquad cascade filter. 01455 * @param[in,out] *S points to an instance of the floating-point Biquad cascade structure. 01456 * @param[in] numStages number of 2nd order stages in the filter. 01457 * @param[in] *pCoeffs points to the filter coefficients. 01458 * @param[in] *pState points to the state buffer. 01459 * @return none 01460 */ 01461 01462 void arm_biquad_cascade_df1_init_f32( 01463 arm_biquad_casd_df1_inst_f32 * S, 01464 uint8_t numStages, 01465 float32_t * pCoeffs, 01466 float32_t * pState); 01467 01468 01469 /** 01470 * @brief Instance structure for the floating-point matrix structure. 01471 */ 01472 01473 typedef struct 01474 { 01475 uint16_t numRows; /**< number of rows of the matrix. */ 01476 uint16_t numCols; /**< number of columns of the matrix. */ 01477 float32_t *pData; /**< points to the data of the matrix. */ 01478 } arm_matrix_instance_f32; 01479 01480 /** 01481 * @brief Instance structure for the Q15 matrix structure. 01482 */ 01483 01484 typedef struct 01485 { 01486 uint16_t numRows; /**< number of rows of the matrix. */ 01487 uint16_t numCols; /**< number of columns of the matrix. */ 01488 q15_t *pData; /**< points to the data of the matrix. */ 01489 01490 } arm_matrix_instance_q15; 01491 01492 /** 01493 * @brief Instance structure for the Q31 matrix structure. 01494 */ 01495 01496 typedef struct 01497 { 01498 uint16_t numRows; /**< number of rows of the matrix. */ 01499 uint16_t numCols; /**< number of columns of the matrix. */ 01500 q31_t *pData; /**< points to the data of the matrix. */ 01501 01502 } arm_matrix_instance_q31; 01503 01504 01505 01506 /** 01507 * @brief Floating-point matrix addition. 01508 * @param[in] *pSrcA points to the first input matrix structure 01509 * @param[in] *pSrcB points to the second input matrix structure 01510 * @param[out] *pDst points to output matrix structure 01511 * @return The function returns either 01512 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01513 */ 01514 01515 arm_status arm_mat_add_f32( 01516 const arm_matrix_instance_f32 * pSrcA, 01517 const arm_matrix_instance_f32 * pSrcB, 01518 arm_matrix_instance_f32 * pDst); 01519 01520 /** 01521 * @brief Q15 matrix addition. 01522 * @param[in] *pSrcA points to the first input matrix structure 01523 * @param[in] *pSrcB points to the second input matrix structure 01524 * @param[out] *pDst points to output matrix structure 01525 * @return The function returns either 01526 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01527 */ 01528 01529 arm_status arm_mat_add_q15( 01530 const arm_matrix_instance_q15 * pSrcA, 01531 const arm_matrix_instance_q15 * pSrcB, 01532 arm_matrix_instance_q15 * pDst); 01533 01534 /** 01535 * @brief Q31 matrix addition. 01536 * @param[in] *pSrcA points to the first input matrix structure 01537 * @param[in] *pSrcB points to the second input matrix structure 01538 * @param[out] *pDst points to output matrix structure 01539 * @return The function returns either 01540 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01541 */ 01542 01543 arm_status arm_mat_add_q31( 01544 const arm_matrix_instance_q31 * pSrcA, 01545 const arm_matrix_instance_q31 * pSrcB, 01546 arm_matrix_instance_q31 * pDst); 01547 01548 /** 01549 * @brief Floating-point, complex, matrix multiplication. 01550 * @param[in] *pSrcA points to the first input matrix structure 01551 * @param[in] *pSrcB points to the second input matrix structure 01552 * @param[out] *pDst points to output matrix structure 01553 * @return The function returns either 01554 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01555 */ 01556 01557 arm_status arm_mat_cmplx_mult_f32( 01558 const arm_matrix_instance_f32 * pSrcA, 01559 const arm_matrix_instance_f32 * pSrcB, 01560 arm_matrix_instance_f32 * pDst); 01561 01562 /** 01563 * @brief Q15, complex, matrix multiplication. 01564 * @param[in] *pSrcA points to the first input matrix structure 01565 * @param[in] *pSrcB points to the second input matrix structure 01566 * @param[out] *pDst points to output matrix structure 01567 * @return The function returns either 01568 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01569 */ 01570 01571 arm_status arm_mat_cmplx_mult_q15( 01572 const arm_matrix_instance_q15 * pSrcA, 01573 const arm_matrix_instance_q15 * pSrcB, 01574 arm_matrix_instance_q15 * pDst, 01575 q15_t * pScratch); 01576 01577 /** 01578 * @brief Q31, complex, matrix multiplication. 01579 * @param[in] *pSrcA points to the first input matrix structure 01580 * @param[in] *pSrcB points to the second input matrix structure 01581 * @param[out] *pDst points to output matrix structure 01582 * @return The function returns either 01583 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01584 */ 01585 01586 arm_status arm_mat_cmplx_mult_q31( 01587 const arm_matrix_instance_q31 * pSrcA, 01588 const arm_matrix_instance_q31 * pSrcB, 01589 arm_matrix_instance_q31 * pDst); 01590 01591 01592 /** 01593 * @brief Floating-point matrix transpose. 01594 * @param[in] *pSrc points to the input matrix 01595 * @param[out] *pDst points to the output matrix 01596 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> 01597 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01598 */ 01599 01600 arm_status arm_mat_trans_f32( 01601 const arm_matrix_instance_f32 * pSrc, 01602 arm_matrix_instance_f32 * pDst); 01603 01604 01605 /** 01606 * @brief Q15 matrix transpose. 01607 * @param[in] *pSrc points to the input matrix 01608 * @param[out] *pDst points to the output matrix 01609 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> 01610 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01611 */ 01612 01613 arm_status arm_mat_trans_q15( 01614 const arm_matrix_instance_q15 * pSrc, 01615 arm_matrix_instance_q15 * pDst); 01616 01617 /** 01618 * @brief Q31 matrix transpose. 01619 * @param[in] *pSrc points to the input matrix 01620 * @param[out] *pDst points to the output matrix 01621 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code> 01622 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01623 */ 01624 01625 arm_status arm_mat_trans_q31( 01626 const arm_matrix_instance_q31 * pSrc, 01627 arm_matrix_instance_q31 * pDst); 01628 01629 01630 /** 01631 * @brief Floating-point matrix multiplication 01632 * @param[in] *pSrcA points to the first input matrix structure 01633 * @param[in] *pSrcB points to the second input matrix structure 01634 * @param[out] *pDst points to output matrix structure 01635 * @return The function returns either 01636 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01637 */ 01638 01639 arm_status arm_mat_mult_f32( 01640 const arm_matrix_instance_f32 * pSrcA, 01641 const arm_matrix_instance_f32 * pSrcB, 01642 arm_matrix_instance_f32 * pDst); 01643 01644 /** 01645 * @brief Q15 matrix multiplication 01646 * @param[in] *pSrcA points to the first input matrix structure 01647 * @param[in] *pSrcB points to the second input matrix structure 01648 * @param[out] *pDst points to output matrix structure 01649 * @param[in] *pState points to the array for storing intermediate results 01650 * @return The function returns either 01651 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01652 */ 01653 01654 arm_status arm_mat_mult_q15( 01655 const arm_matrix_instance_q15 * pSrcA, 01656 const arm_matrix_instance_q15 * pSrcB, 01657 arm_matrix_instance_q15 * pDst, 01658 q15_t * pState); 01659 01660 /** 01661 * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4 01662 * @param[in] *pSrcA points to the first input matrix structure 01663 * @param[in] *pSrcB points to the second input matrix structure 01664 * @param[out] *pDst points to output matrix structure 01665 * @param[in] *pState points to the array for storing intermediate results 01666 * @return The function returns either 01667 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01668 */ 01669 01670 arm_status arm_mat_mult_fast_q15( 01671 const arm_matrix_instance_q15 * pSrcA, 01672 const arm_matrix_instance_q15 * pSrcB, 01673 arm_matrix_instance_q15 * pDst, 01674 q15_t * pState); 01675 01676 /** 01677 * @brief Q31 matrix multiplication 01678 * @param[in] *pSrcA points to the first input matrix structure 01679 * @param[in] *pSrcB points to the second input matrix structure 01680 * @param[out] *pDst points to output matrix structure 01681 * @return The function returns either 01682 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01683 */ 01684 01685 arm_status arm_mat_mult_q31( 01686 const arm_matrix_instance_q31 * pSrcA, 01687 const arm_matrix_instance_q31 * pSrcB, 01688 arm_matrix_instance_q31 * pDst); 01689 01690 /** 01691 * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4 01692 * @param[in] *pSrcA points to the first input matrix structure 01693 * @param[in] *pSrcB points to the second input matrix structure 01694 * @param[out] *pDst points to output matrix structure 01695 * @return The function returns either 01696 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01697 */ 01698 01699 arm_status arm_mat_mult_fast_q31( 01700 const arm_matrix_instance_q31 * pSrcA, 01701 const arm_matrix_instance_q31 * pSrcB, 01702 arm_matrix_instance_q31 * pDst); 01703 01704 01705 /** 01706 * @brief Floating-point matrix subtraction 01707 * @param[in] *pSrcA points to the first input matrix structure 01708 * @param[in] *pSrcB points to the second input matrix structure 01709 * @param[out] *pDst points to output matrix structure 01710 * @return The function returns either 01711 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01712 */ 01713 01714 arm_status arm_mat_sub_f32( 01715 const arm_matrix_instance_f32 * pSrcA, 01716 const arm_matrix_instance_f32 * pSrcB, 01717 arm_matrix_instance_f32 * pDst); 01718 01719 /** 01720 * @brief Q15 matrix subtraction 01721 * @param[in] *pSrcA points to the first input matrix structure 01722 * @param[in] *pSrcB points to the second input matrix structure 01723 * @param[out] *pDst points to output matrix structure 01724 * @return The function returns either 01725 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01726 */ 01727 01728 arm_status arm_mat_sub_q15( 01729 const arm_matrix_instance_q15 * pSrcA, 01730 const arm_matrix_instance_q15 * pSrcB, 01731 arm_matrix_instance_q15 * pDst); 01732 01733 /** 01734 * @brief Q31 matrix subtraction 01735 * @param[in] *pSrcA points to the first input matrix structure 01736 * @param[in] *pSrcB points to the second input matrix structure 01737 * @param[out] *pDst points to output matrix structure 01738 * @return The function returns either 01739 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01740 */ 01741 01742 arm_status arm_mat_sub_q31( 01743 const arm_matrix_instance_q31 * pSrcA, 01744 const arm_matrix_instance_q31 * pSrcB, 01745 arm_matrix_instance_q31 * pDst); 01746 01747 /** 01748 * @brief Floating-point matrix scaling. 01749 * @param[in] *pSrc points to the input matrix 01750 * @param[in] scale scale factor 01751 * @param[out] *pDst points to the output matrix 01752 * @return The function returns either 01753 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01754 */ 01755 01756 arm_status arm_mat_scale_f32( 01757 const arm_matrix_instance_f32 * pSrc, 01758 float32_t scale, 01759 arm_matrix_instance_f32 * pDst); 01760 01761 /** 01762 * @brief Q15 matrix scaling. 01763 * @param[in] *pSrc points to input matrix 01764 * @param[in] scaleFract fractional portion of the scale factor 01765 * @param[in] shift number of bits to shift the result by 01766 * @param[out] *pDst points to output matrix 01767 * @return The function returns either 01768 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01769 */ 01770 01771 arm_status arm_mat_scale_q15( 01772 const arm_matrix_instance_q15 * pSrc, 01773 q15_t scaleFract, 01774 int32_t shift, 01775 arm_matrix_instance_q15 * pDst); 01776 01777 /** 01778 * @brief Q31 matrix scaling. 01779 * @param[in] *pSrc points to input matrix 01780 * @param[in] scaleFract fractional portion of the scale factor 01781 * @param[in] shift number of bits to shift the result by 01782 * @param[out] *pDst points to output matrix structure 01783 * @return The function returns either 01784 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking. 01785 */ 01786 01787 arm_status arm_mat_scale_q31( 01788 const arm_matrix_instance_q31 * pSrc, 01789 q31_t scaleFract, 01790 int32_t shift, 01791 arm_matrix_instance_q31 * pDst); 01792 01793 01794 /** 01795 * @brief Q31 matrix initialization. 01796 * @param[in,out] *S points to an instance of the floating-point matrix structure. 01797 * @param[in] nRows number of rows in the matrix. 01798 * @param[in] nColumns number of columns in the matrix. 01799 * @param[in] *pData points to the matrix data array. 01800 * @return none 01801 */ 01802 01803 void arm_mat_init_q31( 01804 arm_matrix_instance_q31 * S, 01805 uint16_t nRows, 01806 uint16_t nColumns, 01807 q31_t * pData); 01808 01809 /** 01810 * @brief Q15 matrix initialization. 01811 * @param[in,out] *S points to an instance of the floating-point matrix structure. 01812 * @param[in] nRows number of rows in the matrix. 01813 * @param[in] nColumns number of columns in the matrix. 01814 * @param[in] *pData points to the matrix data array. 01815 * @return none 01816 */ 01817 01818 void arm_mat_init_q15( 01819 arm_matrix_instance_q15 * S, 01820 uint16_t nRows, 01821 uint16_t nColumns, 01822 q15_t * pData); 01823 01824 /** 01825 * @brief Floating-point matrix initialization. 01826 * @param[in,out] *S points to an instance of the floating-point matrix structure. 01827 * @param[in] nRows number of rows in the matrix. 01828 * @param[in] nColumns number of columns in the matrix. 01829 * @param[in] *pData points to the matrix data array. 01830 * @return none 01831 */ 01832 01833 void arm_mat_init_f32( 01834 arm_matrix_instance_f32 * S, 01835 uint16_t nRows, 01836 uint16_t nColumns, 01837 float32_t * pData); 01838 01839 01840 01841 /** 01842 * @brief Instance structure for the Q15 PID Control. 01843 */ 01844 typedef struct 01845 { 01846 q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ 01847 #ifdef ARM_MATH_CM0_FAMILY 01848 q15_t A1; 01849 q15_t A2; 01850 #else 01851 q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/ 01852 #endif 01853 q15_t state[3]; /**< The state array of length 3. */ 01854 q15_t Kp; /**< The proportional gain. */ 01855 q15_t Ki; /**< The integral gain. */ 01856 q15_t Kd; /**< The derivative gain. */ 01857 } arm_pid_instance_q15; 01858 01859 /** 01860 * @brief Instance structure for the Q31 PID Control. 01861 */ 01862 typedef struct 01863 { 01864 q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ 01865 q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ 01866 q31_t A2; /**< The derived gain, A2 = Kd . */ 01867 q31_t state[3]; /**< The state array of length 3. */ 01868 q31_t Kp; /**< The proportional gain. */ 01869 q31_t Ki; /**< The integral gain. */ 01870 q31_t Kd; /**< The derivative gain. */ 01871 01872 } arm_pid_instance_q31; 01873 01874 /** 01875 * @brief Instance structure for the floating-point PID Control. 01876 */ 01877 typedef struct 01878 { 01879 float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ 01880 float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ 01881 float32_t A2; /**< The derived gain, A2 = Kd . */ 01882 float32_t state[3]; /**< The state array of length 3. */ 01883 float32_t Kp; /**< The proportional gain. */ 01884 float32_t Ki; /**< The integral gain. */ 01885 float32_t Kd; /**< The derivative gain. */ 01886 } arm_pid_instance_f32; 01887 01888 01889 01890 /** 01891 * @brief Initialization function for the floating-point PID Control. 01892 * @param[in,out] *S points to an instance of the PID structure. 01893 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 01894 * @return none. 01895 */ 01896 void arm_pid_init_f32( 01897 arm_pid_instance_f32 * S, 01898 int32_t resetStateFlag); 01899 01900 /** 01901 * @brief Reset function for the floating-point PID Control. 01902 * @param[in,out] *S is an instance of the floating-point PID Control structure 01903 * @return none 01904 */ 01905 void arm_pid_reset_f32( 01906 arm_pid_instance_f32 * S); 01907 01908 01909 /** 01910 * @brief Initialization function for the Q31 PID Control. 01911 * @param[in,out] *S points to an instance of the Q15 PID structure. 01912 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 01913 * @return none. 01914 */ 01915 void arm_pid_init_q31( 01916 arm_pid_instance_q31 * S, 01917 int32_t resetStateFlag); 01918 01919 01920 /** 01921 * @brief Reset function for the Q31 PID Control. 01922 * @param[in,out] *S points to an instance of the Q31 PID Control structure 01923 * @return none 01924 */ 01925 01926 void arm_pid_reset_q31( 01927 arm_pid_instance_q31 * S); 01928 01929 /** 01930 * @brief Initialization function for the Q15 PID Control. 01931 * @param[in,out] *S points to an instance of the Q15 PID structure. 01932 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. 01933 * @return none. 01934 */ 01935 void arm_pid_init_q15( 01936 arm_pid_instance_q15 * S, 01937 int32_t resetStateFlag); 01938 01939 /** 01940 * @brief Reset function for the Q15 PID Control. 01941 * @param[in,out] *S points to an instance of the q15 PID Control structure 01942 * @return none 01943 */ 01944 void arm_pid_reset_q15( 01945 arm_pid_instance_q15 * S); 01946 01947 01948 /** 01949 * @brief Instance structure for the floating-point Linear Interpolate function. 01950 */ 01951 typedef struct 01952 { 01953 uint32_t nValues; /**< nValues */ 01954 float32_t x1; /**< x1 */ 01955 float32_t xSpacing; /**< xSpacing */ 01956 float32_t *pYData; /**< pointer to the table of Y values */ 01957 } arm_linear_interp_instance_f32; 01958 01959 /** 01960 * @brief Instance structure for the floating-point bilinear interpolation function. 01961 */ 01962 01963 typedef struct 01964 { 01965 uint16_t numRows; /**< number of rows in the data table. */ 01966 uint16_t numCols; /**< number of columns in the data table. */ 01967 float32_t *pData; /**< points to the data table. */ 01968 } arm_bilinear_interp_instance_f32; 01969 01970 /** 01971 * @brief Instance structure for the Q31 bilinear interpolation function. 01972 */ 01973 01974 typedef struct 01975 { 01976 uint16_t numRows; /**< number of rows in the data table. */ 01977 uint16_t numCols; /**< number of columns in the data table. */ 01978 q31_t *pData; /**< points to the data table. */ 01979 } arm_bilinear_interp_instance_q31; 01980 01981 /** 01982 * @brief Instance structure for the Q15 bilinear interpolation function. 01983 */ 01984 01985 typedef struct 01986 { 01987 uint16_t numRows; /**< number of rows in the data table. */ 01988 uint16_t numCols; /**< number of columns in the data table. */ 01989 q15_t *pData; /**< points to the data table. */ 01990 } arm_bilinear_interp_instance_q15; 01991 01992 /** 01993 * @brief Instance structure for the Q15 bilinear interpolation function. 01994 */ 01995 01996 typedef struct 01997 { 01998 uint16_t numRows; /**< number of rows in the data table. */ 01999 uint16_t numCols; /**< number of columns in the data table. */ 02000 q7_t *pData; /**< points to the data table. */ 02001 } arm_bilinear_interp_instance_q7; 02002 02003 02004 /** 02005 * @brief Q7 vector multiplication. 02006 * @param[in] *pSrcA points to the first input vector 02007 * @param[in] *pSrcB points to the second input vector 02008 * @param[out] *pDst points to the output vector 02009 * @param[in] blockSize number of samples in each vector 02010 * @return none. 02011 */ 02012 02013 void arm_mult_q7( 02014 q7_t * pSrcA, 02015 q7_t * pSrcB, 02016 q7_t * pDst, 02017 uint32_t blockSize); 02018 02019 /** 02020 * @brief Q15 vector multiplication. 02021 * @param[in] *pSrcA points to the first input vector 02022 * @param[in] *pSrcB points to the second input vector 02023 * @param[out] *pDst points to the output vector 02024 * @param[in] blockSize number of samples in each vector 02025 * @return none. 02026 */ 02027 02028 void arm_mult_q15( 02029 q15_t * pSrcA, 02030 q15_t * pSrcB, 02031 q15_t * pDst, 02032 uint32_t blockSize); 02033 02034 /** 02035 * @brief Q31 vector multiplication. 02036 * @param[in] *pSrcA points to the first input vector 02037 * @param[in] *pSrcB points to the second input vector 02038 * @param[out] *pDst points to the output vector 02039 * @param[in] blockSize number of samples in each vector 02040 * @return none. 02041 */ 02042 02043 void arm_mult_q31( 02044 q31_t * pSrcA, 02045 q31_t * pSrcB, 02046 q31_t * pDst, 02047 uint32_t blockSize); 02048 02049 /** 02050 * @brief Floating-point vector multiplication. 02051 * @param[in] *pSrcA points to the first input vector 02052 * @param[in] *pSrcB points to the second input vector 02053 * @param[out] *pDst points to the output vector 02054 * @param[in] blockSize number of samples in each vector 02055 * @return none. 02056 */ 02057 02058 void arm_mult_f32( 02059 float32_t * pSrcA, 02060 float32_t * pSrcB, 02061 float32_t * pDst, 02062 uint32_t blockSize); 02063 02064 02065 02066 02067 02068 02069 /** 02070 * @brief Instance structure for the Q15 CFFT/CIFFT function. 02071 */ 02072 02073 typedef struct 02074 { 02075 uint16_t fftLen; /**< length of the FFT. */ 02076 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 02077 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 02078 q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */ 02079 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02080 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02081 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 02082 } arm_cfft_radix2_instance_q15; 02083 02084 arm_status arm_cfft_radix2_init_q15( 02085 arm_cfft_radix2_instance_q15 * S, 02086 uint16_t fftLen, 02087 uint8_t ifftFlag, 02088 uint8_t bitReverseFlag); 02089 02090 void arm_cfft_radix2_q15( 02091 const arm_cfft_radix2_instance_q15 * S, 02092 q15_t * pSrc); 02093 02094 02095 02096 /** 02097 * @brief Instance structure for the Q15 CFFT/CIFFT function. 02098 */ 02099 02100 typedef struct 02101 { 02102 uint16_t fftLen; /**< length of the FFT. */ 02103 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 02104 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 02105 q15_t *pTwiddle; /**< points to the twiddle factor table. */ 02106 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02107 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02108 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 02109 } arm_cfft_radix4_instance_q15; 02110 02111 arm_status arm_cfft_radix4_init_q15( 02112 arm_cfft_radix4_instance_q15 * S, 02113 uint16_t fftLen, 02114 uint8_t ifftFlag, 02115 uint8_t bitReverseFlag); 02116 02117 void arm_cfft_radix4_q15( 02118 const arm_cfft_radix4_instance_q15 * S, 02119 q15_t * pSrc); 02120 02121 /** 02122 * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function. 02123 */ 02124 02125 typedef struct 02126 { 02127 uint16_t fftLen; /**< length of the FFT. */ 02128 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 02129 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 02130 q31_t *pTwiddle; /**< points to the Twiddle factor table. */ 02131 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02132 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02133 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 02134 } arm_cfft_radix2_instance_q31; 02135 02136 arm_status arm_cfft_radix2_init_q31( 02137 arm_cfft_radix2_instance_q31 * S, 02138 uint16_t fftLen, 02139 uint8_t ifftFlag, 02140 uint8_t bitReverseFlag); 02141 02142 void arm_cfft_radix2_q31( 02143 const arm_cfft_radix2_instance_q31 * S, 02144 q31_t * pSrc); 02145 02146 /** 02147 * @brief Instance structure for the Q31 CFFT/CIFFT function. 02148 */ 02149 02150 typedef struct 02151 { 02152 uint16_t fftLen; /**< length of the FFT. */ 02153 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 02154 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 02155 q31_t *pTwiddle; /**< points to the twiddle factor table. */ 02156 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02157 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02158 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 02159 } arm_cfft_radix4_instance_q31; 02160 02161 void arm_cfft_radix4_q31( 02162 const arm_cfft_radix4_instance_q31 * S, 02163 q31_t * pSrc); 02164 02165 arm_status arm_cfft_radix4_init_q31( 02166 arm_cfft_radix4_instance_q31 * S, 02167 uint16_t fftLen, 02168 uint8_t ifftFlag, 02169 uint8_t bitReverseFlag); 02170 02171 /** 02172 * @brief Instance structure for the floating-point CFFT/CIFFT function. 02173 */ 02174 02175 typedef struct 02176 { 02177 uint16_t fftLen; /**< length of the FFT. */ 02178 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 02179 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 02180 float32_t *pTwiddle; /**< points to the Twiddle factor table. */ 02181 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02182 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02183 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 02184 float32_t onebyfftLen; /**< value of 1/fftLen. */ 02185 } arm_cfft_radix2_instance_f32; 02186 02187 /* Deprecated */ 02188 arm_status arm_cfft_radix2_init_f32( 02189 arm_cfft_radix2_instance_f32 * S, 02190 uint16_t fftLen, 02191 uint8_t ifftFlag, 02192 uint8_t bitReverseFlag); 02193 02194 /* Deprecated */ 02195 void arm_cfft_radix2_f32( 02196 const arm_cfft_radix2_instance_f32 * S, 02197 float32_t * pSrc); 02198 02199 /** 02200 * @brief Instance structure for the floating-point CFFT/CIFFT function. 02201 */ 02202 02203 typedef struct 02204 { 02205 uint16_t fftLen; /**< length of the FFT. */ 02206 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ 02207 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ 02208 float32_t *pTwiddle; /**< points to the Twiddle factor table. */ 02209 uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02210 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02211 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ 02212 float32_t onebyfftLen; /**< value of 1/fftLen. */ 02213 } arm_cfft_radix4_instance_f32; 02214 02215 /* Deprecated */ 02216 arm_status arm_cfft_radix4_init_f32( 02217 arm_cfft_radix4_instance_f32 * S, 02218 uint16_t fftLen, 02219 uint8_t ifftFlag, 02220 uint8_t bitReverseFlag); 02221 02222 /* Deprecated */ 02223 void arm_cfft_radix4_f32( 02224 const arm_cfft_radix4_instance_f32 * S, 02225 float32_t * pSrc); 02226 02227 /** 02228 * @brief Instance structure for the floating-point CFFT/CIFFT function. 02229 */ 02230 02231 typedef struct 02232 { 02233 uint16_t fftLen; /**< length of the FFT. */ 02234 const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ 02235 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ 02236 uint16_t bitRevLength; /**< bit reversal table length. */ 02237 } arm_cfft_instance_f32; 02238 02239 void arm_cfft_f32( 02240 const arm_cfft_instance_f32 * S, 02241 float32_t * p1, 02242 uint8_t ifftFlag, 02243 uint8_t bitReverseFlag); 02244 02245 /** 02246 * @brief Instance structure for the Q15 RFFT/RIFFT function. 02247 */ 02248 02249 typedef struct 02250 { 02251 uint32_t fftLenReal; /**< length of the real FFT. */ 02252 uint32_t fftLenBy2; /**< length of the complex FFT. */ 02253 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ 02254 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ 02255 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02256 q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ 02257 q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ 02258 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */ 02259 } arm_rfft_instance_q15; 02260 02261 arm_status arm_rfft_init_q15( 02262 arm_rfft_instance_q15 * S, 02263 arm_cfft_radix4_instance_q15 * S_CFFT, 02264 uint32_t fftLenReal, 02265 uint32_t ifftFlagR, 02266 uint32_t bitReverseFlag); 02267 02268 void arm_rfft_q15( 02269 const arm_rfft_instance_q15 * S, 02270 q15_t * pSrc, 02271 q15_t * pDst); 02272 02273 /** 02274 * @brief Instance structure for the Q31 RFFT/RIFFT function. 02275 */ 02276 02277 typedef struct 02278 { 02279 uint32_t fftLenReal; /**< length of the real FFT. */ 02280 uint32_t fftLenBy2; /**< length of the complex FFT. */ 02281 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ 02282 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ 02283 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02284 q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ 02285 q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ 02286 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */ 02287 } arm_rfft_instance_q31; 02288 02289 arm_status arm_rfft_init_q31( 02290 arm_rfft_instance_q31 * S, 02291 arm_cfft_radix4_instance_q31 * S_CFFT, 02292 uint32_t fftLenReal, 02293 uint32_t ifftFlagR, 02294 uint32_t bitReverseFlag); 02295 02296 void arm_rfft_q31( 02297 const arm_rfft_instance_q31 * S, 02298 q31_t * pSrc, 02299 q31_t * pDst); 02300 02301 /** 02302 * @brief Instance structure for the floating-point RFFT/RIFFT function. 02303 */ 02304 02305 typedef struct 02306 { 02307 uint32_t fftLenReal; /**< length of the real FFT. */ 02308 uint16_t fftLenBy2; /**< length of the complex FFT. */ 02309 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ 02310 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ 02311 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ 02312 float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ 02313 float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ 02314 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ 02315 } arm_rfft_instance_f32; 02316 02317 arm_status arm_rfft_init_f32( 02318 arm_rfft_instance_f32 * S, 02319 arm_cfft_radix4_instance_f32 * S_CFFT, 02320 uint32_t fftLenReal, 02321 uint32_t ifftFlagR, 02322 uint32_t bitReverseFlag); 02323 02324 void arm_rfft_f32( 02325 const arm_rfft_instance_f32 * S, 02326 float32_t * pSrc, 02327 float32_t * pDst); 02328 02329 /** 02330 * @brief Instance structure for the floating-point RFFT/RIFFT function. 02331 */ 02332 02333 typedef struct 02334 { 02335 arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */ 02336 uint16_t fftLenRFFT; /**< length of the real sequence */ 02337 float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */ 02338 } arm_rfft_fast_instance_f32 ; 02339 02340 arm_status arm_rfft_fast_init_f32 ( 02341 arm_rfft_fast_instance_f32 * S, 02342 uint16_t fftLen); 02343 02344 void arm_rfft_fast_f32( 02345 arm_rfft_fast_instance_f32 * S, 02346 float32_t * p, float32_t * pOut, 02347 uint8_t ifftFlag); 02348 02349 /** 02350 * @brief Instance structure for the floating-point DCT4/IDCT4 function. 02351 */ 02352 02353 typedef struct 02354 { 02355 uint16_t N; /**< length of the DCT4. */ 02356 uint16_t Nby2; /**< half of the length of the DCT4. */ 02357 float32_t normalize; /**< normalizing factor. */ 02358 float32_t *pTwiddle; /**< points to the twiddle factor table. */ 02359 float32_t *pCosFactor; /**< points to the cosFactor table. */ 02360 arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */ 02361 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ 02362 } arm_dct4_instance_f32; 02363 02364 /** 02365 * @brief Initialization function for the floating-point DCT4/IDCT4. 02366 * @param[in,out] *S points to an instance of floating-point DCT4/IDCT4 structure. 02367 * @param[in] *S_RFFT points to an instance of floating-point RFFT/RIFFT structure. 02368 * @param[in] *S_CFFT points to an instance of floating-point CFFT/CIFFT structure. 02369 * @param[in] N length of the DCT4. 02370 * @param[in] Nby2 half of the length of the DCT4. 02371 * @param[in] normalize normalizing factor. 02372 * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length. 02373 */ 02374 02375 arm_status arm_dct4_init_f32( 02376 arm_dct4_instance_f32 * S, 02377 arm_rfft_instance_f32 * S_RFFT, 02378 arm_cfft_radix4_instance_f32 * S_CFFT, 02379 uint16_t N, 02380 uint16_t Nby2, 02381 float32_t normalize); 02382 02383 /** 02384 * @brief Processing function for the floating-point DCT4/IDCT4. 02385 * @param[in] *S points to an instance of the floating-point DCT4/IDCT4 structure. 02386 * @param[in] *pState points to state buffer. 02387 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. 02388 * @return none. 02389 */ 02390 02391 void arm_dct4_f32( 02392 const arm_dct4_instance_f32 * S, 02393 float32_t * pState, 02394 float32_t * pInlineBuffer); 02395 02396 /** 02397 * @brief Instance structure for the Q31 DCT4/IDCT4 function. 02398 */ 02399 02400 typedef struct 02401 { 02402 uint16_t N; /**< length of the DCT4. */ 02403 uint16_t Nby2; /**< half of the length of the DCT4. */ 02404 q31_t normalize; /**< normalizing factor. */ 02405 q31_t *pTwiddle; /**< points to the twiddle factor table. */ 02406 q31_t *pCosFactor; /**< points to the cosFactor table. */ 02407 arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */ 02408 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */ 02409 } arm_dct4_instance_q31; 02410 02411 /** 02412 * @brief Initialization function for the Q31 DCT4/IDCT4. 02413 * @param[in,out] *S points to an instance of Q31 DCT4/IDCT4 structure. 02414 * @param[in] *S_RFFT points to an instance of Q31 RFFT/RIFFT structure 02415 * @param[in] *S_CFFT points to an instance of Q31 CFFT/CIFFT structure 02416 * @param[in] N length of the DCT4. 02417 * @param[in] Nby2 half of the length of the DCT4. 02418 * @param[in] normalize normalizing factor. 02419 * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length. 02420 */ 02421 02422 arm_status arm_dct4_init_q31( 02423 arm_dct4_instance_q31 * S, 02424 arm_rfft_instance_q31 * S_RFFT, 02425 arm_cfft_radix4_instance_q31 * S_CFFT, 02426 uint16_t N, 02427 uint16_t Nby2, 02428 q31_t normalize); 02429 02430 /** 02431 * @brief Processing function for the Q31 DCT4/IDCT4. 02432 * @param[in] *S points to an instance of the Q31 DCT4 structure. 02433 * @param[in] *pState points to state buffer. 02434 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. 02435 * @return none. 02436 */ 02437 02438 void arm_dct4_q31( 02439 const arm_dct4_instance_q31 * S, 02440 q31_t * pState, 02441 q31_t * pInlineBuffer); 02442 02443 /** 02444 * @brief Instance structure for the Q15 DCT4/IDCT4 function. 02445 */ 02446 02447 typedef struct 02448 { 02449 uint16_t N; /**< length of the DCT4. */ 02450 uint16_t Nby2; /**< half of the length of the DCT4. */ 02451 q15_t normalize; /**< normalizing factor. */ 02452 q15_t *pTwiddle; /**< points to the twiddle factor table. */ 02453 q15_t *pCosFactor; /**< points to the cosFactor table. */ 02454 arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */ 02455 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */ 02456 } arm_dct4_instance_q15; 02457 02458 /** 02459 * @brief Initialization function for the Q15 DCT4/IDCT4. 02460 * @param[in,out] *S points to an instance of Q15 DCT4/IDCT4 structure. 02461 * @param[in] *S_RFFT points to an instance of Q15 RFFT/RIFFT structure. 02462 * @param[in] *S_CFFT points to an instance of Q15 CFFT/CIFFT structure. 02463 * @param[in] N length of the DCT4. 02464 * @param[in] Nby2 half of the length of the DCT4. 02465 * @param[in] normalize normalizing factor. 02466 * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length. 02467 */ 02468 02469 arm_status arm_dct4_init_q15( 02470 arm_dct4_instance_q15 * S, 02471 arm_rfft_instance_q15 * S_RFFT, 02472 arm_cfft_radix4_instance_q15 * S_CFFT, 02473 uint16_t N, 02474 uint16_t Nby2, 02475 q15_t normalize); 02476 02477 /** 02478 * @brief Processing function for the Q15 DCT4/IDCT4. 02479 * @param[in] *S points to an instance of the Q15 DCT4 structure. 02480 * @param[in] *pState points to state buffer. 02481 * @param[in,out] *pInlineBuffer points to the in-place input and output buffer. 02482 * @return none. 02483 */ 02484 02485 void arm_dct4_q15( 02486 const arm_dct4_instance_q15 * S, 02487 q15_t * pState, 02488 q15_t * pInlineBuffer); 02489 02490 /** 02491 * @brief Floating-point vector addition. 02492 * @param[in] *pSrcA points to the first input vector 02493 * @param[in] *pSrcB points to the second input vector 02494 * @param[out] *pDst points to the output vector 02495 * @param[in] blockSize number of samples in each vector 02496 * @return none. 02497 */ 02498 02499 void arm_add_f32( 02500 float32_t * pSrcA, 02501 float32_t * pSrcB, 02502 float32_t * pDst, 02503 uint32_t blockSize); 02504 02505 /** 02506 * @brief Q7 vector addition. 02507 * @param[in] *pSrcA points to the first input vector 02508 * @param[in] *pSrcB points to the second input vector 02509 * @param[out] *pDst points to the output vector 02510 * @param[in] blockSize number of samples in each vector 02511 * @return none. 02512 */ 02513 02514 void arm_add_q7( 02515 q7_t * pSrcA, 02516 q7_t * pSrcB, 02517 q7_t * pDst, 02518 uint32_t blockSize); 02519 02520 /** 02521 * @brief Q15 vector addition. 02522 * @param[in] *pSrcA points to the first input vector 02523 * @param[in] *pSrcB points to the second input vector 02524 * @param[out] *pDst points to the output vector 02525 * @param[in] blockSize number of samples in each vector 02526 * @return none. 02527 */ 02528 02529 void arm_add_q15( 02530 q15_t * pSrcA, 02531 q15_t * pSrcB, 02532 q15_t * pDst, 02533 uint32_t blockSize); 02534 02535 /** 02536 * @brief Q31 vector addition. 02537 * @param[in] *pSrcA points to the first input vector 02538 * @param[in] *pSrcB points to the second input vector 02539 * @param[out] *pDst points to the output vector 02540 * @param[in] blockSize number of samples in each vector 02541 * @return none. 02542 */ 02543 02544 void arm_add_q31( 02545 q31_t * pSrcA, 02546 q31_t * pSrcB, 02547 q31_t * pDst, 02548 uint32_t blockSize); 02549 02550 /** 02551 * @brief Floating-point vector subtraction. 02552 * @param[in] *pSrcA points to the first input vector 02553 * @param[in] *pSrcB points to the second input vector 02554 * @param[out] *pDst points to the output vector 02555 * @param[in] blockSize number of samples in each vector 02556 * @return none. 02557 */ 02558 02559 void arm_sub_f32( 02560 float32_t * pSrcA, 02561 float32_t * pSrcB, 02562 float32_t * pDst, 02563 uint32_t blockSize); 02564 02565 /** 02566 * @brief Q7 vector subtraction. 02567 * @param[in] *pSrcA points to the first input vector 02568 * @param[in] *pSrcB points to the second input vector 02569 * @param[out] *pDst points to the output vector 02570 * @param[in] blockSize number of samples in each vector 02571 * @return none. 02572 */ 02573 02574 void arm_sub_q7( 02575 q7_t * pSrcA, 02576 q7_t * pSrcB, 02577 q7_t * pDst, 02578 uint32_t blockSize); 02579 02580 /** 02581 * @brief Q15 vector subtraction. 02582 * @param[in] *pSrcA points to the first input vector 02583 * @param[in] *pSrcB points to the second input vector 02584 * @param[out] *pDst points to the output vector 02585 * @param[in] blockSize number of samples in each vector 02586 * @return none. 02587 */ 02588 02589 void arm_sub_q15( 02590 q15_t * pSrcA, 02591 q15_t * pSrcB, 02592 q15_t * pDst, 02593 uint32_t blockSize); 02594 02595 /** 02596 * @brief Q31 vector subtraction. 02597 * @param[in] *pSrcA points to the first input vector 02598 * @param[in] *pSrcB points to the second input vector 02599 * @param[out] *pDst points to the output vector 02600 * @param[in] blockSize number of samples in each vector 02601 * @return none. 02602 */ 02603 02604 void arm_sub_q31( 02605 q31_t * pSrcA, 02606 q31_t * pSrcB, 02607 q31_t * pDst, 02608 uint32_t blockSize); 02609 02610 /** 02611 * @brief Multiplies a floating-point vector by a scalar. 02612 * @param[in] *pSrc points to the input vector 02613 * @param[in] scale scale factor to be applied 02614 * @param[out] *pDst points to the output vector 02615 * @param[in] blockSize number of samples in the vector 02616 * @return none. 02617 */ 02618 02619 void arm_scale_f32( 02620 float32_t * pSrc, 02621 float32_t scale, 02622 float32_t * pDst, 02623 uint32_t blockSize); 02624 02625 /** 02626 * @brief Multiplies a Q7 vector by a scalar. 02627 * @param[in] *pSrc points to the input vector 02628 * @param[in] scaleFract fractional portion of the scale value 02629 * @param[in] shift number of bits to shift the result by 02630 * @param[out] *pDst points to the output vector 02631 * @param[in] blockSize number of samples in the vector 02632 * @return none. 02633 */ 02634 02635 void arm_scale_q7( 02636 q7_t * pSrc, 02637 q7_t scaleFract, 02638 int8_t shift, 02639 q7_t * pDst, 02640 uint32_t blockSize); 02641 02642 /** 02643 * @brief Multiplies a Q15 vector by a scalar. 02644 * @param[in] *pSrc points to the input vector 02645 * @param[in] scaleFract fractional portion of the scale value 02646 * @param[in] shift number of bits to shift the result by 02647 * @param[out] *pDst points to the output vector 02648 * @param[in] blockSize number of samples in the vector 02649 * @return none. 02650 */ 02651 02652 void arm_scale_q15( 02653 q15_t * pSrc, 02654 q15_t scaleFract, 02655 int8_t shift, 02656 q15_t * pDst, 02657 uint32_t blockSize); 02658 02659 /** 02660 * @brief Multiplies a Q31 vector by a scalar. 02661 * @param[in] *pSrc points to the input vector 02662 * @param[in] scaleFract fractional portion of the scale value 02663 * @param[in] shift number of bits to shift the result by 02664 * @param[out] *pDst points to the output vector 02665 * @param[in] blockSize number of samples in the vector 02666 * @return none. 02667 */ 02668 02669 void arm_scale_q31( 02670 q31_t * pSrc, 02671 q31_t scaleFract, 02672 int8_t shift, 02673 q31_t * pDst, 02674 uint32_t blockSize); 02675 02676 /** 02677 * @brief Q7 vector absolute value. 02678 * @param[in] *pSrc points to the input buffer 02679 * @param[out] *pDst points to the output buffer 02680 * @param[in] blockSize number of samples in each vector 02681 * @return none. 02682 */ 02683 02684 void arm_abs_q7( 02685 q7_t * pSrc, 02686 q7_t * pDst, 02687 uint32_t blockSize); 02688 02689 /** 02690 * @brief Floating-point vector absolute value. 02691 * @param[in] *pSrc points to the input buffer 02692 * @param[out] *pDst points to the output buffer 02693 * @param[in] blockSize number of samples in each vector 02694 * @return none. 02695 */ 02696 02697 void arm_abs_f32( 02698 float32_t * pSrc, 02699 float32_t * pDst, 02700 uint32_t blockSize); 02701 02702 /** 02703 * @brief Q15 vector absolute value. 02704 * @param[in] *pSrc points to the input buffer 02705 * @param[out] *pDst points to the output buffer 02706 * @param[in] blockSize number of samples in each vector 02707 * @return none. 02708 */ 02709 02710 void arm_abs_q15( 02711 q15_t * pSrc, 02712 q15_t * pDst, 02713 uint32_t blockSize); 02714 02715 /** 02716 * @brief Q31 vector absolute value. 02717 * @param[in] *pSrc points to the input buffer 02718 * @param[out] *pDst points to the output buffer 02719 * @param[in] blockSize number of samples in each vector 02720 * @return none. 02721 */ 02722 02723 void arm_abs_q31( 02724 q31_t * pSrc, 02725 q31_t * pDst, 02726 uint32_t blockSize); 02727 02728 /** 02729 * @brief Dot product of floating-point vectors. 02730 * @param[in] *pSrcA points to the first input vector 02731 * @param[in] *pSrcB points to the second input vector 02732 * @param[in] blockSize number of samples in each vector 02733 * @param[out] *result output result returned here 02734 * @return none. 02735 */ 02736 02737 void arm_dot_prod_f32( 02738 float32_t * pSrcA, 02739 float32_t * pSrcB, 02740 uint32_t blockSize, 02741 float32_t * result); 02742 02743 /** 02744 * @brief Dot product of Q7 vectors. 02745 * @param[in] *pSrcA points to the first input vector 02746 * @param[in] *pSrcB points to the second input vector 02747 * @param[in] blockSize number of samples in each vector 02748 * @param[out] *result output result returned here 02749 * @return none. 02750 */ 02751 02752 void arm_dot_prod_q7( 02753 q7_t * pSrcA, 02754 q7_t * pSrcB, 02755 uint32_t blockSize, 02756 q31_t * result); 02757 02758 /** 02759 * @brief Dot product of Q15 vectors. 02760 * @param[in] *pSrcA points to the first input vector 02761 * @param[in] *pSrcB points to the second input vector 02762 * @param[in] blockSize number of samples in each vector 02763 * @param[out] *result output result returned here 02764 * @return none. 02765 */ 02766 02767 void arm_dot_prod_q15( 02768 q15_t * pSrcA, 02769 q15_t * pSrcB, 02770 uint32_t blockSize, 02771 q63_t * result); 02772 02773 /** 02774 * @brief Dot product of Q31 vectors. 02775 * @param[in] *pSrcA points to the first input vector 02776 * @param[in] *pSrcB points to the second input vector 02777 * @param[in] blockSize number of samples in each vector 02778 * @param[out] *result output result returned here 02779 * @return none. 02780 */ 02781 02782 void arm_dot_prod_q31( 02783 q31_t * pSrcA, 02784 q31_t * pSrcB, 02785 uint32_t blockSize, 02786 q63_t * result); 02787 02788 /** 02789 * @brief Shifts the elements of a Q7 vector a specified number of bits. 02790 * @param[in] *pSrc points to the input vector 02791 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. 02792 * @param[out] *pDst points to the output vector 02793 * @param[in] blockSize number of samples in the vector 02794 * @return none. 02795 */ 02796 02797 void arm_shift_q7( 02798 q7_t * pSrc, 02799 int8_t shiftBits, 02800 q7_t * pDst, 02801 uint32_t blockSize); 02802 02803 /** 02804 * @brief Shifts the elements of a Q15 vector a specified number of bits. 02805 * @param[in] *pSrc points to the input vector 02806 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. 02807 * @param[out] *pDst points to the output vector 02808 * @param[in] blockSize number of samples in the vector 02809 * @return none. 02810 */ 02811 02812 void arm_shift_q15( 02813 q15_t * pSrc, 02814 int8_t shiftBits, 02815 q15_t * pDst, 02816 uint32_t blockSize); 02817 02818 /** 02819 * @brief Shifts the elements of a Q31 vector a specified number of bits. 02820 * @param[in] *pSrc points to the input vector 02821 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. 02822 * @param[out] *pDst points to the output vector 02823 * @param[in] blockSize number of samples in the vector 02824 * @return none. 02825 */ 02826 02827 void arm_shift_q31( 02828 q31_t * pSrc, 02829 int8_t shiftBits, 02830 q31_t * pDst, 02831 uint32_t blockSize); 02832 02833 /** 02834 * @brief Adds a constant offset to a floating-point vector. 02835 * @param[in] *pSrc points to the input vector 02836 * @param[in] offset is the offset to be added 02837 * @param[out] *pDst points to the output vector 02838 * @param[in] blockSize number of samples in the vector 02839 * @return none. 02840 */ 02841 02842 void arm_offset_f32( 02843 float32_t * pSrc, 02844 float32_t offset, 02845 float32_t * pDst, 02846 uint32_t blockSize); 02847 02848 /** 02849 * @brief Adds a constant offset to a Q7 vector. 02850 * @param[in] *pSrc points to the input vector 02851 * @param[in] offset is the offset to be added 02852 * @param[out] *pDst points to the output vector 02853 * @param[in] blockSize number of samples in the vector 02854 * @return none. 02855 */ 02856 02857 void arm_offset_q7( 02858 q7_t * pSrc, 02859 q7_t offset, 02860 q7_t * pDst, 02861 uint32_t blockSize); 02862 02863 /** 02864 * @brief Adds a constant offset to a Q15 vector. 02865 * @param[in] *pSrc points to the input vector 02866 * @param[in] offset is the offset to be added 02867 * @param[out] *pDst points to the output vector 02868 * @param[in] blockSize number of samples in the vector 02869 * @return none. 02870 */ 02871 02872 void arm_offset_q15( 02873 q15_t * pSrc, 02874 q15_t offset, 02875 q15_t * pDst, 02876 uint32_t blockSize); 02877 02878 /** 02879 * @brief Adds a constant offset to a Q31 vector. 02880 * @param[in] *pSrc points to the input vector 02881 * @param[in] offset is the offset to be added 02882 * @param[out] *pDst points to the output vector 02883 * @param[in] blockSize number of samples in the vector 02884 * @return none. 02885 */ 02886 02887 void arm_offset_q31( 02888 q31_t * pSrc, 02889 q31_t offset, 02890 q31_t * pDst, 02891 uint32_t blockSize); 02892 02893 /** 02894 * @brief Negates the elements of a floating-point vector. 02895 * @param[in] *pSrc points to the input vector 02896 * @param[out] *pDst points to the output vector 02897 * @param[in] blockSize number of samples in the vector 02898 * @return none. 02899 */ 02900 02901 void arm_negate_f32( 02902 float32_t * pSrc, 02903 float32_t * pDst, 02904 uint32_t blockSize); 02905 02906 /** 02907 * @brief Negates the elements of a Q7 vector. 02908 * @param[in] *pSrc points to the input vector 02909 * @param[out] *pDst points to the output vector 02910 * @param[in] blockSize number of samples in the vector 02911 * @return none. 02912 */ 02913 02914 void arm_negate_q7( 02915 q7_t * pSrc, 02916 q7_t * pDst, 02917 uint32_t blockSize); 02918 02919 /** 02920 * @brief Negates the elements of a Q15 vector. 02921 * @param[in] *pSrc points to the input vector 02922 * @param[out] *pDst points to the output vector 02923 * @param[in] blockSize number of samples in the vector 02924 * @return none. 02925 */ 02926 02927 void arm_negate_q15( 02928 q15_t * pSrc, 02929 q15_t * pDst, 02930 uint32_t blockSize); 02931 02932 /** 02933 * @brief Negates the elements of a Q31 vector. 02934 * @param[in] *pSrc points to the input vector 02935 * @param[out] *pDst points to the output vector 02936 * @param[in] blockSize number of samples in the vector 02937 * @return none. 02938 */ 02939 02940 void arm_negate_q31( 02941 q31_t * pSrc, 02942 q31_t * pDst, 02943 uint32_t blockSize); 02944 /** 02945 * @brief Copies the elements of a floating-point vector. 02946 * @param[in] *pSrc input pointer 02947 * @param[out] *pDst output pointer 02948 * @param[in] blockSize number of samples to process 02949 * @return none. 02950 */ 02951 void arm_copy_f32( 02952 float32_t * pSrc, 02953 float32_t * pDst, 02954 uint32_t blockSize); 02955 02956 /** 02957 * @brief Copies the elements of a Q7 vector. 02958 * @param[in] *pSrc input pointer 02959 * @param[out] *pDst output pointer 02960 * @param[in] blockSize number of samples to process 02961 * @return none. 02962 */ 02963 void arm_copy_q7( 02964 q7_t * pSrc, 02965 q7_t * pDst, 02966 uint32_t blockSize); 02967 02968 /** 02969 * @brief Copies the elements of a Q15 vector. 02970 * @param[in] *pSrc input pointer 02971 * @param[out] *pDst output pointer 02972 * @param[in] blockSize number of samples to process 02973 * @return none. 02974 */ 02975 void arm_copy_q15( 02976 q15_t * pSrc, 02977 q15_t * pDst, 02978 uint32_t blockSize); 02979 02980 /** 02981 * @brief Copies the elements of a Q31 vector. 02982 * @param[in] *pSrc input pointer 02983 * @param[out] *pDst output pointer 02984 * @param[in] blockSize number of samples to process 02985 * @return none. 02986 */ 02987 void arm_copy_q31( 02988 q31_t * pSrc, 02989 q31_t * pDst, 02990 uint32_t blockSize); 02991 /** 02992 * @brief Fills a constant value into a floating-point vector. 02993 * @param[in] value input value to be filled 02994 * @param[out] *pDst output pointer 02995 * @param[in] blockSize number of samples to process 02996 * @return none. 02997 */ 02998 void arm_fill_f32( 02999 float32_t value, 03000 float32_t * pDst, 03001 uint32_t blockSize); 03002 03003 /** 03004 * @brief Fills a constant value into a Q7 vector. 03005 * @param[in] value input value to be filled 03006 * @param[out] *pDst output pointer 03007 * @param[in] blockSize number of samples to process 03008 * @return none. 03009 */ 03010 void arm_fill_q7( 03011 q7_t value, 03012 q7_t * pDst, 03013 uint32_t blockSize); 03014 03015 /** 03016 * @brief Fills a constant value into a Q15 vector. 03017 * @param[in] value input value to be filled 03018 * @param[out] *pDst output pointer 03019 * @param[in] blockSize number of samples to process 03020 * @return none. 03021 */ 03022 void arm_fill_q15( 03023 q15_t value, 03024 q15_t * pDst, 03025 uint32_t blockSize); 03026 03027 /** 03028 * @brief Fills a constant value into a Q31 vector. 03029 * @param[in] value input value to be filled 03030 * @param[out] *pDst output pointer 03031 * @param[in] blockSize number of samples to process 03032 * @return none. 03033 */ 03034 void arm_fill_q31( 03035 q31_t value, 03036 q31_t * pDst, 03037 uint32_t blockSize); 03038 03039 /** 03040 * @brief Convolution of floating-point sequences. 03041 * @param[in] *pSrcA points to the first input sequence. 03042 * @param[in] srcALen length of the first input sequence. 03043 * @param[in] *pSrcB points to the second input sequence. 03044 * @param[in] srcBLen length of the second input sequence. 03045 * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1. 03046 * @return none. 03047 */ 03048 03049 void arm_conv_f32( 03050 float32_t * pSrcA, 03051 uint32_t srcALen, 03052 float32_t * pSrcB, 03053 uint32_t srcBLen, 03054 float32_t * pDst); 03055 03056 03057 /** 03058 * @brief Convolution of Q15 sequences. 03059 * @param[in] *pSrcA points to the first input sequence. 03060 * @param[in] srcALen length of the first input sequence. 03061 * @param[in] *pSrcB points to the second input sequence. 03062 * @param[in] srcBLen length of the second input sequence. 03063 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03064 * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 03065 * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 03066 * @return none. 03067 */ 03068 03069 03070 void arm_conv_opt_q15( 03071 q15_t * pSrcA, 03072 uint32_t srcALen, 03073 q15_t * pSrcB, 03074 uint32_t srcBLen, 03075 q15_t * pDst, 03076 q15_t * pScratch1, 03077 q15_t * pScratch2); 03078 03079 03080 /** 03081 * @brief Convolution of Q15 sequences. 03082 * @param[in] *pSrcA points to the first input sequence. 03083 * @param[in] srcALen length of the first input sequence. 03084 * @param[in] *pSrcB points to the second input sequence. 03085 * @param[in] srcBLen length of the second input sequence. 03086 * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1. 03087 * @return none. 03088 */ 03089 03090 void arm_conv_q15( 03091 q15_t * pSrcA, 03092 uint32_t srcALen, 03093 q15_t * pSrcB, 03094 uint32_t srcBLen, 03095 q15_t * pDst); 03096 03097 /** 03098 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 03099 * @param[in] *pSrcA points to the first input sequence. 03100 * @param[in] srcALen length of the first input sequence. 03101 * @param[in] *pSrcB points to the second input sequence. 03102 * @param[in] srcBLen length of the second input sequence. 03103 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03104 * @return none. 03105 */ 03106 03107 void arm_conv_fast_q15( 03108 q15_t * pSrcA, 03109 uint32_t srcALen, 03110 q15_t * pSrcB, 03111 uint32_t srcBLen, 03112 q15_t * pDst); 03113 03114 /** 03115 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 03116 * @param[in] *pSrcA points to the first input sequence. 03117 * @param[in] srcALen length of the first input sequence. 03118 * @param[in] *pSrcB points to the second input sequence. 03119 * @param[in] srcBLen length of the second input sequence. 03120 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03121 * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 03122 * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 03123 * @return none. 03124 */ 03125 03126 void arm_conv_fast_opt_q15( 03127 q15_t * pSrcA, 03128 uint32_t srcALen, 03129 q15_t * pSrcB, 03130 uint32_t srcBLen, 03131 q15_t * pDst, 03132 q15_t * pScratch1, 03133 q15_t * pScratch2); 03134 03135 03136 03137 /** 03138 * @brief Convolution of Q31 sequences. 03139 * @param[in] *pSrcA points to the first input sequence. 03140 * @param[in] srcALen length of the first input sequence. 03141 * @param[in] *pSrcB points to the second input sequence. 03142 * @param[in] srcBLen length of the second input sequence. 03143 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03144 * @return none. 03145 */ 03146 03147 void arm_conv_q31( 03148 q31_t * pSrcA, 03149 uint32_t srcALen, 03150 q31_t * pSrcB, 03151 uint32_t srcBLen, 03152 q31_t * pDst); 03153 03154 /** 03155 * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 03156 * @param[in] *pSrcA points to the first input sequence. 03157 * @param[in] srcALen length of the first input sequence. 03158 * @param[in] *pSrcB points to the second input sequence. 03159 * @param[in] srcBLen length of the second input sequence. 03160 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03161 * @return none. 03162 */ 03163 03164 void arm_conv_fast_q31( 03165 q31_t * pSrcA, 03166 uint32_t srcALen, 03167 q31_t * pSrcB, 03168 uint32_t srcBLen, 03169 q31_t * pDst); 03170 03171 03172 /** 03173 * @brief Convolution of Q7 sequences. 03174 * @param[in] *pSrcA points to the first input sequence. 03175 * @param[in] srcALen length of the first input sequence. 03176 * @param[in] *pSrcB points to the second input sequence. 03177 * @param[in] srcBLen length of the second input sequence. 03178 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03179 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 03180 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 03181 * @return none. 03182 */ 03183 03184 void arm_conv_opt_q7( 03185 q7_t * pSrcA, 03186 uint32_t srcALen, 03187 q7_t * pSrcB, 03188 uint32_t srcBLen, 03189 q7_t * pDst, 03190 q15_t * pScratch1, 03191 q15_t * pScratch2); 03192 03193 03194 03195 /** 03196 * @brief Convolution of Q7 sequences. 03197 * @param[in] *pSrcA points to the first input sequence. 03198 * @param[in] srcALen length of the first input sequence. 03199 * @param[in] *pSrcB points to the second input sequence. 03200 * @param[in] srcBLen length of the second input sequence. 03201 * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1. 03202 * @return none. 03203 */ 03204 03205 void arm_conv_q7( 03206 q7_t * pSrcA, 03207 uint32_t srcALen, 03208 q7_t * pSrcB, 03209 uint32_t srcBLen, 03210 q7_t * pDst); 03211 03212 03213 /** 03214 * @brief Partial convolution of floating-point sequences. 03215 * @param[in] *pSrcA points to the first input sequence. 03216 * @param[in] srcALen length of the first input sequence. 03217 * @param[in] *pSrcB points to the second input sequence. 03218 * @param[in] srcBLen length of the second input sequence. 03219 * @param[out] *pDst points to the block of output data 03220 * @param[in] firstIndex is the first output sample to start with. 03221 * @param[in] numPoints is the number of output points to be computed. 03222 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03223 */ 03224 03225 arm_status arm_conv_partial_f32( 03226 float32_t * pSrcA, 03227 uint32_t srcALen, 03228 float32_t * pSrcB, 03229 uint32_t srcBLen, 03230 float32_t * pDst, 03231 uint32_t firstIndex, 03232 uint32_t numPoints); 03233 03234 /** 03235 * @brief Partial convolution of Q15 sequences. 03236 * @param[in] *pSrcA points to the first input sequence. 03237 * @param[in] srcALen length of the first input sequence. 03238 * @param[in] *pSrcB points to the second input sequence. 03239 * @param[in] srcBLen length of the second input sequence. 03240 * @param[out] *pDst points to the block of output data 03241 * @param[in] firstIndex is the first output sample to start with. 03242 * @param[in] numPoints is the number of output points to be computed. 03243 * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 03244 * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 03245 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03246 */ 03247 03248 arm_status arm_conv_partial_opt_q15( 03249 q15_t * pSrcA, 03250 uint32_t srcALen, 03251 q15_t * pSrcB, 03252 uint32_t srcBLen, 03253 q15_t * pDst, 03254 uint32_t firstIndex, 03255 uint32_t numPoints, 03256 q15_t * pScratch1, 03257 q15_t * pScratch2); 03258 03259 03260 /** 03261 * @brief Partial convolution of Q15 sequences. 03262 * @param[in] *pSrcA points to the first input sequence. 03263 * @param[in] srcALen length of the first input sequence. 03264 * @param[in] *pSrcB points to the second input sequence. 03265 * @param[in] srcBLen length of the second input sequence. 03266 * @param[out] *pDst points to the block of output data 03267 * @param[in] firstIndex is the first output sample to start with. 03268 * @param[in] numPoints is the number of output points to be computed. 03269 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03270 */ 03271 03272 arm_status arm_conv_partial_q15( 03273 q15_t * pSrcA, 03274 uint32_t srcALen, 03275 q15_t * pSrcB, 03276 uint32_t srcBLen, 03277 q15_t * pDst, 03278 uint32_t firstIndex, 03279 uint32_t numPoints); 03280 03281 /** 03282 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 03283 * @param[in] *pSrcA points to the first input sequence. 03284 * @param[in] srcALen length of the first input sequence. 03285 * @param[in] *pSrcB points to the second input sequence. 03286 * @param[in] srcBLen length of the second input sequence. 03287 * @param[out] *pDst points to the block of output data 03288 * @param[in] firstIndex is the first output sample to start with. 03289 * @param[in] numPoints is the number of output points to be computed. 03290 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03291 */ 03292 03293 arm_status arm_conv_partial_fast_q15( 03294 q15_t * pSrcA, 03295 uint32_t srcALen, 03296 q15_t * pSrcB, 03297 uint32_t srcBLen, 03298 q15_t * pDst, 03299 uint32_t firstIndex, 03300 uint32_t numPoints); 03301 03302 03303 /** 03304 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 03305 * @param[in] *pSrcA points to the first input sequence. 03306 * @param[in] srcALen length of the first input sequence. 03307 * @param[in] *pSrcB points to the second input sequence. 03308 * @param[in] srcBLen length of the second input sequence. 03309 * @param[out] *pDst points to the block of output data 03310 * @param[in] firstIndex is the first output sample to start with. 03311 * @param[in] numPoints is the number of output points to be computed. 03312 * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 03313 * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 03314 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03315 */ 03316 03317 arm_status arm_conv_partial_fast_opt_q15( 03318 q15_t * pSrcA, 03319 uint32_t srcALen, 03320 q15_t * pSrcB, 03321 uint32_t srcBLen, 03322 q15_t * pDst, 03323 uint32_t firstIndex, 03324 uint32_t numPoints, 03325 q15_t * pScratch1, 03326 q15_t * pScratch2); 03327 03328 03329 /** 03330 * @brief Partial convolution of Q31 sequences. 03331 * @param[in] *pSrcA points to the first input sequence. 03332 * @param[in] srcALen length of the first input sequence. 03333 * @param[in] *pSrcB points to the second input sequence. 03334 * @param[in] srcBLen length of the second input sequence. 03335 * @param[out] *pDst points to the block of output data 03336 * @param[in] firstIndex is the first output sample to start with. 03337 * @param[in] numPoints is the number of output points to be computed. 03338 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03339 */ 03340 03341 arm_status arm_conv_partial_q31( 03342 q31_t * pSrcA, 03343 uint32_t srcALen, 03344 q31_t * pSrcB, 03345 uint32_t srcBLen, 03346 q31_t * pDst, 03347 uint32_t firstIndex, 03348 uint32_t numPoints); 03349 03350 03351 /** 03352 * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 03353 * @param[in] *pSrcA points to the first input sequence. 03354 * @param[in] srcALen length of the first input sequence. 03355 * @param[in] *pSrcB points to the second input sequence. 03356 * @param[in] srcBLen length of the second input sequence. 03357 * @param[out] *pDst points to the block of output data 03358 * @param[in] firstIndex is the first output sample to start with. 03359 * @param[in] numPoints is the number of output points to be computed. 03360 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03361 */ 03362 03363 arm_status arm_conv_partial_fast_q31( 03364 q31_t * pSrcA, 03365 uint32_t srcALen, 03366 q31_t * pSrcB, 03367 uint32_t srcBLen, 03368 q31_t * pDst, 03369 uint32_t firstIndex, 03370 uint32_t numPoints); 03371 03372 03373 /** 03374 * @brief Partial convolution of Q7 sequences 03375 * @param[in] *pSrcA points to the first input sequence. 03376 * @param[in] srcALen length of the first input sequence. 03377 * @param[in] *pSrcB points to the second input sequence. 03378 * @param[in] srcBLen length of the second input sequence. 03379 * @param[out] *pDst points to the block of output data 03380 * @param[in] firstIndex is the first output sample to start with. 03381 * @param[in] numPoints is the number of output points to be computed. 03382 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 03383 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 03384 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03385 */ 03386 03387 arm_status arm_conv_partial_opt_q7( 03388 q7_t * pSrcA, 03389 uint32_t srcALen, 03390 q7_t * pSrcB, 03391 uint32_t srcBLen, 03392 q7_t * pDst, 03393 uint32_t firstIndex, 03394 uint32_t numPoints, 03395 q15_t * pScratch1, 03396 q15_t * pScratch2); 03397 03398 03399 /** 03400 * @brief Partial convolution of Q7 sequences. 03401 * @param[in] *pSrcA points to the first input sequence. 03402 * @param[in] srcALen length of the first input sequence. 03403 * @param[in] *pSrcB points to the second input sequence. 03404 * @param[in] srcBLen length of the second input sequence. 03405 * @param[out] *pDst points to the block of output data 03406 * @param[in] firstIndex is the first output sample to start with. 03407 * @param[in] numPoints is the number of output points to be computed. 03408 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 03409 */ 03410 03411 arm_status arm_conv_partial_q7( 03412 q7_t * pSrcA, 03413 uint32_t srcALen, 03414 q7_t * pSrcB, 03415 uint32_t srcBLen, 03416 q7_t * pDst, 03417 uint32_t firstIndex, 03418 uint32_t numPoints); 03419 03420 03421 03422 /** 03423 * @brief Instance structure for the Q15 FIR decimator. 03424 */ 03425 03426 typedef struct 03427 { 03428 uint8_t M; /**< decimation factor. */ 03429 uint16_t numTaps; /**< number of coefficients in the filter. */ 03430 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 03431 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03432 } arm_fir_decimate_instance_q15; 03433 03434 /** 03435 * @brief Instance structure for the Q31 FIR decimator. 03436 */ 03437 03438 typedef struct 03439 { 03440 uint8_t M; /**< decimation factor. */ 03441 uint16_t numTaps; /**< number of coefficients in the filter. */ 03442 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 03443 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03444 03445 } arm_fir_decimate_instance_q31; 03446 03447 /** 03448 * @brief Instance structure for the floating-point FIR decimator. 03449 */ 03450 03451 typedef struct 03452 { 03453 uint8_t M; /**< decimation factor. */ 03454 uint16_t numTaps; /**< number of coefficients in the filter. */ 03455 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 03456 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 03457 03458 } arm_fir_decimate_instance_f32; 03459 03460 03461 03462 /** 03463 * @brief Processing function for the floating-point FIR decimator. 03464 * @param[in] *S points to an instance of the floating-point FIR decimator structure. 03465 * @param[in] *pSrc points to the block of input data. 03466 * @param[out] *pDst points to the block of output data 03467 * @param[in] blockSize number of input samples to process per call. 03468 * @return none 03469 */ 03470 03471 void arm_fir_decimate_f32( 03472 const arm_fir_decimate_instance_f32 * S, 03473 float32_t * pSrc, 03474 float32_t * pDst, 03475 uint32_t blockSize); 03476 03477 03478 /** 03479 * @brief Initialization function for the floating-point FIR decimator. 03480 * @param[in,out] *S points to an instance of the floating-point FIR decimator structure. 03481 * @param[in] numTaps number of coefficients in the filter. 03482 * @param[in] M decimation factor. 03483 * @param[in] *pCoeffs points to the filter coefficients. 03484 * @param[in] *pState points to the state buffer. 03485 * @param[in] blockSize number of input samples to process per call. 03486 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03487 * <code>blockSize</code> is not a multiple of <code>M</code>. 03488 */ 03489 03490 arm_status arm_fir_decimate_init_f32( 03491 arm_fir_decimate_instance_f32 * S, 03492 uint16_t numTaps, 03493 uint8_t M, 03494 float32_t * pCoeffs, 03495 float32_t * pState, 03496 uint32_t blockSize); 03497 03498 /** 03499 * @brief Processing function for the Q15 FIR decimator. 03500 * @param[in] *S points to an instance of the Q15 FIR decimator structure. 03501 * @param[in] *pSrc points to the block of input data. 03502 * @param[out] *pDst points to the block of output data 03503 * @param[in] blockSize number of input samples to process per call. 03504 * @return none 03505 */ 03506 03507 void arm_fir_decimate_q15( 03508 const arm_fir_decimate_instance_q15 * S, 03509 q15_t * pSrc, 03510 q15_t * pDst, 03511 uint32_t blockSize); 03512 03513 /** 03514 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. 03515 * @param[in] *S points to an instance of the Q15 FIR decimator structure. 03516 * @param[in] *pSrc points to the block of input data. 03517 * @param[out] *pDst points to the block of output data 03518 * @param[in] blockSize number of input samples to process per call. 03519 * @return none 03520 */ 03521 03522 void arm_fir_decimate_fast_q15( 03523 const arm_fir_decimate_instance_q15 * S, 03524 q15_t * pSrc, 03525 q15_t * pDst, 03526 uint32_t blockSize); 03527 03528 03529 03530 /** 03531 * @brief Initialization function for the Q15 FIR decimator. 03532 * @param[in,out] *S points to an instance of the Q15 FIR decimator structure. 03533 * @param[in] numTaps number of coefficients in the filter. 03534 * @param[in] M decimation factor. 03535 * @param[in] *pCoeffs points to the filter coefficients. 03536 * @param[in] *pState points to the state buffer. 03537 * @param[in] blockSize number of input samples to process per call. 03538 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03539 * <code>blockSize</code> is not a multiple of <code>M</code>. 03540 */ 03541 03542 arm_status arm_fir_decimate_init_q15( 03543 arm_fir_decimate_instance_q15 * S, 03544 uint16_t numTaps, 03545 uint8_t M, 03546 q15_t * pCoeffs, 03547 q15_t * pState, 03548 uint32_t blockSize); 03549 03550 /** 03551 * @brief Processing function for the Q31 FIR decimator. 03552 * @param[in] *S points to an instance of the Q31 FIR decimator structure. 03553 * @param[in] *pSrc points to the block of input data. 03554 * @param[out] *pDst points to the block of output data 03555 * @param[in] blockSize number of input samples to process per call. 03556 * @return none 03557 */ 03558 03559 void arm_fir_decimate_q31( 03560 const arm_fir_decimate_instance_q31 * S, 03561 q31_t * pSrc, 03562 q31_t * pDst, 03563 uint32_t blockSize); 03564 03565 /** 03566 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. 03567 * @param[in] *S points to an instance of the Q31 FIR decimator structure. 03568 * @param[in] *pSrc points to the block of input data. 03569 * @param[out] *pDst points to the block of output data 03570 * @param[in] blockSize number of input samples to process per call. 03571 * @return none 03572 */ 03573 03574 void arm_fir_decimate_fast_q31( 03575 arm_fir_decimate_instance_q31 * S, 03576 q31_t * pSrc, 03577 q31_t * pDst, 03578 uint32_t blockSize); 03579 03580 03581 /** 03582 * @brief Initialization function for the Q31 FIR decimator. 03583 * @param[in,out] *S points to an instance of the Q31 FIR decimator structure. 03584 * @param[in] numTaps number of coefficients in the filter. 03585 * @param[in] M decimation factor. 03586 * @param[in] *pCoeffs points to the filter coefficients. 03587 * @param[in] *pState points to the state buffer. 03588 * @param[in] blockSize number of input samples to process per call. 03589 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03590 * <code>blockSize</code> is not a multiple of <code>M</code>. 03591 */ 03592 03593 arm_status arm_fir_decimate_init_q31( 03594 arm_fir_decimate_instance_q31 * S, 03595 uint16_t numTaps, 03596 uint8_t M, 03597 q31_t * pCoeffs, 03598 q31_t * pState, 03599 uint32_t blockSize); 03600 03601 03602 03603 /** 03604 * @brief Instance structure for the Q15 FIR interpolator. 03605 */ 03606 03607 typedef struct 03608 { 03609 uint8_t L; /**< upsample factor. */ 03610 uint16_t phaseLength; /**< length of each polyphase filter component. */ 03611 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 03612 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 03613 } arm_fir_interpolate_instance_q15; 03614 03615 /** 03616 * @brief Instance structure for the Q31 FIR interpolator. 03617 */ 03618 03619 typedef struct 03620 { 03621 uint8_t L; /**< upsample factor. */ 03622 uint16_t phaseLength; /**< length of each polyphase filter component. */ 03623 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 03624 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 03625 } arm_fir_interpolate_instance_q31; 03626 03627 /** 03628 * @brief Instance structure for the floating-point FIR interpolator. 03629 */ 03630 03631 typedef struct 03632 { 03633 uint8_t L; /**< upsample factor. */ 03634 uint16_t phaseLength; /**< length of each polyphase filter component. */ 03635 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 03636 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */ 03637 } arm_fir_interpolate_instance_f32; 03638 03639 03640 /** 03641 * @brief Processing function for the Q15 FIR interpolator. 03642 * @param[in] *S points to an instance of the Q15 FIR interpolator structure. 03643 * @param[in] *pSrc points to the block of input data. 03644 * @param[out] *pDst points to the block of output data. 03645 * @param[in] blockSize number of input samples to process per call. 03646 * @return none. 03647 */ 03648 03649 void arm_fir_interpolate_q15( 03650 const arm_fir_interpolate_instance_q15 * S, 03651 q15_t * pSrc, 03652 q15_t * pDst, 03653 uint32_t blockSize); 03654 03655 03656 /** 03657 * @brief Initialization function for the Q15 FIR interpolator. 03658 * @param[in,out] *S points to an instance of the Q15 FIR interpolator structure. 03659 * @param[in] L upsample factor. 03660 * @param[in] numTaps number of filter coefficients in the filter. 03661 * @param[in] *pCoeffs points to the filter coefficient buffer. 03662 * @param[in] *pState points to the state buffer. 03663 * @param[in] blockSize number of input samples to process per call. 03664 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03665 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 03666 */ 03667 03668 arm_status arm_fir_interpolate_init_q15( 03669 arm_fir_interpolate_instance_q15 * S, 03670 uint8_t L, 03671 uint16_t numTaps, 03672 q15_t * pCoeffs, 03673 q15_t * pState, 03674 uint32_t blockSize); 03675 03676 /** 03677 * @brief Processing function for the Q31 FIR interpolator. 03678 * @param[in] *S points to an instance of the Q15 FIR interpolator structure. 03679 * @param[in] *pSrc points to the block of input data. 03680 * @param[out] *pDst points to the block of output data. 03681 * @param[in] blockSize number of input samples to process per call. 03682 * @return none. 03683 */ 03684 03685 void arm_fir_interpolate_q31( 03686 const arm_fir_interpolate_instance_q31 * S, 03687 q31_t * pSrc, 03688 q31_t * pDst, 03689 uint32_t blockSize); 03690 03691 /** 03692 * @brief Initialization function for the Q31 FIR interpolator. 03693 * @param[in,out] *S points to an instance of the Q31 FIR interpolator structure. 03694 * @param[in] L upsample factor. 03695 * @param[in] numTaps number of filter coefficients in the filter. 03696 * @param[in] *pCoeffs points to the filter coefficient buffer. 03697 * @param[in] *pState points to the state buffer. 03698 * @param[in] blockSize number of input samples to process per call. 03699 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03700 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 03701 */ 03702 03703 arm_status arm_fir_interpolate_init_q31( 03704 arm_fir_interpolate_instance_q31 * S, 03705 uint8_t L, 03706 uint16_t numTaps, 03707 q31_t * pCoeffs, 03708 q31_t * pState, 03709 uint32_t blockSize); 03710 03711 03712 /** 03713 * @brief Processing function for the floating-point FIR interpolator. 03714 * @param[in] *S points to an instance of the floating-point FIR interpolator structure. 03715 * @param[in] *pSrc points to the block of input data. 03716 * @param[out] *pDst points to the block of output data. 03717 * @param[in] blockSize number of input samples to process per call. 03718 * @return none. 03719 */ 03720 03721 void arm_fir_interpolate_f32( 03722 const arm_fir_interpolate_instance_f32 * S, 03723 float32_t * pSrc, 03724 float32_t * pDst, 03725 uint32_t blockSize); 03726 03727 /** 03728 * @brief Initialization function for the floating-point FIR interpolator. 03729 * @param[in,out] *S points to an instance of the floating-point FIR interpolator structure. 03730 * @param[in] L upsample factor. 03731 * @param[in] numTaps number of filter coefficients in the filter. 03732 * @param[in] *pCoeffs points to the filter coefficient buffer. 03733 * @param[in] *pState points to the state buffer. 03734 * @param[in] blockSize number of input samples to process per call. 03735 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 03736 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 03737 */ 03738 03739 arm_status arm_fir_interpolate_init_f32( 03740 arm_fir_interpolate_instance_f32 * S, 03741 uint8_t L, 03742 uint16_t numTaps, 03743 float32_t * pCoeffs, 03744 float32_t * pState, 03745 uint32_t blockSize); 03746 03747 /** 03748 * @brief Instance structure for the high precision Q31 Biquad cascade filter. 03749 */ 03750 03751 typedef struct 03752 { 03753 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 03754 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ 03755 q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 03756 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */ 03757 03758 } arm_biquad_cas_df1_32x64_ins_q31; 03759 03760 03761 /** 03762 * @param[in] *S points to an instance of the high precision Q31 Biquad cascade filter structure. 03763 * @param[in] *pSrc points to the block of input data. 03764 * @param[out] *pDst points to the block of output data 03765 * @param[in] blockSize number of samples to process. 03766 * @return none. 03767 */ 03768 03769 void arm_biquad_cas_df1_32x64_q31( 03770 const arm_biquad_cas_df1_32x64_ins_q31 * S, 03771 q31_t * pSrc, 03772 q31_t * pDst, 03773 uint32_t blockSize); 03774 03775 03776 /** 03777 * @param[in,out] *S points to an instance of the high precision Q31 Biquad cascade filter structure. 03778 * @param[in] numStages number of 2nd order stages in the filter. 03779 * @param[in] *pCoeffs points to the filter coefficients. 03780 * @param[in] *pState points to the state buffer. 03781 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format 03782 * @return none 03783 */ 03784 03785 void arm_biquad_cas_df1_32x64_init_q31( 03786 arm_biquad_cas_df1_32x64_ins_q31 * S, 03787 uint8_t numStages, 03788 q31_t * pCoeffs, 03789 q63_t * pState, 03790 uint8_t postShift); 03791 03792 03793 03794 /** 03795 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 03796 */ 03797 03798 typedef struct 03799 { 03800 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 03801 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ 03802 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 03803 } arm_biquad_cascade_df2T_instance_f32; 03804 03805 03806 /** 03807 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 03808 * @param[in] *S points to an instance of the filter data structure. 03809 * @param[in] *pSrc points to the block of input data. 03810 * @param[out] *pDst points to the block of output data 03811 * @param[in] blockSize number of samples to process. 03812 * @return none. 03813 */ 03814 03815 void arm_biquad_cascade_df2T_f32( 03816 const arm_biquad_cascade_df2T_instance_f32 * S, 03817 float32_t * pSrc, 03818 float32_t * pDst, 03819 uint32_t blockSize); 03820 03821 03822 /** 03823 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 03824 * @param[in,out] *S points to an instance of the filter data structure. 03825 * @param[in] numStages number of 2nd order stages in the filter. 03826 * @param[in] *pCoeffs points to the filter coefficients. 03827 * @param[in] *pState points to the state buffer. 03828 * @return none 03829 */ 03830 03831 void arm_biquad_cascade_df2T_init_f32( 03832 arm_biquad_cascade_df2T_instance_f32 * S, 03833 uint8_t numStages, 03834 float32_t * pCoeffs, 03835 float32_t * pState); 03836 03837 03838 03839 /** 03840 * @brief Instance structure for the Q15 FIR lattice filter. 03841 */ 03842 03843 typedef struct 03844 { 03845 uint16_t numStages; /**< number of filter stages. */ 03846 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */ 03847 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 03848 } arm_fir_lattice_instance_q15; 03849 03850 /** 03851 * @brief Instance structure for the Q31 FIR lattice filter. 03852 */ 03853 03854 typedef struct 03855 { 03856 uint16_t numStages; /**< number of filter stages. */ 03857 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */ 03858 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 03859 } arm_fir_lattice_instance_q31; 03860 03861 /** 03862 * @brief Instance structure for the floating-point FIR lattice filter. 03863 */ 03864 03865 typedef struct 03866 { 03867 uint16_t numStages; /**< number of filter stages. */ 03868 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */ 03869 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 03870 } arm_fir_lattice_instance_f32; 03871 03872 /** 03873 * @brief Initialization function for the Q15 FIR lattice filter. 03874 * @param[in] *S points to an instance of the Q15 FIR lattice structure. 03875 * @param[in] numStages number of filter stages. 03876 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 03877 * @param[in] *pState points to the state buffer. The array is of length numStages. 03878 * @return none. 03879 */ 03880 03881 void arm_fir_lattice_init_q15( 03882 arm_fir_lattice_instance_q15 * S, 03883 uint16_t numStages, 03884 q15_t * pCoeffs, 03885 q15_t * pState); 03886 03887 03888 /** 03889 * @brief Processing function for the Q15 FIR lattice filter. 03890 * @param[in] *S points to an instance of the Q15 FIR lattice structure. 03891 * @param[in] *pSrc points to the block of input data. 03892 * @param[out] *pDst points to the block of output data. 03893 * @param[in] blockSize number of samples to process. 03894 * @return none. 03895 */ 03896 void arm_fir_lattice_q15( 03897 const arm_fir_lattice_instance_q15 * S, 03898 q15_t * pSrc, 03899 q15_t * pDst, 03900 uint32_t blockSize); 03901 03902 /** 03903 * @brief Initialization function for the Q31 FIR lattice filter. 03904 * @param[in] *S points to an instance of the Q31 FIR lattice structure. 03905 * @param[in] numStages number of filter stages. 03906 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 03907 * @param[in] *pState points to the state buffer. The array is of length numStages. 03908 * @return none. 03909 */ 03910 03911 void arm_fir_lattice_init_q31( 03912 arm_fir_lattice_instance_q31 * S, 03913 uint16_t numStages, 03914 q31_t * pCoeffs, 03915 q31_t * pState); 03916 03917 03918 /** 03919 * @brief Processing function for the Q31 FIR lattice filter. 03920 * @param[in] *S points to an instance of the Q31 FIR lattice structure. 03921 * @param[in] *pSrc points to the block of input data. 03922 * @param[out] *pDst points to the block of output data 03923 * @param[in] blockSize number of samples to process. 03924 * @return none. 03925 */ 03926 03927 void arm_fir_lattice_q31( 03928 const arm_fir_lattice_instance_q31 * S, 03929 q31_t * pSrc, 03930 q31_t * pDst, 03931 uint32_t blockSize); 03932 03933 /** 03934 * @brief Initialization function for the floating-point FIR lattice filter. 03935 * @param[in] *S points to an instance of the floating-point FIR lattice structure. 03936 * @param[in] numStages number of filter stages. 03937 * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages. 03938 * @param[in] *pState points to the state buffer. The array is of length numStages. 03939 * @return none. 03940 */ 03941 03942 void arm_fir_lattice_init_f32( 03943 arm_fir_lattice_instance_f32 * S, 03944 uint16_t numStages, 03945 float32_t * pCoeffs, 03946 float32_t * pState); 03947 03948 /** 03949 * @brief Processing function for the floating-point FIR lattice filter. 03950 * @param[in] *S points to an instance of the floating-point FIR lattice structure. 03951 * @param[in] *pSrc points to the block of input data. 03952 * @param[out] *pDst points to the block of output data 03953 * @param[in] blockSize number of samples to process. 03954 * @return none. 03955 */ 03956 03957 void arm_fir_lattice_f32( 03958 const arm_fir_lattice_instance_f32 * S, 03959 float32_t * pSrc, 03960 float32_t * pDst, 03961 uint32_t blockSize); 03962 03963 /** 03964 * @brief Instance structure for the Q15 IIR lattice filter. 03965 */ 03966 typedef struct 03967 { 03968 uint16_t numStages; /**< number of stages in the filter. */ 03969 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 03970 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 03971 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 03972 } arm_iir_lattice_instance_q15; 03973 03974 /** 03975 * @brief Instance structure for the Q31 IIR lattice filter. 03976 */ 03977 typedef struct 03978 { 03979 uint16_t numStages; /**< number of stages in the filter. */ 03980 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 03981 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 03982 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 03983 } arm_iir_lattice_instance_q31; 03984 03985 /** 03986 * @brief Instance structure for the floating-point IIR lattice filter. 03987 */ 03988 typedef struct 03989 { 03990 uint16_t numStages; /**< number of stages in the filter. */ 03991 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 03992 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 03993 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 03994 } arm_iir_lattice_instance_f32; 03995 03996 /** 03997 * @brief Processing function for the floating-point IIR lattice filter. 03998 * @param[in] *S points to an instance of the floating-point IIR lattice structure. 03999 * @param[in] *pSrc points to the block of input data. 04000 * @param[out] *pDst points to the block of output data. 04001 * @param[in] blockSize number of samples to process. 04002 * @return none. 04003 */ 04004 04005 void arm_iir_lattice_f32( 04006 const arm_iir_lattice_instance_f32 * S, 04007 float32_t * pSrc, 04008 float32_t * pDst, 04009 uint32_t blockSize); 04010 04011 /** 04012 * @brief Initialization function for the floating-point IIR lattice filter. 04013 * @param[in] *S points to an instance of the floating-point IIR lattice structure. 04014 * @param[in] numStages number of stages in the filter. 04015 * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 04016 * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 04017 * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize-1. 04018 * @param[in] blockSize number of samples to process. 04019 * @return none. 04020 */ 04021 04022 void arm_iir_lattice_init_f32( 04023 arm_iir_lattice_instance_f32 * S, 04024 uint16_t numStages, 04025 float32_t * pkCoeffs, 04026 float32_t * pvCoeffs, 04027 float32_t * pState, 04028 uint32_t blockSize); 04029 04030 04031 /** 04032 * @brief Processing function for the Q31 IIR lattice filter. 04033 * @param[in] *S points to an instance of the Q31 IIR lattice structure. 04034 * @param[in] *pSrc points to the block of input data. 04035 * @param[out] *pDst points to the block of output data. 04036 * @param[in] blockSize number of samples to process. 04037 * @return none. 04038 */ 04039 04040 void arm_iir_lattice_q31( 04041 const arm_iir_lattice_instance_q31 * S, 04042 q31_t * pSrc, 04043 q31_t * pDst, 04044 uint32_t blockSize); 04045 04046 04047 /** 04048 * @brief Initialization function for the Q31 IIR lattice filter. 04049 * @param[in] *S points to an instance of the Q31 IIR lattice structure. 04050 * @param[in] numStages number of stages in the filter. 04051 * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 04052 * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 04053 * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize. 04054 * @param[in] blockSize number of samples to process. 04055 * @return none. 04056 */ 04057 04058 void arm_iir_lattice_init_q31( 04059 arm_iir_lattice_instance_q31 * S, 04060 uint16_t numStages, 04061 q31_t * pkCoeffs, 04062 q31_t * pvCoeffs, 04063 q31_t * pState, 04064 uint32_t blockSize); 04065 04066 04067 /** 04068 * @brief Processing function for the Q15 IIR lattice filter. 04069 * @param[in] *S points to an instance of the Q15 IIR lattice structure. 04070 * @param[in] *pSrc points to the block of input data. 04071 * @param[out] *pDst points to the block of output data. 04072 * @param[in] blockSize number of samples to process. 04073 * @return none. 04074 */ 04075 04076 void arm_iir_lattice_q15( 04077 const arm_iir_lattice_instance_q15 * S, 04078 q15_t * pSrc, 04079 q15_t * pDst, 04080 uint32_t blockSize); 04081 04082 04083 /** 04084 * @brief Initialization function for the Q15 IIR lattice filter. 04085 * @param[in] *S points to an instance of the fixed-point Q15 IIR lattice structure. 04086 * @param[in] numStages number of stages in the filter. 04087 * @param[in] *pkCoeffs points to reflection coefficient buffer. The array is of length numStages. 04088 * @param[in] *pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. 04089 * @param[in] *pState points to state buffer. The array is of length numStages+blockSize. 04090 * @param[in] blockSize number of samples to process per call. 04091 * @return none. 04092 */ 04093 04094 void arm_iir_lattice_init_q15( 04095 arm_iir_lattice_instance_q15 * S, 04096 uint16_t numStages, 04097 q15_t * pkCoeffs, 04098 q15_t * pvCoeffs, 04099 q15_t * pState, 04100 uint32_t blockSize); 04101 04102 /** 04103 * @brief Instance structure for the floating-point LMS filter. 04104 */ 04105 04106 typedef struct 04107 { 04108 uint16_t numTaps; /**< number of coefficients in the filter. */ 04109 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04110 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04111 float32_t mu; /**< step size that controls filter coefficient updates. */ 04112 } arm_lms_instance_f32; 04113 04114 /** 04115 * @brief Processing function for floating-point LMS filter. 04116 * @param[in] *S points to an instance of the floating-point LMS filter structure. 04117 * @param[in] *pSrc points to the block of input data. 04118 * @param[in] *pRef points to the block of reference data. 04119 * @param[out] *pOut points to the block of output data. 04120 * @param[out] *pErr points to the block of error data. 04121 * @param[in] blockSize number of samples to process. 04122 * @return none. 04123 */ 04124 04125 void arm_lms_f32( 04126 const arm_lms_instance_f32 * S, 04127 float32_t * pSrc, 04128 float32_t * pRef, 04129 float32_t * pOut, 04130 float32_t * pErr, 04131 uint32_t blockSize); 04132 04133 /** 04134 * @brief Initialization function for floating-point LMS filter. 04135 * @param[in] *S points to an instance of the floating-point LMS filter structure. 04136 * @param[in] numTaps number of filter coefficients. 04137 * @param[in] *pCoeffs points to the coefficient buffer. 04138 * @param[in] *pState points to state buffer. 04139 * @param[in] mu step size that controls filter coefficient updates. 04140 * @param[in] blockSize number of samples to process. 04141 * @return none. 04142 */ 04143 04144 void arm_lms_init_f32( 04145 arm_lms_instance_f32 * S, 04146 uint16_t numTaps, 04147 float32_t * pCoeffs, 04148 float32_t * pState, 04149 float32_t mu, 04150 uint32_t blockSize); 04151 04152 /** 04153 * @brief Instance structure for the Q15 LMS filter. 04154 */ 04155 04156 typedef struct 04157 { 04158 uint16_t numTaps; /**< number of coefficients in the filter. */ 04159 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04160 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04161 q15_t mu; /**< step size that controls filter coefficient updates. */ 04162 uint32_t postShift; /**< bit shift applied to coefficients. */ 04163 } arm_lms_instance_q15; 04164 04165 04166 /** 04167 * @brief Initialization function for the Q15 LMS filter. 04168 * @param[in] *S points to an instance of the Q15 LMS filter structure. 04169 * @param[in] numTaps number of filter coefficients. 04170 * @param[in] *pCoeffs points to the coefficient buffer. 04171 * @param[in] *pState points to the state buffer. 04172 * @param[in] mu step size that controls filter coefficient updates. 04173 * @param[in] blockSize number of samples to process. 04174 * @param[in] postShift bit shift applied to coefficients. 04175 * @return none. 04176 */ 04177 04178 void arm_lms_init_q15( 04179 arm_lms_instance_q15 * S, 04180 uint16_t numTaps, 04181 q15_t * pCoeffs, 04182 q15_t * pState, 04183 q15_t mu, 04184 uint32_t blockSize, 04185 uint32_t postShift); 04186 04187 /** 04188 * @brief Processing function for Q15 LMS filter. 04189 * @param[in] *S points to an instance of the Q15 LMS filter structure. 04190 * @param[in] *pSrc points to the block of input data. 04191 * @param[in] *pRef points to the block of reference data. 04192 * @param[out] *pOut points to the block of output data. 04193 * @param[out] *pErr points to the block of error data. 04194 * @param[in] blockSize number of samples to process. 04195 * @return none. 04196 */ 04197 04198 void arm_lms_q15( 04199 const arm_lms_instance_q15 * S, 04200 q15_t * pSrc, 04201 q15_t * pRef, 04202 q15_t * pOut, 04203 q15_t * pErr, 04204 uint32_t blockSize); 04205 04206 04207 /** 04208 * @brief Instance structure for the Q31 LMS filter. 04209 */ 04210 04211 typedef struct 04212 { 04213 uint16_t numTaps; /**< number of coefficients in the filter. */ 04214 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04215 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04216 q31_t mu; /**< step size that controls filter coefficient updates. */ 04217 uint32_t postShift; /**< bit shift applied to coefficients. */ 04218 04219 } arm_lms_instance_q31; 04220 04221 /** 04222 * @brief Processing function for Q31 LMS filter. 04223 * @param[in] *S points to an instance of the Q15 LMS filter structure. 04224 * @param[in] *pSrc points to the block of input data. 04225 * @param[in] *pRef points to the block of reference data. 04226 * @param[out] *pOut points to the block of output data. 04227 * @param[out] *pErr points to the block of error data. 04228 * @param[in] blockSize number of samples to process. 04229 * @return none. 04230 */ 04231 04232 void arm_lms_q31( 04233 const arm_lms_instance_q31 * S, 04234 q31_t * pSrc, 04235 q31_t * pRef, 04236 q31_t * pOut, 04237 q31_t * pErr, 04238 uint32_t blockSize); 04239 04240 /** 04241 * @brief Initialization function for Q31 LMS filter. 04242 * @param[in] *S points to an instance of the Q31 LMS filter structure. 04243 * @param[in] numTaps number of filter coefficients. 04244 * @param[in] *pCoeffs points to coefficient buffer. 04245 * @param[in] *pState points to state buffer. 04246 * @param[in] mu step size that controls filter coefficient updates. 04247 * @param[in] blockSize number of samples to process. 04248 * @param[in] postShift bit shift applied to coefficients. 04249 * @return none. 04250 */ 04251 04252 void arm_lms_init_q31( 04253 arm_lms_instance_q31 * S, 04254 uint16_t numTaps, 04255 q31_t * pCoeffs, 04256 q31_t * pState, 04257 q31_t mu, 04258 uint32_t blockSize, 04259 uint32_t postShift); 04260 04261 /** 04262 * @brief Instance structure for the floating-point normalized LMS filter. 04263 */ 04264 04265 typedef struct 04266 { 04267 uint16_t numTaps; /**< number of coefficients in the filter. */ 04268 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04269 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04270 float32_t mu; /**< step size that control filter coefficient updates. */ 04271 float32_t energy; /**< saves previous frame energy. */ 04272 float32_t x0; /**< saves previous input sample. */ 04273 } arm_lms_norm_instance_f32; 04274 04275 /** 04276 * @brief Processing function for floating-point normalized LMS filter. 04277 * @param[in] *S points to an instance of the floating-point normalized LMS filter structure. 04278 * @param[in] *pSrc points to the block of input data. 04279 * @param[in] *pRef points to the block of reference data. 04280 * @param[out] *pOut points to the block of output data. 04281 * @param[out] *pErr points to the block of error data. 04282 * @param[in] blockSize number of samples to process. 04283 * @return none. 04284 */ 04285 04286 void arm_lms_norm_f32( 04287 arm_lms_norm_instance_f32 * S, 04288 float32_t * pSrc, 04289 float32_t * pRef, 04290 float32_t * pOut, 04291 float32_t * pErr, 04292 uint32_t blockSize); 04293 04294 /** 04295 * @brief Initialization function for floating-point normalized LMS filter. 04296 * @param[in] *S points to an instance of the floating-point LMS filter structure. 04297 * @param[in] numTaps number of filter coefficients. 04298 * @param[in] *pCoeffs points to coefficient buffer. 04299 * @param[in] *pState points to state buffer. 04300 * @param[in] mu step size that controls filter coefficient updates. 04301 * @param[in] blockSize number of samples to process. 04302 * @return none. 04303 */ 04304 04305 void arm_lms_norm_init_f32( 04306 arm_lms_norm_instance_f32 * S, 04307 uint16_t numTaps, 04308 float32_t * pCoeffs, 04309 float32_t * pState, 04310 float32_t mu, 04311 uint32_t blockSize); 04312 04313 04314 /** 04315 * @brief Instance structure for the Q31 normalized LMS filter. 04316 */ 04317 typedef struct 04318 { 04319 uint16_t numTaps; /**< number of coefficients in the filter. */ 04320 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04321 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04322 q31_t mu; /**< step size that controls filter coefficient updates. */ 04323 uint8_t postShift; /**< bit shift applied to coefficients. */ 04324 q31_t *recipTable; /**< points to the reciprocal initial value table. */ 04325 q31_t energy; /**< saves previous frame energy. */ 04326 q31_t x0; /**< saves previous input sample. */ 04327 } arm_lms_norm_instance_q31; 04328 04329 /** 04330 * @brief Processing function for Q31 normalized LMS filter. 04331 * @param[in] *S points to an instance of the Q31 normalized LMS filter structure. 04332 * @param[in] *pSrc points to the block of input data. 04333 * @param[in] *pRef points to the block of reference data. 04334 * @param[out] *pOut points to the block of output data. 04335 * @param[out] *pErr points to the block of error data. 04336 * @param[in] blockSize number of samples to process. 04337 * @return none. 04338 */ 04339 04340 void arm_lms_norm_q31( 04341 arm_lms_norm_instance_q31 * S, 04342 q31_t * pSrc, 04343 q31_t * pRef, 04344 q31_t * pOut, 04345 q31_t * pErr, 04346 uint32_t blockSize); 04347 04348 /** 04349 * @brief Initialization function for Q31 normalized LMS filter. 04350 * @param[in] *S points to an instance of the Q31 normalized LMS filter structure. 04351 * @param[in] numTaps number of filter coefficients. 04352 * @param[in] *pCoeffs points to coefficient buffer. 04353 * @param[in] *pState points to state buffer. 04354 * @param[in] mu step size that controls filter coefficient updates. 04355 * @param[in] blockSize number of samples to process. 04356 * @param[in] postShift bit shift applied to coefficients. 04357 * @return none. 04358 */ 04359 04360 void arm_lms_norm_init_q31( 04361 arm_lms_norm_instance_q31 * S, 04362 uint16_t numTaps, 04363 q31_t * pCoeffs, 04364 q31_t * pState, 04365 q31_t mu, 04366 uint32_t blockSize, 04367 uint8_t postShift); 04368 04369 /** 04370 * @brief Instance structure for the Q15 normalized LMS filter. 04371 */ 04372 04373 typedef struct 04374 { 04375 uint16_t numTaps; /**< Number of coefficients in the filter. */ 04376 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 04377 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 04378 q15_t mu; /**< step size that controls filter coefficient updates. */ 04379 uint8_t postShift; /**< bit shift applied to coefficients. */ 04380 q15_t *recipTable; /**< Points to the reciprocal initial value table. */ 04381 q15_t energy; /**< saves previous frame energy. */ 04382 q15_t x0; /**< saves previous input sample. */ 04383 } arm_lms_norm_instance_q15; 04384 04385 /** 04386 * @brief Processing function for Q15 normalized LMS filter. 04387 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure. 04388 * @param[in] *pSrc points to the block of input data. 04389 * @param[in] *pRef points to the block of reference data. 04390 * @param[out] *pOut points to the block of output data. 04391 * @param[out] *pErr points to the block of error data. 04392 * @param[in] blockSize number of samples to process. 04393 * @return none. 04394 */ 04395 04396 void arm_lms_norm_q15( 04397 arm_lms_norm_instance_q15 * S, 04398 q15_t * pSrc, 04399 q15_t * pRef, 04400 q15_t * pOut, 04401 q15_t * pErr, 04402 uint32_t blockSize); 04403 04404 04405 /** 04406 * @brief Initialization function for Q15 normalized LMS filter. 04407 * @param[in] *S points to an instance of the Q15 normalized LMS filter structure. 04408 * @param[in] numTaps number of filter coefficients. 04409 * @param[in] *pCoeffs points to coefficient buffer. 04410 * @param[in] *pState points to state buffer. 04411 * @param[in] mu step size that controls filter coefficient updates. 04412 * @param[in] blockSize number of samples to process. 04413 * @param[in] postShift bit shift applied to coefficients. 04414 * @return none. 04415 */ 04416 04417 void arm_lms_norm_init_q15( 04418 arm_lms_norm_instance_q15 * S, 04419 uint16_t numTaps, 04420 q15_t * pCoeffs, 04421 q15_t * pState, 04422 q15_t mu, 04423 uint32_t blockSize, 04424 uint8_t postShift); 04425 04426 /** 04427 * @brief Correlation of floating-point sequences. 04428 * @param[in] *pSrcA points to the first input sequence. 04429 * @param[in] srcALen length of the first input sequence. 04430 * @param[in] *pSrcB points to the second input sequence. 04431 * @param[in] srcBLen length of the second input sequence. 04432 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04433 * @return none. 04434 */ 04435 04436 void arm_correlate_f32( 04437 float32_t * pSrcA, 04438 uint32_t srcALen, 04439 float32_t * pSrcB, 04440 uint32_t srcBLen, 04441 float32_t * pDst); 04442 04443 04444 /** 04445 * @brief Correlation of Q15 sequences 04446 * @param[in] *pSrcA points to the first input sequence. 04447 * @param[in] srcALen length of the first input sequence. 04448 * @param[in] *pSrcB points to the second input sequence. 04449 * @param[in] srcBLen length of the second input sequence. 04450 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04451 * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 04452 * @return none. 04453 */ 04454 void arm_correlate_opt_q15( 04455 q15_t * pSrcA, 04456 uint32_t srcALen, 04457 q15_t * pSrcB, 04458 uint32_t srcBLen, 04459 q15_t * pDst, 04460 q15_t * pScratch); 04461 04462 04463 /** 04464 * @brief Correlation of Q15 sequences. 04465 * @param[in] *pSrcA points to the first input sequence. 04466 * @param[in] srcALen length of the first input sequence. 04467 * @param[in] *pSrcB points to the second input sequence. 04468 * @param[in] srcBLen length of the second input sequence. 04469 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04470 * @return none. 04471 */ 04472 04473 void arm_correlate_q15( 04474 q15_t * pSrcA, 04475 uint32_t srcALen, 04476 q15_t * pSrcB, 04477 uint32_t srcBLen, 04478 q15_t * pDst); 04479 04480 /** 04481 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4. 04482 * @param[in] *pSrcA points to the first input sequence. 04483 * @param[in] srcALen length of the first input sequence. 04484 * @param[in] *pSrcB points to the second input sequence. 04485 * @param[in] srcBLen length of the second input sequence. 04486 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04487 * @return none. 04488 */ 04489 04490 void arm_correlate_fast_q15( 04491 q15_t * pSrcA, 04492 uint32_t srcALen, 04493 q15_t * pSrcB, 04494 uint32_t srcBLen, 04495 q15_t * pDst); 04496 04497 04498 04499 /** 04500 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4. 04501 * @param[in] *pSrcA points to the first input sequence. 04502 * @param[in] srcALen length of the first input sequence. 04503 * @param[in] *pSrcB points to the second input sequence. 04504 * @param[in] srcBLen length of the second input sequence. 04505 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04506 * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 04507 * @return none. 04508 */ 04509 04510 void arm_correlate_fast_opt_q15( 04511 q15_t * pSrcA, 04512 uint32_t srcALen, 04513 q15_t * pSrcB, 04514 uint32_t srcBLen, 04515 q15_t * pDst, 04516 q15_t * pScratch); 04517 04518 /** 04519 * @brief Correlation of Q31 sequences. 04520 * @param[in] *pSrcA points to the first input sequence. 04521 * @param[in] srcALen length of the first input sequence. 04522 * @param[in] *pSrcB points to the second input sequence. 04523 * @param[in] srcBLen length of the second input sequence. 04524 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04525 * @return none. 04526 */ 04527 04528 void arm_correlate_q31( 04529 q31_t * pSrcA, 04530 uint32_t srcALen, 04531 q31_t * pSrcB, 04532 uint32_t srcBLen, 04533 q31_t * pDst); 04534 04535 /** 04536 * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 04537 * @param[in] *pSrcA points to the first input sequence. 04538 * @param[in] srcALen length of the first input sequence. 04539 * @param[in] *pSrcB points to the second input sequence. 04540 * @param[in] srcBLen length of the second input sequence. 04541 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04542 * @return none. 04543 */ 04544 04545 void arm_correlate_fast_q31( 04546 q31_t * pSrcA, 04547 uint32_t srcALen, 04548 q31_t * pSrcB, 04549 uint32_t srcBLen, 04550 q31_t * pDst); 04551 04552 04553 04554 /** 04555 * @brief Correlation of Q7 sequences. 04556 * @param[in] *pSrcA points to the first input sequence. 04557 * @param[in] srcALen length of the first input sequence. 04558 * @param[in] *pSrcB points to the second input sequence. 04559 * @param[in] srcBLen length of the second input sequence. 04560 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04561 * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 04562 * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 04563 * @return none. 04564 */ 04565 04566 void arm_correlate_opt_q7( 04567 q7_t * pSrcA, 04568 uint32_t srcALen, 04569 q7_t * pSrcB, 04570 uint32_t srcBLen, 04571 q7_t * pDst, 04572 q15_t * pScratch1, 04573 q15_t * pScratch2); 04574 04575 04576 /** 04577 * @brief Correlation of Q7 sequences. 04578 * @param[in] *pSrcA points to the first input sequence. 04579 * @param[in] srcALen length of the first input sequence. 04580 * @param[in] *pSrcB points to the second input sequence. 04581 * @param[in] srcBLen length of the second input sequence. 04582 * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 04583 * @return none. 04584 */ 04585 04586 void arm_correlate_q7( 04587 q7_t * pSrcA, 04588 uint32_t srcALen, 04589 q7_t * pSrcB, 04590 uint32_t srcBLen, 04591 q7_t * pDst); 04592 04593 04594 /** 04595 * @brief Instance structure for the floating-point sparse FIR filter. 04596 */ 04597 typedef struct 04598 { 04599 uint16_t numTaps; /**< number of coefficients in the filter. */ 04600 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04601 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04602 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04603 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04604 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04605 } arm_fir_sparse_instance_f32; 04606 04607 /** 04608 * @brief Instance structure for the Q31 sparse FIR filter. 04609 */ 04610 04611 typedef struct 04612 { 04613 uint16_t numTaps; /**< number of coefficients in the filter. */ 04614 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04615 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04616 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04617 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04618 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04619 } arm_fir_sparse_instance_q31; 04620 04621 /** 04622 * @brief Instance structure for the Q15 sparse FIR filter. 04623 */ 04624 04625 typedef struct 04626 { 04627 uint16_t numTaps; /**< number of coefficients in the filter. */ 04628 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04629 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04630 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04631 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04632 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04633 } arm_fir_sparse_instance_q15; 04634 04635 /** 04636 * @brief Instance structure for the Q7 sparse FIR filter. 04637 */ 04638 04639 typedef struct 04640 { 04641 uint16_t numTaps; /**< number of coefficients in the filter. */ 04642 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 04643 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 04644 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 04645 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 04646 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 04647 } arm_fir_sparse_instance_q7; 04648 04649 /** 04650 * @brief Processing function for the floating-point sparse FIR filter. 04651 * @param[in] *S points to an instance of the floating-point sparse FIR structure. 04652 * @param[in] *pSrc points to the block of input data. 04653 * @param[out] *pDst points to the block of output data 04654 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04655 * @param[in] blockSize number of input samples to process per call. 04656 * @return none. 04657 */ 04658 04659 void arm_fir_sparse_f32( 04660 arm_fir_sparse_instance_f32 * S, 04661 float32_t * pSrc, 04662 float32_t * pDst, 04663 float32_t * pScratchIn, 04664 uint32_t blockSize); 04665 04666 /** 04667 * @brief Initialization function for the floating-point sparse FIR filter. 04668 * @param[in,out] *S points to an instance of the floating-point sparse FIR structure. 04669 * @param[in] numTaps number of nonzero coefficients in the filter. 04670 * @param[in] *pCoeffs points to the array of filter coefficients. 04671 * @param[in] *pState points to the state buffer. 04672 * @param[in] *pTapDelay points to the array of offset times. 04673 * @param[in] maxDelay maximum offset time supported. 04674 * @param[in] blockSize number of samples that will be processed per block. 04675 * @return none 04676 */ 04677 04678 void arm_fir_sparse_init_f32( 04679 arm_fir_sparse_instance_f32 * S, 04680 uint16_t numTaps, 04681 float32_t * pCoeffs, 04682 float32_t * pState, 04683 int32_t * pTapDelay, 04684 uint16_t maxDelay, 04685 uint32_t blockSize); 04686 04687 /** 04688 * @brief Processing function for the Q31 sparse FIR filter. 04689 * @param[in] *S points to an instance of the Q31 sparse FIR structure. 04690 * @param[in] *pSrc points to the block of input data. 04691 * @param[out] *pDst points to the block of output data 04692 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04693 * @param[in] blockSize number of input samples to process per call. 04694 * @return none. 04695 */ 04696 04697 void arm_fir_sparse_q31( 04698 arm_fir_sparse_instance_q31 * S, 04699 q31_t * pSrc, 04700 q31_t * pDst, 04701 q31_t * pScratchIn, 04702 uint32_t blockSize); 04703 04704 /** 04705 * @brief Initialization function for the Q31 sparse FIR filter. 04706 * @param[in,out] *S points to an instance of the Q31 sparse FIR structure. 04707 * @param[in] numTaps number of nonzero coefficients in the filter. 04708 * @param[in] *pCoeffs points to the array of filter coefficients. 04709 * @param[in] *pState points to the state buffer. 04710 * @param[in] *pTapDelay points to the array of offset times. 04711 * @param[in] maxDelay maximum offset time supported. 04712 * @param[in] blockSize number of samples that will be processed per block. 04713 * @return none 04714 */ 04715 04716 void arm_fir_sparse_init_q31( 04717 arm_fir_sparse_instance_q31 * S, 04718 uint16_t numTaps, 04719 q31_t * pCoeffs, 04720 q31_t * pState, 04721 int32_t * pTapDelay, 04722 uint16_t maxDelay, 04723 uint32_t blockSize); 04724 04725 /** 04726 * @brief Processing function for the Q15 sparse FIR filter. 04727 * @param[in] *S points to an instance of the Q15 sparse FIR structure. 04728 * @param[in] *pSrc points to the block of input data. 04729 * @param[out] *pDst points to the block of output data 04730 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04731 * @param[in] *pScratchOut points to a temporary buffer of size blockSize. 04732 * @param[in] blockSize number of input samples to process per call. 04733 * @return none. 04734 */ 04735 04736 void arm_fir_sparse_q15( 04737 arm_fir_sparse_instance_q15 * S, 04738 q15_t * pSrc, 04739 q15_t * pDst, 04740 q15_t * pScratchIn, 04741 q31_t * pScratchOut, 04742 uint32_t blockSize); 04743 04744 04745 /** 04746 * @brief Initialization function for the Q15 sparse FIR filter. 04747 * @param[in,out] *S points to an instance of the Q15 sparse FIR structure. 04748 * @param[in] numTaps number of nonzero coefficients in the filter. 04749 * @param[in] *pCoeffs points to the array of filter coefficients. 04750 * @param[in] *pState points to the state buffer. 04751 * @param[in] *pTapDelay points to the array of offset times. 04752 * @param[in] maxDelay maximum offset time supported. 04753 * @param[in] blockSize number of samples that will be processed per block. 04754 * @return none 04755 */ 04756 04757 void arm_fir_sparse_init_q15( 04758 arm_fir_sparse_instance_q15 * S, 04759 uint16_t numTaps, 04760 q15_t * pCoeffs, 04761 q15_t * pState, 04762 int32_t * pTapDelay, 04763 uint16_t maxDelay, 04764 uint32_t blockSize); 04765 04766 /** 04767 * @brief Processing function for the Q7 sparse FIR filter. 04768 * @param[in] *S points to an instance of the Q7 sparse FIR structure. 04769 * @param[in] *pSrc points to the block of input data. 04770 * @param[out] *pDst points to the block of output data 04771 * @param[in] *pScratchIn points to a temporary buffer of size blockSize. 04772 * @param[in] *pScratchOut points to a temporary buffer of size blockSize. 04773 * @param[in] blockSize number of input samples to process per call. 04774 * @return none. 04775 */ 04776 04777 void arm_fir_sparse_q7( 04778 arm_fir_sparse_instance_q7 * S, 04779 q7_t * pSrc, 04780 q7_t * pDst, 04781 q7_t * pScratchIn, 04782 q31_t * pScratchOut, 04783 uint32_t blockSize); 04784 04785 /** 04786 * @brief Initialization function for the Q7 sparse FIR filter. 04787 * @param[in,out] *S points to an instance of the Q7 sparse FIR structure. 04788 * @param[in] numTaps number of nonzero coefficients in the filter. 04789 * @param[in] *pCoeffs points to the array of filter coefficients. 04790 * @param[in] *pState points to the state buffer. 04791 * @param[in] *pTapDelay points to the array of offset times. 04792 * @param[in] maxDelay maximum offset time supported. 04793 * @param[in] blockSize number of samples that will be processed per block. 04794 * @return none 04795 */ 04796 04797 void arm_fir_sparse_init_q7( 04798 arm_fir_sparse_instance_q7 * S, 04799 uint16_t numTaps, 04800 q7_t * pCoeffs, 04801 q7_t * pState, 04802 int32_t * pTapDelay, 04803 uint16_t maxDelay, 04804 uint32_t blockSize); 04805 04806 04807 /* 04808 * @brief Floating-point sin_cos function. 04809 * @param[in] theta input value in degrees 04810 * @param[out] *pSinVal points to the processed sine output. 04811 * @param[out] *pCosVal points to the processed cos output. 04812 * @return none. 04813 */ 04814 04815 void arm_sin_cos_f32( 04816 float32_t theta, 04817 float32_t * pSinVal, 04818 float32_t * pCcosVal); 04819 04820 /* 04821 * @brief Q31 sin_cos function. 04822 * @param[in] theta scaled input value in degrees 04823 * @param[out] *pSinVal points to the processed sine output. 04824 * @param[out] *pCosVal points to the processed cosine output. 04825 * @return none. 04826 */ 04827 04828 void arm_sin_cos_q31( 04829 q31_t theta, 04830 q31_t * pSinVal, 04831 q31_t * pCosVal); 04832 04833 04834 /** 04835 * @brief Floating-point complex conjugate. 04836 * @param[in] *pSrc points to the input vector 04837 * @param[out] *pDst points to the output vector 04838 * @param[in] numSamples number of complex samples in each vector 04839 * @return none. 04840 */ 04841 04842 void arm_cmplx_conj_f32( 04843 float32_t * pSrc, 04844 float32_t * pDst, 04845 uint32_t numSamples); 04846 04847 /** 04848 * @brief Q31 complex conjugate. 04849 * @param[in] *pSrc points to the input vector 04850 * @param[out] *pDst points to the output vector 04851 * @param[in] numSamples number of complex samples in each vector 04852 * @return none. 04853 */ 04854 04855 void arm_cmplx_conj_q31( 04856 q31_t * pSrc, 04857 q31_t * pDst, 04858 uint32_t numSamples); 04859 04860 /** 04861 * @brief Q15 complex conjugate. 04862 * @param[in] *pSrc points to the input vector 04863 * @param[out] *pDst points to the output vector 04864 * @param[in] numSamples number of complex samples in each vector 04865 * @return none. 04866 */ 04867 04868 void arm_cmplx_conj_q15( 04869 q15_t * pSrc, 04870 q15_t * pDst, 04871 uint32_t numSamples); 04872 04873 04874 04875 /** 04876 * @brief Floating-point complex magnitude squared 04877 * @param[in] *pSrc points to the complex input vector 04878 * @param[out] *pDst points to the real output vector 04879 * @param[in] numSamples number of complex samples in the input vector 04880 * @return none. 04881 */ 04882 04883 void arm_cmplx_mag_squared_f32( 04884 float32_t * pSrc, 04885 float32_t * pDst, 04886 uint32_t numSamples); 04887 04888 /** 04889 * @brief Q31 complex magnitude squared 04890 * @param[in] *pSrc points to the complex input vector 04891 * @param[out] *pDst points to the real output vector 04892 * @param[in] numSamples number of complex samples in the input vector 04893 * @return none. 04894 */ 04895 04896 void arm_cmplx_mag_squared_q31( 04897 q31_t * pSrc, 04898 q31_t * pDst, 04899 uint32_t numSamples); 04900 04901 /** 04902 * @brief Q15 complex magnitude squared 04903 * @param[in] *pSrc points to the complex input vector 04904 * @param[out] *pDst points to the real output vector 04905 * @param[in] numSamples number of complex samples in the input vector 04906 * @return none. 04907 */ 04908 04909 void arm_cmplx_mag_squared_q15( 04910 q15_t * pSrc, 04911 q15_t * pDst, 04912 uint32_t numSamples); 04913 04914 04915 /** 04916 * @ingroup groupController 04917 */ 04918 04919 /** 04920 * @defgroup PID PID Motor Control 04921 * 04922 * A Proportional Integral Derivative (PID) controller is a generic feedback control 04923 * loop mechanism widely used in industrial control systems. 04924 * A PID controller is the most commonly used type of feedback controller. 04925 * 04926 * This set of functions implements (PID) controllers 04927 * for Q15, Q31, and floating-point data types. The functions operate on a single sample 04928 * of data and each call to the function returns a single processed value. 04929 * <code>S</code> points to an instance of the PID control data structure. <code>in</code> 04930 * is the input sample value. The functions return the output value. 04931 * 04932 * \par Algorithm: 04933 * <pre> 04934 * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] 04935 * A0 = Kp + Ki + Kd 04936 * A1 = (-Kp ) - (2 * Kd ) 04937 * A2 = Kd </pre> 04938 * 04939 * \par 04940 * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant 04941 * 04942 * \par 04943 * \image html PID.gif "Proportional Integral Derivative Controller" 04944 * 04945 * \par 04946 * The PID controller calculates an "error" value as the difference between 04947 * the measured output and the reference input. 04948 * The controller attempts to minimize the error by adjusting the process control inputs. 04949 * The proportional value determines the reaction to the current error, 04950 * the integral value determines the reaction based on the sum of recent errors, 04951 * and the derivative value determines the reaction based on the rate at which the error has been changing. 04952 * 04953 * \par Instance Structure 04954 * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure. 04955 * A separate instance structure must be defined for each PID Controller. 04956 * There are separate instance structure declarations for each of the 3 supported data types. 04957 * 04958 * \par Reset Functions 04959 * There is also an associated reset function for each data type which clears the state array. 04960 * 04961 * \par Initialization Functions 04962 * There is also an associated initialization function for each data type. 04963 * The initialization function performs the following operations: 04964 * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains. 04965 * - Zeros out the values in the state buffer. 04966 * 04967 * \par 04968 * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function. 04969 * 04970 * \par Fixed-Point Behavior 04971 * Care must be taken when using the fixed-point versions of the PID Controller functions. 04972 * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. 04973 * Refer to the function specific documentation below for usage guidelines. 04974 */ 04975 04976 /** 04977 * @addtogroup PID 04978 * @{ 04979 */ 04980 04981 /** 04982 * @brief Process function for the floating-point PID Control. 04983 * @param[in,out] *S is an instance of the floating-point PID Control structure 04984 * @param[in] in input sample to process 04985 * @return out processed output sample. 04986 */ 04987 04988 04989 static __INLINE float32_t arm_pid_f32( 04990 arm_pid_instance_f32 * S, 04991 float32_t in) 04992 { 04993 float32_t out; 04994 04995 /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */ 04996 out = (S->A0 * in) + 04997 (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]); 04998 04999 /* Update state */ 05000 S->state[1] = S->state[0]; 05001 S->state[0] = in; 05002 S->state[2] = out; 05003 05004 /* return to application */ 05005 return (out); 05006 05007 } 05008 05009 /** 05010 * @brief Process function for the Q31 PID Control. 05011 * @param[in,out] *S points to an instance of the Q31 PID Control structure 05012 * @param[in] in input sample to process 05013 * @return out processed output sample. 05014 * 05015 * <b>Scaling and Overflow Behavior:</b> 05016 * \par 05017 * The function is implemented using an internal 64-bit accumulator. 05018 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. 05019 * Thus, if the accumulator result overflows it wraps around rather than clip. 05020 * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions. 05021 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. 05022 */ 05023 05024 static __INLINE q31_t arm_pid_q31( 05025 arm_pid_instance_q31 * S, 05026 q31_t in) 05027 { 05028 q63_t acc; 05029 q31_t out; 05030 05031 /* acc = A0 * x[n] */ 05032 acc = (q63_t) S->A0 * in; 05033 05034 /* acc += A1 * x[n-1] */ 05035 acc += (q63_t) S->A1 * S->state[0]; 05036 05037 /* acc += A2 * x[n-2] */ 05038 acc += (q63_t) S->A2 * S->state[1]; 05039 05040 /* convert output to 1.31 format to add y[n-1] */ 05041 out = (q31_t) (acc >> 31u); 05042 05043 /* out += y[n-1] */ 05044 out += S->state[2]; 05045 05046 /* Update state */ 05047 S->state[1] = S->state[0]; 05048 S->state[0] = in; 05049 S->state[2] = out; 05050 05051 /* return to application */ 05052 return (out); 05053 05054 } 05055 05056 /** 05057 * @brief Process function for the Q15 PID Control. 05058 * @param[in,out] *S points to an instance of the Q15 PID Control structure 05059 * @param[in] in input sample to process 05060 * @return out processed output sample. 05061 * 05062 * <b>Scaling and Overflow Behavior:</b> 05063 * \par 05064 * The function is implemented using a 64-bit internal accumulator. 05065 * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result. 05066 * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. 05067 * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. 05068 * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. 05069 * Lastly, the accumulator is saturated to yield a result in 1.15 format. 05070 */ 05071 05072 static __INLINE q15_t arm_pid_q15( 05073 arm_pid_instance_q15 * S, 05074 q15_t in) 05075 { 05076 q63_t acc; 05077 q15_t out; 05078 05079 #ifndef ARM_MATH_CM0_FAMILY 05080 __SIMD32_TYPE *vstate; 05081 05082 /* Implementation of PID controller */ 05083 05084 /* acc = A0 * x[n] */ 05085 acc = (q31_t) __SMUAD(S->A0, in); 05086 05087 /* acc += A1 * x[n-1] + A2 * x[n-2] */ 05088 vstate = __SIMD32_CONST(S->state); 05089 acc = __SMLALD(S->A1, (q31_t) *vstate, acc); 05090 05091 #else 05092 /* acc = A0 * x[n] */ 05093 acc = ((q31_t) S->A0) * in; 05094 05095 /* acc += A1 * x[n-1] + A2 * x[n-2] */ 05096 acc += (q31_t) S->A1 * S->state[0]; 05097 acc += (q31_t) S->A2 * S->state[1]; 05098 05099 #endif 05100 05101 /* acc += y[n-1] */ 05102 acc += (q31_t) S->state[2] << 15; 05103 05104 /* saturate the output */ 05105 out = (q15_t) (__SSAT((acc >> 15), 16)); 05106 05107 /* Update state */ 05108 S->state[1] = S->state[0]; 05109 S->state[0] = in; 05110 S->state[2] = out; 05111 05112 /* return to application */ 05113 return (out); 05114 05115 } 05116 05117 /** 05118 * @} end of PID group 05119 */ 05120 05121 05122 /** 05123 * @brief Floating-point matrix inverse. 05124 * @param[in] *src points to the instance of the input floating-point matrix structure. 05125 * @param[out] *dst points to the instance of the output floating-point matrix structure. 05126 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match. 05127 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR. 05128 */ 05129 05130 arm_status arm_mat_inverse_f32( 05131 const arm_matrix_instance_f32 * src, 05132 arm_matrix_instance_f32 * dst); 05133 05134 05135 05136 /** 05137 * @ingroup groupController 05138 */ 05139 05140 05141 /** 05142 * @defgroup clarke Vector Clarke Transform 05143 * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector. 05144 * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents 05145 * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>. 05146 * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below 05147 * \image html clarke.gif Stator current space vector and its components in (a,b). 05148 * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code> 05149 * can be calculated using only <code>Ia</code> and <code>Ib</code>. 05150 * 05151 * The function operates on a single sample of data and each call to the function returns the processed output. 05152 * The library provides separate functions for Q31 and floating-point data types. 05153 * \par Algorithm 05154 * \image html clarkeFormula.gif 05155 * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and 05156 * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector. 05157 * \par Fixed-Point Behavior 05158 * Care must be taken when using the Q31 version of the Clarke transform. 05159 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 05160 * Refer to the function specific documentation below for usage guidelines. 05161 */ 05162 05163 /** 05164 * @addtogroup clarke 05165 * @{ 05166 */ 05167 05168 /** 05169 * 05170 * @brief Floating-point Clarke transform 05171 * @param[in] Ia input three-phase coordinate <code>a</code> 05172 * @param[in] Ib input three-phase coordinate <code>b</code> 05173 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 05174 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 05175 * @return none. 05176 */ 05177 05178 static __INLINE void arm_clarke_f32( 05179 float32_t Ia, 05180 float32_t Ib, 05181 float32_t * pIalpha, 05182 float32_t * pIbeta) 05183 { 05184 /* Calculate pIalpha using the equation, pIalpha = Ia */ 05185 *pIalpha = Ia; 05186 05187 /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */ 05188 *pIbeta = 05189 ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib); 05190 05191 } 05192 05193 /** 05194 * @brief Clarke transform for Q31 version 05195 * @param[in] Ia input three-phase coordinate <code>a</code> 05196 * @param[in] Ib input three-phase coordinate <code>b</code> 05197 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 05198 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 05199 * @return none. 05200 * 05201 * <b>Scaling and Overflow Behavior:</b> 05202 * \par 05203 * The function is implemented using an internal 32-bit accumulator. 05204 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 05205 * There is saturation on the addition, hence there is no risk of overflow. 05206 */ 05207 05208 static __INLINE void arm_clarke_q31( 05209 q31_t Ia, 05210 q31_t Ib, 05211 q31_t * pIalpha, 05212 q31_t * pIbeta) 05213 { 05214 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 05215 05216 /* Calculating pIalpha from Ia by equation pIalpha = Ia */ 05217 *pIalpha = Ia; 05218 05219 /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */ 05220 product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30); 05221 05222 /* Intermediate product is calculated by (2/sqrt(3) * Ib) */ 05223 product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30); 05224 05225 /* pIbeta is calculated by adding the intermediate products */ 05226 *pIbeta = __QADD(product1, product2); 05227 } 05228 05229 /** 05230 * @} end of clarke group 05231 */ 05232 05233 /** 05234 * @brief Converts the elements of the Q7 vector to Q31 vector. 05235 * @param[in] *pSrc input pointer 05236 * @param[out] *pDst output pointer 05237 * @param[in] blockSize number of samples to process 05238 * @return none. 05239 */ 05240 void arm_q7_to_q31( 05241 q7_t * pSrc, 05242 q31_t * pDst, 05243 uint32_t blockSize); 05244 05245 05246 05247 05248 /** 05249 * @ingroup groupController 05250 */ 05251 05252 /** 05253 * @defgroup inv_clarke Vector Inverse Clarke Transform 05254 * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases. 05255 * 05256 * The function operates on a single sample of data and each call to the function returns the processed output. 05257 * The library provides separate functions for Q31 and floating-point data types. 05258 * \par Algorithm 05259 * \image html clarkeInvFormula.gif 05260 * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and 05261 * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector. 05262 * \par Fixed-Point Behavior 05263 * Care must be taken when using the Q31 version of the Clarke transform. 05264 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 05265 * Refer to the function specific documentation below for usage guidelines. 05266 */ 05267 05268 /** 05269 * @addtogroup inv_clarke 05270 * @{ 05271 */ 05272 05273 /** 05274 * @brief Floating-point Inverse Clarke transform 05275 * @param[in] Ialpha input two-phase orthogonal vector axis alpha 05276 * @param[in] Ibeta input two-phase orthogonal vector axis beta 05277 * @param[out] *pIa points to output three-phase coordinate <code>a</code> 05278 * @param[out] *pIb points to output three-phase coordinate <code>b</code> 05279 * @return none. 05280 */ 05281 05282 05283 static __INLINE void arm_inv_clarke_f32( 05284 float32_t Ialpha, 05285 float32_t Ibeta, 05286 float32_t * pIa, 05287 float32_t * pIb) 05288 { 05289 /* Calculating pIa from Ialpha by equation pIa = Ialpha */ 05290 *pIa = Ialpha; 05291 05292 /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */ 05293 *pIb = -0.5 * Ialpha + (float32_t) 0.8660254039 *Ibeta; 05294 05295 } 05296 05297 /** 05298 * @brief Inverse Clarke transform for Q31 version 05299 * @param[in] Ialpha input two-phase orthogonal vector axis alpha 05300 * @param[in] Ibeta input two-phase orthogonal vector axis beta 05301 * @param[out] *pIa points to output three-phase coordinate <code>a</code> 05302 * @param[out] *pIb points to output three-phase coordinate <code>b</code> 05303 * @return none. 05304 * 05305 * <b>Scaling and Overflow Behavior:</b> 05306 * \par 05307 * The function is implemented using an internal 32-bit accumulator. 05308 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 05309 * There is saturation on the subtraction, hence there is no risk of overflow. 05310 */ 05311 05312 static __INLINE void arm_inv_clarke_q31( 05313 q31_t Ialpha, 05314 q31_t Ibeta, 05315 q31_t * pIa, 05316 q31_t * pIb) 05317 { 05318 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 05319 05320 /* Calculating pIa from Ialpha by equation pIa = Ialpha */ 05321 *pIa = Ialpha; 05322 05323 /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */ 05324 product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31); 05325 05326 /* Intermediate product is calculated by (1/sqrt(3) * pIb) */ 05327 product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31); 05328 05329 /* pIb is calculated by subtracting the products */ 05330 *pIb = __QSUB(product2, product1); 05331 05332 } 05333 05334 /** 05335 * @} end of inv_clarke group 05336 */ 05337 05338 /** 05339 * @brief Converts the elements of the Q7 vector to Q15 vector. 05340 * @param[in] *pSrc input pointer 05341 * @param[out] *pDst output pointer 05342 * @param[in] blockSize number of samples to process 05343 * @return none. 05344 */ 05345 void arm_q7_to_q15( 05346 q7_t * pSrc, 05347 q15_t * pDst, 05348 uint32_t blockSize); 05349 05350 05351 05352 /** 05353 * @ingroup groupController 05354 */ 05355 05356 /** 05357 * @defgroup park Vector Park Transform 05358 * 05359 * Forward Park transform converts the input two-coordinate vector to flux and torque components. 05360 * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents 05361 * from the stationary to the moving reference frame and control the spatial relationship between 05362 * the stator vector current and rotor flux vector. 05363 * If we consider the d axis aligned with the rotor flux, the diagram below shows the 05364 * current vector and the relationship from the two reference frames: 05365 * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame" 05366 * 05367 * The function operates on a single sample of data and each call to the function returns the processed output. 05368 * The library provides separate functions for Q31 and floating-point data types. 05369 * \par Algorithm 05370 * \image html parkFormula.gif 05371 * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components, 05372 * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the 05373 * cosine and sine values of theta (rotor flux position). 05374 * \par Fixed-Point Behavior 05375 * Care must be taken when using the Q31 version of the Park transform. 05376 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 05377 * Refer to the function specific documentation below for usage guidelines. 05378 */ 05379 05380 /** 05381 * @addtogroup park 05382 * @{ 05383 */ 05384 05385 /** 05386 * @brief Floating-point Park transform 05387 * @param[in] Ialpha input two-phase vector coordinate alpha 05388 * @param[in] Ibeta input two-phase vector coordinate beta 05389 * @param[out] *pId points to output rotor reference frame d 05390 * @param[out] *pIq points to output rotor reference frame q 05391 * @param[in] sinVal sine value of rotation angle theta 05392 * @param[in] cosVal cosine value of rotation angle theta 05393 * @return none. 05394 * 05395 * The function implements the forward Park transform. 05396 * 05397 */ 05398 05399 static __INLINE void arm_park_f32( 05400 float32_t Ialpha, 05401 float32_t Ibeta, 05402 float32_t * pId, 05403 float32_t * pIq, 05404 float32_t sinVal, 05405 float32_t cosVal) 05406 { 05407 /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */ 05408 *pId = Ialpha * cosVal + Ibeta * sinVal; 05409 05410 /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */ 05411 *pIq = -Ialpha * sinVal + Ibeta * cosVal; 05412 05413 } 05414 05415 /** 05416 * @brief Park transform for Q31 version 05417 * @param[in] Ialpha input two-phase vector coordinate alpha 05418 * @param[in] Ibeta input two-phase vector coordinate beta 05419 * @param[out] *pId points to output rotor reference frame d 05420 * @param[out] *pIq points to output rotor reference frame q 05421 * @param[in] sinVal sine value of rotation angle theta 05422 * @param[in] cosVal cosine value of rotation angle theta 05423 * @return none. 05424 * 05425 * <b>Scaling and Overflow Behavior:</b> 05426 * \par 05427 * The function is implemented using an internal 32-bit accumulator. 05428 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 05429 * There is saturation on the addition and subtraction, hence there is no risk of overflow. 05430 */ 05431 05432 05433 static __INLINE void arm_park_q31( 05434 q31_t Ialpha, 05435 q31_t Ibeta, 05436 q31_t * pId, 05437 q31_t * pIq, 05438 q31_t sinVal, 05439 q31_t cosVal) 05440 { 05441 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 05442 q31_t product3, product4; /* Temporary variables used to store intermediate results */ 05443 05444 /* Intermediate product is calculated by (Ialpha * cosVal) */ 05445 product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31); 05446 05447 /* Intermediate product is calculated by (Ibeta * sinVal) */ 05448 product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31); 05449 05450 05451 /* Intermediate product is calculated by (Ialpha * sinVal) */ 05452 product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31); 05453 05454 /* Intermediate product is calculated by (Ibeta * cosVal) */ 05455 product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31); 05456 05457 /* Calculate pId by adding the two intermediate products 1 and 2 */ 05458 *pId = __QADD(product1, product2); 05459 05460 /* Calculate pIq by subtracting the two intermediate products 3 from 4 */ 05461 *pIq = __QSUB(product4, product3); 05462 } 05463 05464 /** 05465 * @} end of park group 05466 */ 05467 05468 /** 05469 * @brief Converts the elements of the Q7 vector to floating-point vector. 05470 * @param[in] *pSrc is input pointer 05471 * @param[out] *pDst is output pointer 05472 * @param[in] blockSize is the number of samples to process 05473 * @return none. 05474 */ 05475 void arm_q7_to_float( 05476 q7_t * pSrc, 05477 float32_t * pDst, 05478 uint32_t blockSize); 05479 05480 05481 /** 05482 * @ingroup groupController 05483 */ 05484 05485 /** 05486 * @defgroup inv_park Vector Inverse Park transform 05487 * Inverse Park transform converts the input flux and torque components to two-coordinate vector. 05488 * 05489 * The function operates on a single sample of data and each call to the function returns the processed output. 05490 * The library provides separate functions for Q31 and floating-point data types. 05491 * \par Algorithm 05492 * \image html parkInvFormula.gif 05493 * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components, 05494 * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the 05495 * cosine and sine values of theta (rotor flux position). 05496 * \par Fixed-Point Behavior 05497 * Care must be taken when using the Q31 version of the Park transform. 05498 * In particular, the overflow and saturation behavior of the accumulator used must be considered. 05499 * Refer to the function specific documentation below for usage guidelines. 05500 */ 05501 05502 /** 05503 * @addtogroup inv_park 05504 * @{ 05505 */ 05506 05507 /** 05508 * @brief Floating-point Inverse Park transform 05509 * @param[in] Id input coordinate of rotor reference frame d 05510 * @param[in] Iq input coordinate of rotor reference frame q 05511 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 05512 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 05513 * @param[in] sinVal sine value of rotation angle theta 05514 * @param[in] cosVal cosine value of rotation angle theta 05515 * @return none. 05516 */ 05517 05518 static __INLINE void arm_inv_park_f32( 05519 float32_t Id, 05520 float32_t Iq, 05521 float32_t * pIalpha, 05522 float32_t * pIbeta, 05523 float32_t sinVal, 05524 float32_t cosVal) 05525 { 05526 /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */ 05527 *pIalpha = Id * cosVal - Iq * sinVal; 05528 05529 /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */ 05530 *pIbeta = Id * sinVal + Iq * cosVal; 05531 05532 } 05533 05534 05535 /** 05536 * @brief Inverse Park transform for Q31 version 05537 * @param[in] Id input coordinate of rotor reference frame d 05538 * @param[in] Iq input coordinate of rotor reference frame q 05539 * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha 05540 * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta 05541 * @param[in] sinVal sine value of rotation angle theta 05542 * @param[in] cosVal cosine value of rotation angle theta 05543 * @return none. 05544 * 05545 * <b>Scaling and Overflow Behavior:</b> 05546 * \par 05547 * The function is implemented using an internal 32-bit accumulator. 05548 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. 05549 * There is saturation on the addition, hence there is no risk of overflow. 05550 */ 05551 05552 05553 static __INLINE void arm_inv_park_q31( 05554 q31_t Id, 05555 q31_t Iq, 05556 q31_t * pIalpha, 05557 q31_t * pIbeta, 05558 q31_t sinVal, 05559 q31_t cosVal) 05560 { 05561 q31_t product1, product2; /* Temporary variables used to store intermediate results */ 05562 q31_t product3, product4; /* Temporary variables used to store intermediate results */ 05563 05564 /* Intermediate product is calculated by (Id * cosVal) */ 05565 product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31); 05566 05567 /* Intermediate product is calculated by (Iq * sinVal) */ 05568 product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31); 05569 05570 05571 /* Intermediate product is calculated by (Id * sinVal) */ 05572 product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31); 05573 05574 /* Intermediate product is calculated by (Iq * cosVal) */ 05575 product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31); 05576 05577 /* Calculate pIalpha by using the two intermediate products 1 and 2 */ 05578 *pIalpha = __QSUB(product1, product2); 05579 05580 /* Calculate pIbeta by using the two intermediate products 3 and 4 */ 05581 *pIbeta = __QADD(product4, product3); 05582 05583 } 05584 05585 /** 05586 * @} end of Inverse park group 05587 */ 05588 05589 05590 /** 05591 * @brief Converts the elements of the Q31 vector to floating-point vector. 05592 * @param[in] *pSrc is input pointer 05593 * @param[out] *pDst is output pointer 05594 * @param[in] blockSize is the number of samples to process 05595 * @return none. 05596 */ 05597 void arm_q31_to_float( 05598 q31_t * pSrc, 05599 float32_t * pDst, 05600 uint32_t blockSize); 05601 05602 /** 05603 * @ingroup groupInterpolation 05604 */ 05605 05606 /** 05607 * @defgroup LinearInterpolate Linear Interpolation 05608 * 05609 * Linear interpolation is a method of curve fitting using linear polynomials. 05610 * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line 05611 * 05612 * \par 05613 * \image html LinearInterp.gif "Linear interpolation" 05614 * 05615 * \par 05616 * A Linear Interpolate function calculates an output value(y), for the input(x) 05617 * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values) 05618 * 05619 * \par Algorithm: 05620 * <pre> 05621 * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0)) 05622 * where x0, x1 are nearest values of input x 05623 * y0, y1 are nearest values to output y 05624 * </pre> 05625 * 05626 * \par 05627 * This set of functions implements Linear interpolation process 05628 * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single 05629 * sample of data and each call to the function returns a single processed value. 05630 * <code>S</code> points to an instance of the Linear Interpolate function data structure. 05631 * <code>x</code> is the input sample value. The functions returns the output value. 05632 * 05633 * \par 05634 * if x is outside of the table boundary, Linear interpolation returns first value of the table 05635 * if x is below input range and returns last value of table if x is above range. 05636 */ 05637 05638 /** 05639 * @addtogroup LinearInterpolate 05640 * @{ 05641 */ 05642 05643 /** 05644 * @brief Process function for the floating-point Linear Interpolation Function. 05645 * @param[in,out] *S is an instance of the floating-point Linear Interpolation structure 05646 * @param[in] x input sample to process 05647 * @return y processed output sample. 05648 * 05649 */ 05650 05651 static __INLINE float32_t arm_linear_interp_f32( 05652 arm_linear_interp_instance_f32 * S, 05653 float32_t x) 05654 { 05655 05656 float32_t y; 05657 float32_t x0, x1; /* Nearest input values */ 05658 float32_t y0, y1; /* Nearest output values */ 05659 float32_t xSpacing = S->xSpacing; /* spacing between input values */ 05660 int32_t i; /* Index variable */ 05661 float32_t *pYData = S->pYData; /* pointer to output table */ 05662 05663 /* Calculation of index */ 05664 i = (int32_t) ((x - S->x1) / xSpacing); 05665 05666 if(i < 0) 05667 { 05668 /* Iniatilize output for below specified range as least output value of table */ 05669 y = pYData[0]; 05670 } 05671 else if((uint32_t)i >= S->nValues) 05672 { 05673 /* Iniatilize output for above specified range as last output value of table */ 05674 y = pYData[S->nValues - 1]; 05675 } 05676 else 05677 { 05678 /* Calculation of nearest input values */ 05679 x0 = S->x1 + i * xSpacing; 05680 x1 = S->x1 + (i + 1) * xSpacing; 05681 05682 /* Read of nearest output values */ 05683 y0 = pYData[i]; 05684 y1 = pYData[i + 1]; 05685 05686 /* Calculation of output */ 05687 y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0)); 05688 05689 } 05690 05691 /* returns output value */ 05692 return (y); 05693 } 05694 05695 /** 05696 * 05697 * @brief Process function for the Q31 Linear Interpolation Function. 05698 * @param[in] *pYData pointer to Q31 Linear Interpolation table 05699 * @param[in] x input sample to process 05700 * @param[in] nValues number of table values 05701 * @return y processed output sample. 05702 * 05703 * \par 05704 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 05705 * This function can support maximum of table size 2^12. 05706 * 05707 */ 05708 05709 05710 static __INLINE q31_t arm_linear_interp_q31( 05711 q31_t * pYData, 05712 q31_t x, 05713 uint32_t nValues) 05714 { 05715 q31_t y; /* output */ 05716 q31_t y0, y1; /* Nearest output values */ 05717 q31_t fract; /* fractional part */ 05718 int32_t index; /* Index to read nearest output values */ 05719 05720 /* Input is in 12.20 format */ 05721 /* 12 bits for the table index */ 05722 /* Index value calculation */ 05723 index = ((x & 0xFFF00000) >> 20); 05724 05725 if(index >= (int32_t)(nValues - 1)) 05726 { 05727 return (pYData[nValues - 1]); 05728 } 05729 else if(index < 0) 05730 { 05731 return (pYData[0]); 05732 } 05733 else 05734 { 05735 05736 /* 20 bits for the fractional part */ 05737 /* shift left by 11 to keep fract in 1.31 format */ 05738 fract = (x & 0x000FFFFF) << 11; 05739 05740 /* Read two nearest output values from the index in 1.31(q31) format */ 05741 y0 = pYData[index]; 05742 y1 = pYData[index + 1u]; 05743 05744 /* Calculation of y0 * (1-fract) and y is in 2.30 format */ 05745 y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32)); 05746 05747 /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */ 05748 y += ((q31_t) (((q63_t) y1 * fract) >> 32)); 05749 05750 /* Convert y to 1.31 format */ 05751 return (y << 1u); 05752 05753 } 05754 05755 } 05756 05757 /** 05758 * 05759 * @brief Process function for the Q15 Linear Interpolation Function. 05760 * @param[in] *pYData pointer to Q15 Linear Interpolation table 05761 * @param[in] x input sample to process 05762 * @param[in] nValues number of table values 05763 * @return y processed output sample. 05764 * 05765 * \par 05766 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 05767 * This function can support maximum of table size 2^12. 05768 * 05769 */ 05770 05771 05772 static __INLINE q15_t arm_linear_interp_q15( 05773 q15_t * pYData, 05774 q31_t x, 05775 uint32_t nValues) 05776 { 05777 q63_t y; /* output */ 05778 q15_t y0, y1; /* Nearest output values */ 05779 q31_t fract; /* fractional part */ 05780 int32_t index; /* Index to read nearest output values */ 05781 05782 /* Input is in 12.20 format */ 05783 /* 12 bits for the table index */ 05784 /* Index value calculation */ 05785 index = ((x & 0xFFF00000) >> 20u); 05786 05787 if(index >= (int32_t)(nValues - 1)) 05788 { 05789 return (pYData[nValues - 1]); 05790 } 05791 else if(index < 0) 05792 { 05793 return (pYData[0]); 05794 } 05795 else 05796 { 05797 /* 20 bits for the fractional part */ 05798 /* fract is in 12.20 format */ 05799 fract = (x & 0x000FFFFF); 05800 05801 /* Read two nearest output values from the index */ 05802 y0 = pYData[index]; 05803 y1 = pYData[index + 1u]; 05804 05805 /* Calculation of y0 * (1-fract) and y is in 13.35 format */ 05806 y = ((q63_t) y0 * (0xFFFFF - fract)); 05807 05808 /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */ 05809 y += ((q63_t) y1 * (fract)); 05810 05811 /* convert y to 1.15 format */ 05812 return (y >> 20); 05813 } 05814 05815 05816 } 05817 05818 /** 05819 * 05820 * @brief Process function for the Q7 Linear Interpolation Function. 05821 * @param[in] *pYData pointer to Q7 Linear Interpolation table 05822 * @param[in] x input sample to process 05823 * @param[in] nValues number of table values 05824 * @return y processed output sample. 05825 * 05826 * \par 05827 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. 05828 * This function can support maximum of table size 2^12. 05829 */ 05830 05831 05832 static __INLINE q7_t arm_linear_interp_q7( 05833 q7_t * pYData, 05834 q31_t x, 05835 uint32_t nValues) 05836 { 05837 q31_t y; /* output */ 05838 q7_t y0, y1; /* Nearest output values */ 05839 q31_t fract; /* fractional part */ 05840 uint32_t index; /* Index to read nearest output values */ 05841 05842 /* Input is in 12.20 format */ 05843 /* 12 bits for the table index */ 05844 /* Index value calculation */ 05845 if (x < 0) 05846 { 05847 return (pYData[0]); 05848 } 05849 index = (x >> 20) & 0xfff; 05850 05851 05852 if(index >= (nValues - 1)) 05853 { 05854 return (pYData[nValues - 1]); 05855 } 05856 else 05857 { 05858 05859 /* 20 bits for the fractional part */ 05860 /* fract is in 12.20 format */ 05861 fract = (x & 0x000FFFFF); 05862 05863 /* Read two nearest output values from the index and are in 1.7(q7) format */ 05864 y0 = pYData[index]; 05865 y1 = pYData[index + 1u]; 05866 05867 /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */ 05868 y = ((y0 * (0xFFFFF - fract))); 05869 05870 /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */ 05871 y += (y1 * fract); 05872 05873 /* convert y to 1.7(q7) format */ 05874 return (y >> 20u); 05875 05876 } 05877 05878 } 05879 /** 05880 * @} end of LinearInterpolate group 05881 */ 05882 05883 /** 05884 * @brief Fast approximation to the trigonometric sine function for floating-point data. 05885 * @param[in] x input value in radians. 05886 * @return sin(x). 05887 */ 05888 05889 float32_t arm_sin_f32( 05890 float32_t x); 05891 05892 /** 05893 * @brief Fast approximation to the trigonometric sine function for Q31 data. 05894 * @param[in] x Scaled input value in radians. 05895 * @return sin(x). 05896 */ 05897 05898 q31_t arm_sin_q31( 05899 q31_t x); 05900 05901 /** 05902 * @brief Fast approximation to the trigonometric sine function for Q15 data. 05903 * @param[in] x Scaled input value in radians. 05904 * @return sin(x). 05905 */ 05906 05907 q15_t arm_sin_q15( 05908 q15_t x); 05909 05910 /** 05911 * @brief Fast approximation to the trigonometric cosine function for floating-point data. 05912 * @param[in] x input value in radians. 05913 * @return cos(x). 05914 */ 05915 05916 float32_t arm_cos_f32( 05917 float32_t x); 05918 05919 /** 05920 * @brief Fast approximation to the trigonometric cosine function for Q31 data. 05921 * @param[in] x Scaled input value in radians. 05922 * @return cos(x). 05923 */ 05924 05925 q31_t arm_cos_q31( 05926 q31_t x); 05927 05928 /** 05929 * @brief Fast approximation to the trigonometric cosine function for Q15 data. 05930 * @param[in] x Scaled input value in radians. 05931 * @return cos(x). 05932 */ 05933 05934 q15_t arm_cos_q15( 05935 q15_t x); 05936 05937 05938 /** 05939 * @ingroup groupFastMath 05940 */ 05941 05942 05943 /** 05944 * @defgroup SQRT Square Root 05945 * 05946 * Computes the square root of a number. 05947 * There are separate functions for Q15, Q31, and floating-point data types. 05948 * The square root function is computed using the Newton-Raphson algorithm. 05949 * This is an iterative algorithm of the form: 05950 * <pre> 05951 * x1 = x0 - f(x0)/f'(x0) 05952 * </pre> 05953 * where <code>x1</code> is the current estimate, 05954 * <code>x0</code> is the previous estimate, and 05955 * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>. 05956 * For the square root function, the algorithm reduces to: 05957 * <pre> 05958 * x0 = in/2 [initial guess] 05959 * x1 = 1/2 * ( x0 + in / x0) [each iteration] 05960 * </pre> 05961 */ 05962 05963 05964 /** 05965 * @addtogroup SQRT 05966 * @{ 05967 */ 05968 05969 /** 05970 * @brief Floating-point square root function. 05971 * @param[in] in input value. 05972 * @param[out] *pOut square root of input value. 05973 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if 05974 * <code>in</code> is negative value and returns zero output for negative values. 05975 */ 05976 05977 static __INLINE arm_status arm_sqrt_f32( 05978 float32_t in, 05979 float32_t * pOut) 05980 { 05981 if(in > 0) 05982 { 05983 05984 // #if __FPU_USED 05985 #if (__FPU_USED == 1) && defined ( __CC_ARM ) 05986 *pOut = __sqrtf(in); 05987 #else 05988 #if defined(__GNUC__) 05989 *pOut = __builtin_sqrtf(in); 05990 #else 05991 *pOut = sqrtf(in); 05992 #endif 05993 #endif 05994 05995 return (ARM_MATH_SUCCESS); 05996 } 05997 else 05998 { 05999 *pOut = 0.0f; 06000 return (ARM_MATH_ARGUMENT_ERROR); 06001 } 06002 06003 } 06004 06005 06006 /** 06007 * @brief Q31 square root function. 06008 * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF. 06009 * @param[out] *pOut square root of input value. 06010 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if 06011 * <code>in</code> is negative value and returns zero output for negative values. 06012 */ 06013 arm_status arm_sqrt_q31( 06014 q31_t in, 06015 q31_t * pOut); 06016 06017 /** 06018 * @brief Q15 square root function. 06019 * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF. 06020 * @param[out] *pOut square root of input value. 06021 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if 06022 * <code>in</code> is negative value and returns zero output for negative values. 06023 */ 06024 arm_status arm_sqrt_q15( 06025 q15_t in, 06026 q15_t * pOut); 06027 06028 /** 06029 * @} end of SQRT group 06030 */ 06031 06032 06033 06034 06035 06036 06037 /** 06038 * @brief floating-point Circular write function. 06039 */ 06040 06041 static __INLINE void arm_circularWrite_f32( 06042 int32_t * circBuffer, 06043 int32_t L, 06044 uint16_t * writeOffset, 06045 int32_t bufferInc, 06046 const int32_t * src, 06047 int32_t srcInc, 06048 uint32_t blockSize) 06049 { 06050 uint32_t i = 0u; 06051 int32_t wOffset; 06052 06053 /* Copy the value of Index pointer that points 06054 * to the current location where the input samples to be copied */ 06055 wOffset = *writeOffset; 06056 06057 /* Loop over the blockSize */ 06058 i = blockSize; 06059 06060 while(i > 0u) 06061 { 06062 /* copy the input sample to the circular buffer */ 06063 circBuffer[wOffset] = *src; 06064 06065 /* Update the input pointer */ 06066 src += srcInc; 06067 06068 /* Circularly update wOffset. Watch out for positive and negative value */ 06069 wOffset += bufferInc; 06070 if(wOffset >= L) 06071 wOffset -= L; 06072 06073 /* Decrement the loop counter */ 06074 i--; 06075 } 06076 06077 /* Update the index pointer */ 06078 *writeOffset = wOffset; 06079 } 06080 06081 06082 06083 /** 06084 * @brief floating-point Circular Read function. 06085 */ 06086 static __INLINE void arm_circularRead_f32( 06087 int32_t * circBuffer, 06088 int32_t L, 06089 int32_t * readOffset, 06090 int32_t bufferInc, 06091 int32_t * dst, 06092 int32_t * dst_base, 06093 int32_t dst_length, 06094 int32_t dstInc, 06095 uint32_t blockSize) 06096 { 06097 uint32_t i = 0u; 06098 int32_t rOffset, dst_end; 06099 06100 /* Copy the value of Index pointer that points 06101 * to the current location from where the input samples to be read */ 06102 rOffset = *readOffset; 06103 dst_end = (int32_t) (dst_base + dst_length); 06104 06105 /* Loop over the blockSize */ 06106 i = blockSize; 06107 06108 while(i > 0u) 06109 { 06110 /* copy the sample from the circular buffer to the destination buffer */ 06111 *dst = circBuffer[rOffset]; 06112 06113 /* Update the input pointer */ 06114 dst += dstInc; 06115 06116 if(dst == (int32_t *) dst_end) 06117 { 06118 dst = dst_base; 06119 } 06120 06121 /* Circularly update rOffset. Watch out for positive and negative value */ 06122 rOffset += bufferInc; 06123 06124 if(rOffset >= L) 06125 { 06126 rOffset -= L; 06127 } 06128 06129 /* Decrement the loop counter */ 06130 i--; 06131 } 06132 06133 /* Update the index pointer */ 06134 *readOffset = rOffset; 06135 } 06136 06137 /** 06138 * @brief Q15 Circular write function. 06139 */ 06140 06141 static __INLINE void arm_circularWrite_q15( 06142 q15_t * circBuffer, 06143 int32_t L, 06144 uint16_t * writeOffset, 06145 int32_t bufferInc, 06146 const q15_t * src, 06147 int32_t srcInc, 06148 uint32_t blockSize) 06149 { 06150 uint32_t i = 0u; 06151 int32_t wOffset; 06152 06153 /* Copy the value of Index pointer that points 06154 * to the current location where the input samples to be copied */ 06155 wOffset = *writeOffset; 06156 06157 /* Loop over the blockSize */ 06158 i = blockSize; 06159 06160 while(i > 0u) 06161 { 06162 /* copy the input sample to the circular buffer */ 06163 circBuffer[wOffset] = *src; 06164 06165 /* Update the input pointer */ 06166 src += srcInc; 06167 06168 /* Circularly update wOffset. Watch out for positive and negative value */ 06169 wOffset += bufferInc; 06170 if(wOffset >= L) 06171 wOffset -= L; 06172 06173 /* Decrement the loop counter */ 06174 i--; 06175 } 06176 06177 /* Update the index pointer */ 06178 *writeOffset = wOffset; 06179 } 06180 06181 06182 06183 /** 06184 * @brief Q15 Circular Read function. 06185 */ 06186 static __INLINE void arm_circularRead_q15( 06187 q15_t * circBuffer, 06188 int32_t L, 06189 int32_t * readOffset, 06190 int32_t bufferInc, 06191 q15_t * dst, 06192 q15_t * dst_base, 06193 int32_t dst_length, 06194 int32_t dstInc, 06195 uint32_t blockSize) 06196 { 06197 uint32_t i = 0; 06198 int32_t rOffset, dst_end; 06199 06200 /* Copy the value of Index pointer that points 06201 * to the current location from where the input samples to be read */ 06202 rOffset = *readOffset; 06203 06204 dst_end = (int32_t) (dst_base + dst_length); 06205 06206 /* Loop over the blockSize */ 06207 i = blockSize; 06208 06209 while(i > 0u) 06210 { 06211 /* copy the sample from the circular buffer to the destination buffer */ 06212 *dst = circBuffer[rOffset]; 06213 06214 /* Update the input pointer */ 06215 dst += dstInc; 06216 06217 if(dst == (q15_t *) dst_end) 06218 { 06219 dst = dst_base; 06220 } 06221 06222 /* Circularly update wOffset. Watch out for positive and negative value */ 06223 rOffset += bufferInc; 06224 06225 if(rOffset >= L) 06226 { 06227 rOffset -= L; 06228 } 06229 06230 /* Decrement the loop counter */ 06231 i--; 06232 } 06233 06234 /* Update the index pointer */ 06235 *readOffset = rOffset; 06236 } 06237 06238 06239 /** 06240 * @brief Q7 Circular write function. 06241 */ 06242 06243 static __INLINE void arm_circularWrite_q7( 06244 q7_t * circBuffer, 06245 int32_t L, 06246 uint16_t * writeOffset, 06247 int32_t bufferInc, 06248 const q7_t * src, 06249 int32_t srcInc, 06250 uint32_t blockSize) 06251 { 06252 uint32_t i = 0u; 06253 int32_t wOffset; 06254 06255 /* Copy the value of Index pointer that points 06256 * to the current location where the input samples to be copied */ 06257 wOffset = *writeOffset; 06258 06259 /* Loop over the blockSize */ 06260 i = blockSize; 06261 06262 while(i > 0u) 06263 { 06264 /* copy the input sample to the circular buffer */ 06265 circBuffer[wOffset] = *src; 06266 06267 /* Update the input pointer */ 06268 src += srcInc; 06269 06270 /* Circularly update wOffset. Watch out for positive and negative value */ 06271 wOffset += bufferInc; 06272 if(wOffset >= L) 06273 wOffset -= L; 06274 06275 /* Decrement the loop counter */ 06276 i--; 06277 } 06278 06279 /* Update the index pointer */ 06280 *writeOffset = wOffset; 06281 } 06282 06283 06284 06285 /** 06286 * @brief Q7 Circular Read function. 06287 */ 06288 static __INLINE void arm_circularRead_q7( 06289 q7_t * circBuffer, 06290 int32_t L, 06291 int32_t * readOffset, 06292 int32_t bufferInc, 06293 q7_t * dst, 06294 q7_t * dst_base, 06295 int32_t dst_length, 06296 int32_t dstInc, 06297 uint32_t blockSize) 06298 { 06299 uint32_t i = 0; 06300 int32_t rOffset, dst_end; 06301 06302 /* Copy the value of Index pointer that points 06303 * to the current location from where the input samples to be read */ 06304 rOffset = *readOffset; 06305 06306 dst_end = (int32_t) (dst_base + dst_length); 06307 06308 /* Loop over the blockSize */ 06309 i = blockSize; 06310 06311 while(i > 0u) 06312 { 06313 /* copy the sample from the circular buffer to the destination buffer */ 06314 *dst = circBuffer[rOffset]; 06315 06316 /* Update the input pointer */ 06317 dst += dstInc; 06318 06319 if(dst == (q7_t *) dst_end) 06320 { 06321 dst = dst_base; 06322 } 06323 06324 /* Circularly update rOffset. Watch out for positive and negative value */ 06325 rOffset += bufferInc; 06326 06327 if(rOffset >= L) 06328 { 06329 rOffset -= L; 06330 } 06331 06332 /* Decrement the loop counter */ 06333 i--; 06334 } 06335 06336 /* Update the index pointer */ 06337 *readOffset = rOffset; 06338 } 06339 06340 06341 /** 06342 * @brief Sum of the squares of the elements of a Q31 vector. 06343 * @param[in] *pSrc is input pointer 06344 * @param[in] blockSize is the number of samples to process 06345 * @param[out] *pResult is output value. 06346 * @return none. 06347 */ 06348 06349 void arm_power_q31( 06350 q31_t * pSrc, 06351 uint32_t blockSize, 06352 q63_t * pResult); 06353 06354 /** 06355 * @brief Sum of the squares of the elements of a floating-point vector. 06356 * @param[in] *pSrc is input pointer 06357 * @param[in] blockSize is the number of samples to process 06358 * @param[out] *pResult is output value. 06359 * @return none. 06360 */ 06361 06362 void arm_power_f32( 06363 float32_t * pSrc, 06364 uint32_t blockSize, 06365 float32_t * pResult); 06366 06367 /** 06368 * @brief Sum of the squares of the elements of a Q15 vector. 06369 * @param[in] *pSrc is input pointer 06370 * @param[in] blockSize is the number of samples to process 06371 * @param[out] *pResult is output value. 06372 * @return none. 06373 */ 06374 06375 void arm_power_q15( 06376 q15_t * pSrc, 06377 uint32_t blockSize, 06378 q63_t * pResult); 06379 06380 /** 06381 * @brief Sum of the squares of the elements of a Q7 vector. 06382 * @param[in] *pSrc is input pointer 06383 * @param[in] blockSize is the number of samples to process 06384 * @param[out] *pResult is output value. 06385 * @return none. 06386 */ 06387 06388 void arm_power_q7( 06389 q7_t * pSrc, 06390 uint32_t blockSize, 06391 q31_t * pResult); 06392 06393 /** 06394 * @brief Mean value of a Q7 vector. 06395 * @param[in] *pSrc is input pointer 06396 * @param[in] blockSize is the number of samples to process 06397 * @param[out] *pResult is output value. 06398 * @return none. 06399 */ 06400 06401 void arm_mean_q7( 06402 q7_t * pSrc, 06403 uint32_t blockSize, 06404 q7_t * pResult); 06405 06406 /** 06407 * @brief Mean value of a Q15 vector. 06408 * @param[in] *pSrc is input pointer 06409 * @param[in] blockSize is the number of samples to process 06410 * @param[out] *pResult is output value. 06411 * @return none. 06412 */ 06413 void arm_mean_q15( 06414 q15_t * pSrc, 06415 uint32_t blockSize, 06416 q15_t * pResult); 06417 06418 /** 06419 * @brief Mean value of a Q31 vector. 06420 * @param[in] *pSrc is input pointer 06421 * @param[in] blockSize is the number of samples to process 06422 * @param[out] *pResult is output value. 06423 * @return none. 06424 */ 06425 void arm_mean_q31( 06426 q31_t * pSrc, 06427 uint32_t blockSize, 06428 q31_t * pResult); 06429 06430 /** 06431 * @brief Mean value of a floating-point vector. 06432 * @param[in] *pSrc is input pointer 06433 * @param[in] blockSize is the number of samples to process 06434 * @param[out] *pResult is output value. 06435 * @return none. 06436 */ 06437 void arm_mean_f32( 06438 float32_t * pSrc, 06439 uint32_t blockSize, 06440 float32_t * pResult); 06441 06442 /** 06443 * @brief Variance of the elements of a floating-point vector. 06444 * @param[in] *pSrc is input pointer 06445 * @param[in] blockSize is the number of samples to process 06446 * @param[out] *pResult is output value. 06447 * @return none. 06448 */ 06449 06450 void arm_var_f32( 06451 float32_t * pSrc, 06452 uint32_t blockSize, 06453 float32_t * pResult); 06454 06455 /** 06456 * @brief Variance of the elements of a Q31 vector. 06457 * @param[in] *pSrc is input pointer 06458 * @param[in] blockSize is the number of samples to process 06459 * @param[out] *pResult is output value. 06460 * @return none. 06461 */ 06462 06463 void arm_var_q31( 06464 q31_t * pSrc, 06465 uint32_t blockSize, 06466 q31_t * pResult); 06467 06468 /** 06469 * @brief Variance of the elements of a Q15 vector. 06470 * @param[in] *pSrc is input pointer 06471 * @param[in] blockSize is the number of samples to process 06472 * @param[out] *pResult is output value. 06473 * @return none. 06474 */ 06475 06476 void arm_var_q15( 06477 q15_t * pSrc, 06478 uint32_t blockSize, 06479 q15_t * pResult); 06480 06481 /** 06482 * @brief Root Mean Square of the elements of a floating-point vector. 06483 * @param[in] *pSrc is input pointer 06484 * @param[in] blockSize is the number of samples to process 06485 * @param[out] *pResult is output value. 06486 * @return none. 06487 */ 06488 06489 void arm_rms_f32( 06490 float32_t * pSrc, 06491 uint32_t blockSize, 06492 float32_t * pResult); 06493 06494 /** 06495 * @brief Root Mean Square of the elements of a Q31 vector. 06496 * @param[in] *pSrc is input pointer 06497 * @param[in] blockSize is the number of samples to process 06498 * @param[out] *pResult is output value. 06499 * @return none. 06500 */ 06501 06502 void arm_rms_q31( 06503 q31_t * pSrc, 06504 uint32_t blockSize, 06505 q31_t * pResult); 06506 06507 /** 06508 * @brief Root Mean Square of the elements of a Q15 vector. 06509 * @param[in] *pSrc is input pointer 06510 * @param[in] blockSize is the number of samples to process 06511 * @param[out] *pResult is output value. 06512 * @return none. 06513 */ 06514 06515 void arm_rms_q15( 06516 q15_t * pSrc, 06517 uint32_t blockSize, 06518 q15_t * pResult); 06519 06520 /** 06521 * @brief Standard deviation of the elements of a floating-point vector. 06522 * @param[in] *pSrc is input pointer 06523 * @param[in] blockSize is the number of samples to process 06524 * @param[out] *pResult is output value. 06525 * @return none. 06526 */ 06527 06528 void arm_std_f32( 06529 float32_t * pSrc, 06530 uint32_t blockSize, 06531 float32_t * pResult); 06532 06533 /** 06534 * @brief Standard deviation of the elements of a Q31 vector. 06535 * @param[in] *pSrc is input pointer 06536 * @param[in] blockSize is the number of samples to process 06537 * @param[out] *pResult is output value. 06538 * @return none. 06539 */ 06540 06541 void arm_std_q31( 06542 q31_t * pSrc, 06543 uint32_t blockSize, 06544 q31_t * pResult); 06545 06546 /** 06547 * @brief Standard deviation of the elements of a Q15 vector. 06548 * @param[in] *pSrc is input pointer 06549 * @param[in] blockSize is the number of samples to process 06550 * @param[out] *pResult is output value. 06551 * @return none. 06552 */ 06553 06554 void arm_std_q15( 06555 q15_t * pSrc, 06556 uint32_t blockSize, 06557 q15_t * pResult); 06558 06559 /** 06560 * @brief Floating-point complex magnitude 06561 * @param[in] *pSrc points to the complex input vector 06562 * @param[out] *pDst points to the real output vector 06563 * @param[in] numSamples number of complex samples in the input vector 06564 * @return none. 06565 */ 06566 06567 void arm_cmplx_mag_f32( 06568 float32_t * pSrc, 06569 float32_t * pDst, 06570 uint32_t numSamples); 06571 06572 /** 06573 * @brief Q31 complex magnitude 06574 * @param[in] *pSrc points to the complex input vector 06575 * @param[out] *pDst points to the real output vector 06576 * @param[in] numSamples number of complex samples in the input vector 06577 * @return none. 06578 */ 06579 06580 void arm_cmplx_mag_q31( 06581 q31_t * pSrc, 06582 q31_t * pDst, 06583 uint32_t numSamples); 06584 06585 /** 06586 * @brief Q15 complex magnitude 06587 * @param[in] *pSrc points to the complex input vector 06588 * @param[out] *pDst points to the real output vector 06589 * @param[in] numSamples number of complex samples in the input vector 06590 * @return none. 06591 */ 06592 06593 void arm_cmplx_mag_q15( 06594 q15_t * pSrc, 06595 q15_t * pDst, 06596 uint32_t numSamples); 06597 06598 /** 06599 * @brief Q15 complex dot product 06600 * @param[in] *pSrcA points to the first input vector 06601 * @param[in] *pSrcB points to the second input vector 06602 * @param[in] numSamples number of complex samples in each vector 06603 * @param[out] *realResult real part of the result returned here 06604 * @param[out] *imagResult imaginary part of the result returned here 06605 * @return none. 06606 */ 06607 06608 void arm_cmplx_dot_prod_q15( 06609 q15_t * pSrcA, 06610 q15_t * pSrcB, 06611 uint32_t numSamples, 06612 q31_t * realResult, 06613 q31_t * imagResult); 06614 06615 /** 06616 * @brief Q31 complex dot product 06617 * @param[in] *pSrcA points to the first input vector 06618 * @param[in] *pSrcB points to the second input vector 06619 * @param[in] numSamples number of complex samples in each vector 06620 * @param[out] *realResult real part of the result returned here 06621 * @param[out] *imagResult imaginary part of the result returned here 06622 * @return none. 06623 */ 06624 06625 void arm_cmplx_dot_prod_q31( 06626 q31_t * pSrcA, 06627 q31_t * pSrcB, 06628 uint32_t numSamples, 06629 q63_t * realResult, 06630 q63_t * imagResult); 06631 06632 /** 06633 * @brief Floating-point complex dot product 06634 * @param[in] *pSrcA points to the first input vector 06635 * @param[in] *pSrcB points to the second input vector 06636 * @param[in] numSamples number of complex samples in each vector 06637 * @param[out] *realResult real part of the result returned here 06638 * @param[out] *imagResult imaginary part of the result returned here 06639 * @return none. 06640 */ 06641 06642 void arm_cmplx_dot_prod_f32( 06643 float32_t * pSrcA, 06644 float32_t * pSrcB, 06645 uint32_t numSamples, 06646 float32_t * realResult, 06647 float32_t * imagResult); 06648 06649 /** 06650 * @brief Q15 complex-by-real multiplication 06651 * @param[in] *pSrcCmplx points to the complex input vector 06652 * @param[in] *pSrcReal points to the real input vector 06653 * @param[out] *pCmplxDst points to the complex output vector 06654 * @param[in] numSamples number of samples in each vector 06655 * @return none. 06656 */ 06657 06658 void arm_cmplx_mult_real_q15( 06659 q15_t * pSrcCmplx, 06660 q15_t * pSrcReal, 06661 q15_t * pCmplxDst, 06662 uint32_t numSamples); 06663 06664 /** 06665 * @brief Q31 complex-by-real multiplication 06666 * @param[in] *pSrcCmplx points to the complex input vector 06667 * @param[in] *pSrcReal points to the real input vector 06668 * @param[out] *pCmplxDst points to the complex output vector 06669 * @param[in] numSamples number of samples in each vector 06670 * @return none. 06671 */ 06672 06673 void arm_cmplx_mult_real_q31( 06674 q31_t * pSrcCmplx, 06675 q31_t * pSrcReal, 06676 q31_t * pCmplxDst, 06677 uint32_t numSamples); 06678 06679 /** 06680 * @brief Floating-point complex-by-real multiplication 06681 * @param[in] *pSrcCmplx points to the complex input vector 06682 * @param[in] *pSrcReal points to the real input vector 06683 * @param[out] *pCmplxDst points to the complex output vector 06684 * @param[in] numSamples number of samples in each vector 06685 * @return none. 06686 */ 06687 06688 void arm_cmplx_mult_real_f32( 06689 float32_t * pSrcCmplx, 06690 float32_t * pSrcReal, 06691 float32_t * pCmplxDst, 06692 uint32_t numSamples); 06693 06694 /** 06695 * @brief Minimum value of a Q7 vector. 06696 * @param[in] *pSrc is input pointer 06697 * @param[in] blockSize is the number of samples to process 06698 * @param[out] *result is output pointer 06699 * @param[in] index is the array index of the minimum value in the input buffer. 06700 * @return none. 06701 */ 06702 06703 void arm_min_q7( 06704 q7_t * pSrc, 06705 uint32_t blockSize, 06706 q7_t * result, 06707 uint32_t * index); 06708 06709 /** 06710 * @brief Minimum value of a Q15 vector. 06711 * @param[in] *pSrc is input pointer 06712 * @param[in] blockSize is the number of samples to process 06713 * @param[out] *pResult is output pointer 06714 * @param[in] *pIndex is the array index of the minimum value in the input buffer. 06715 * @return none. 06716 */ 06717 06718 void arm_min_q15( 06719 q15_t * pSrc, 06720 uint32_t blockSize, 06721 q15_t * pResult, 06722 uint32_t * pIndex); 06723 06724 /** 06725 * @brief Minimum value of a Q31 vector. 06726 * @param[in] *pSrc is input pointer 06727 * @param[in] blockSize is the number of samples to process 06728 * @param[out] *pResult is output pointer 06729 * @param[out] *pIndex is the array index of the minimum value in the input buffer. 06730 * @return none. 06731 */ 06732 void arm_min_q31( 06733 q31_t * pSrc, 06734 uint32_t blockSize, 06735 q31_t * pResult, 06736 uint32_t * pIndex); 06737 06738 /** 06739 * @brief Minimum value of a floating-point vector. 06740 * @param[in] *pSrc is input pointer 06741 * @param[in] blockSize is the number of samples to process 06742 * @param[out] *pResult is output pointer 06743 * @param[out] *pIndex is the array index of the minimum value in the input buffer. 06744 * @return none. 06745 */ 06746 06747 void arm_min_f32( 06748 float32_t * pSrc, 06749 uint32_t blockSize, 06750 float32_t * pResult, 06751 uint32_t * pIndex); 06752 06753 /** 06754 * @brief Maximum value of a Q7 vector. 06755 * @param[in] *pSrc points to the input buffer 06756 * @param[in] blockSize length of the input vector 06757 * @param[out] *pResult maximum value returned here 06758 * @param[out] *pIndex index of maximum value returned here 06759 * @return none. 06760 */ 06761 06762 void arm_max_q7( 06763 q7_t * pSrc, 06764 uint32_t blockSize, 06765 q7_t * pResult, 06766 uint32_t * pIndex); 06767 06768 /** 06769 * @brief Maximum value of a Q15 vector. 06770 * @param[in] *pSrc points to the input buffer 06771 * @param[in] blockSize length of the input vector 06772 * @param[out] *pResult maximum value returned here 06773 * @param[out] *pIndex index of maximum value returned here 06774 * @return none. 06775 */ 06776 06777 void arm_max_q15( 06778 q15_t * pSrc, 06779 uint32_t blockSize, 06780 q15_t * pResult, 06781 uint32_t * pIndex); 06782 06783 /** 06784 * @brief Maximum value of a Q31 vector. 06785 * @param[in] *pSrc points to the input buffer 06786 * @param[in] blockSize length of the input vector 06787 * @param[out] *pResult maximum value returned here 06788 * @param[out] *pIndex index of maximum value returned here 06789 * @return none. 06790 */ 06791 06792 void arm_max_q31( 06793 q31_t * pSrc, 06794 uint32_t blockSize, 06795 q31_t * pResult, 06796 uint32_t * pIndex); 06797 06798 /** 06799 * @brief Maximum value of a floating-point vector. 06800 * @param[in] *pSrc points to the input buffer 06801 * @param[in] blockSize length of the input vector 06802 * @param[out] *pResult maximum value returned here 06803 * @param[out] *pIndex index of maximum value returned here 06804 * @return none. 06805 */ 06806 06807 void arm_max_f32( 06808 float32_t * pSrc, 06809 uint32_t blockSize, 06810 float32_t * pResult, 06811 uint32_t * pIndex); 06812 06813 /** 06814 * @brief Q15 complex-by-complex multiplication 06815 * @param[in] *pSrcA points to the first input vector 06816 * @param[in] *pSrcB points to the second input vector 06817 * @param[out] *pDst points to the output vector 06818 * @param[in] numSamples number of complex samples in each vector 06819 * @return none. 06820 */ 06821 06822 void arm_cmplx_mult_cmplx_q15( 06823 q15_t * pSrcA, 06824 q15_t * pSrcB, 06825 q15_t * pDst, 06826 uint32_t numSamples); 06827 06828 /** 06829 * @brief Q31 complex-by-complex multiplication 06830 * @param[in] *pSrcA points to the first input vector 06831 * @param[in] *pSrcB points to the second input vector 06832 * @param[out] *pDst points to the output vector 06833 * @param[in] numSamples number of complex samples in each vector 06834 * @return none. 06835 */ 06836 06837 void arm_cmplx_mult_cmplx_q31( 06838 q31_t * pSrcA, 06839 q31_t * pSrcB, 06840 q31_t * pDst, 06841 uint32_t numSamples); 06842 06843 /** 06844 * @brief Floating-point complex-by-complex multiplication 06845 * @param[in] *pSrcA points to the first input vector 06846 * @param[in] *pSrcB points to the second input vector 06847 * @param[out] *pDst points to the output vector 06848 * @param[in] numSamples number of complex samples in each vector 06849 * @return none. 06850 */ 06851 06852 void arm_cmplx_mult_cmplx_f32( 06853 float32_t * pSrcA, 06854 float32_t * pSrcB, 06855 float32_t * pDst, 06856 uint32_t numSamples); 06857 06858 /** 06859 * @brief Converts the elements of the floating-point vector to Q31 vector. 06860 * @param[in] *pSrc points to the floating-point input vector 06861 * @param[out] *pDst points to the Q31 output vector 06862 * @param[in] blockSize length of the input vector 06863 * @return none. 06864 */ 06865 void arm_float_to_q31( 06866 float32_t * pSrc, 06867 q31_t * pDst, 06868 uint32_t blockSize); 06869 06870 /** 06871 * @brief Converts the elements of the floating-point vector to Q15 vector. 06872 * @param[in] *pSrc points to the floating-point input vector 06873 * @param[out] *pDst points to the Q15 output vector 06874 * @param[in] blockSize length of the input vector 06875 * @return none 06876 */ 06877 void arm_float_to_q15( 06878 float32_t * pSrc, 06879 q15_t * pDst, 06880 uint32_t blockSize); 06881 06882 /** 06883 * @brief Converts the elements of the floating-point vector to Q7 vector. 06884 * @param[in] *pSrc points to the floating-point input vector 06885 * @param[out] *pDst points to the Q7 output vector 06886 * @param[in] blockSize length of the input vector 06887 * @return none 06888 */ 06889 void arm_float_to_q7( 06890 float32_t * pSrc, 06891 q7_t * pDst, 06892 uint32_t blockSize); 06893 06894 06895 /** 06896 * @brief Converts the elements of the Q31 vector to Q15 vector. 06897 * @param[in] *pSrc is input pointer 06898 * @param[out] *pDst is output pointer 06899 * @param[in] blockSize is the number of samples to process 06900 * @return none. 06901 */ 06902 void arm_q31_to_q15( 06903 q31_t * pSrc, 06904 q15_t * pDst, 06905 uint32_t blockSize); 06906 06907 /** 06908 * @brief Converts the elements of the Q31 vector to Q7 vector. 06909 * @param[in] *pSrc is input pointer 06910 * @param[out] *pDst is output pointer 06911 * @param[in] blockSize is the number of samples to process 06912 * @return none. 06913 */ 06914 void arm_q31_to_q7( 06915 q31_t * pSrc, 06916 q7_t * pDst, 06917 uint32_t blockSize); 06918 06919 /** 06920 * @brief Converts the elements of the Q15 vector to floating-point vector. 06921 * @param[in] *pSrc is input pointer 06922 * @param[out] *pDst is output pointer 06923 * @param[in] blockSize is the number of samples to process 06924 * @return none. 06925 */ 06926 void arm_q15_to_float( 06927 q15_t * pSrc, 06928 float32_t * pDst, 06929 uint32_t blockSize); 06930 06931 06932 /** 06933 * @brief Converts the elements of the Q15 vector to Q31 vector. 06934 * @param[in] *pSrc is input pointer 06935 * @param[out] *pDst is output pointer 06936 * @param[in] blockSize is the number of samples to process 06937 * @return none. 06938 */ 06939 void arm_q15_to_q31( 06940 q15_t * pSrc, 06941 q31_t * pDst, 06942 uint32_t blockSize); 06943 06944 06945 /** 06946 * @brief Converts the elements of the Q15 vector to Q7 vector. 06947 * @param[in] *pSrc is input pointer 06948 * @param[out] *pDst is output pointer 06949 * @param[in] blockSize is the number of samples to process 06950 * @return none. 06951 */ 06952 void arm_q15_to_q7( 06953 q15_t * pSrc, 06954 q7_t * pDst, 06955 uint32_t blockSize); 06956 06957 06958 /** 06959 * @ingroup groupInterpolation 06960 */ 06961 06962 /** 06963 * @defgroup BilinearInterpolate Bilinear Interpolation 06964 * 06965 * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid. 06966 * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process 06967 * determines values between the grid points. 06968 * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension. 06969 * Bilinear interpolation is often used in image processing to rescale images. 06970 * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types. 06971 * 06972 * <b>Algorithm</b> 06973 * \par 06974 * The instance structure used by the bilinear interpolation functions describes a two dimensional data table. 06975 * For floating-point, the instance structure is defined as: 06976 * <pre> 06977 * typedef struct 06978 * { 06979 * uint16_t numRows; 06980 * uint16_t numCols; 06981 * float32_t *pData; 06982 * } arm_bilinear_interp_instance_f32; 06983 * </pre> 06984 * 06985 * \par 06986 * where <code>numRows</code> specifies the number of rows in the table; 06987 * <code>numCols</code> specifies the number of columns in the table; 06988 * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values. 06989 * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes. 06990 * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers. 06991 * 06992 * \par 06993 * Let <code>(x, y)</code> specify the desired interpolation point. Then define: 06994 * <pre> 06995 * XF = floor(x) 06996 * YF = floor(y) 06997 * </pre> 06998 * \par 06999 * The interpolated output point is computed as: 07000 * <pre> 07001 * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF)) 07002 * + f(XF+1, YF) * (x-XF)*(1-(y-YF)) 07003 * + f(XF, YF+1) * (1-(x-XF))*(y-YF) 07004 * + f(XF+1, YF+1) * (x-XF)*(y-YF) 07005 * </pre> 07006 * Note that the coordinates (x, y) contain integer and fractional components. 07007 * The integer components specify which portion of the table to use while the 07008 * fractional components control the interpolation processor. 07009 * 07010 * \par 07011 * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output. 07012 */ 07013 07014 /** 07015 * @addtogroup BilinearInterpolate 07016 * @{ 07017 */ 07018 07019 /** 07020 * 07021 * @brief Floating-point bilinear interpolation. 07022 * @param[in,out] *S points to an instance of the interpolation structure. 07023 * @param[in] X interpolation coordinate. 07024 * @param[in] Y interpolation coordinate. 07025 * @return out interpolated value. 07026 */ 07027 07028 07029 static __INLINE float32_t arm_bilinear_interp_f32( 07030 const arm_bilinear_interp_instance_f32 * S, 07031 float32_t X, 07032 float32_t Y) 07033 { 07034 float32_t out; 07035 float32_t f00, f01, f10, f11; 07036 float32_t *pData = S->pData; 07037 int32_t xIndex, yIndex, index; 07038 float32_t xdiff, ydiff; 07039 float32_t b1, b2, b3, b4; 07040 07041 xIndex = (int32_t) X; 07042 yIndex = (int32_t) Y; 07043 07044 /* Care taken for table outside boundary */ 07045 /* Returns zero output when values are outside table boundary */ 07046 if(xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 07047 || yIndex > (S->numCols - 1)) 07048 { 07049 return (0); 07050 } 07051 07052 /* Calculation of index for two nearest points in X-direction */ 07053 index = (xIndex - 1) + (yIndex - 1) * S->numCols; 07054 07055 07056 /* Read two nearest points in X-direction */ 07057 f00 = pData[index]; 07058 f01 = pData[index + 1]; 07059 07060 /* Calculation of index for two nearest points in Y-direction */ 07061 index = (xIndex - 1) + (yIndex) * S->numCols; 07062 07063 07064 /* Read two nearest points in Y-direction */ 07065 f10 = pData[index]; 07066 f11 = pData[index + 1]; 07067 07068 /* Calculation of intermediate values */ 07069 b1 = f00; 07070 b2 = f01 - f00; 07071 b3 = f10 - f00; 07072 b4 = f00 - f01 - f10 + f11; 07073 07074 /* Calculation of fractional part in X */ 07075 xdiff = X - xIndex; 07076 07077 /* Calculation of fractional part in Y */ 07078 ydiff = Y - yIndex; 07079 07080 /* Calculation of bi-linear interpolated output */ 07081 out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff; 07082 07083 /* return to application */ 07084 return (out); 07085 07086 } 07087 07088 /** 07089 * 07090 * @brief Q31 bilinear interpolation. 07091 * @param[in,out] *S points to an instance of the interpolation structure. 07092 * @param[in] X interpolation coordinate in 12.20 format. 07093 * @param[in] Y interpolation coordinate in 12.20 format. 07094 * @return out interpolated value. 07095 */ 07096 07097 static __INLINE q31_t arm_bilinear_interp_q31( 07098 arm_bilinear_interp_instance_q31 * S, 07099 q31_t X, 07100 q31_t Y) 07101 { 07102 q31_t out; /* Temporary output */ 07103 q31_t acc = 0; /* output */ 07104 q31_t xfract, yfract; /* X, Y fractional parts */ 07105 q31_t x1, x2, y1, y2; /* Nearest output values */ 07106 int32_t rI, cI; /* Row and column indices */ 07107 q31_t *pYData = S->pData; /* pointer to output table values */ 07108 uint32_t nCols = S->numCols; /* num of rows */ 07109 07110 07111 /* Input is in 12.20 format */ 07112 /* 12 bits for the table index */ 07113 /* Index value calculation */ 07114 rI = ((X & 0xFFF00000) >> 20u); 07115 07116 /* Input is in 12.20 format */ 07117 /* 12 bits for the table index */ 07118 /* Index value calculation */ 07119 cI = ((Y & 0xFFF00000) >> 20u); 07120 07121 /* Care taken for table outside boundary */ 07122 /* Returns zero output when values are outside table boundary */ 07123 if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) 07124 { 07125 return (0); 07126 } 07127 07128 /* 20 bits for the fractional part */ 07129 /* shift left xfract by 11 to keep 1.31 format */ 07130 xfract = (X & 0x000FFFFF) << 11u; 07131 07132 /* Read two nearest output values from the index */ 07133 x1 = pYData[(rI) + nCols * (cI)]; 07134 x2 = pYData[(rI) + nCols * (cI) + 1u]; 07135 07136 /* 20 bits for the fractional part */ 07137 /* shift left yfract by 11 to keep 1.31 format */ 07138 yfract = (Y & 0x000FFFFF) << 11u; 07139 07140 /* Read two nearest output values from the index */ 07141 y1 = pYData[(rI) + nCols * (cI + 1)]; 07142 y2 = pYData[(rI) + nCols * (cI + 1) + 1u]; 07143 07144 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */ 07145 out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32)); 07146 acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32)); 07147 07148 /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */ 07149 out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32)); 07150 acc += ((q31_t) ((q63_t) out * (xfract) >> 32)); 07151 07152 /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */ 07153 out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32)); 07154 acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); 07155 07156 /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */ 07157 out = ((q31_t) ((q63_t) y2 * (xfract) >> 32)); 07158 acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); 07159 07160 /* Convert acc to 1.31(q31) format */ 07161 return (acc << 2u); 07162 07163 } 07164 07165 /** 07166 * @brief Q15 bilinear interpolation. 07167 * @param[in,out] *S points to an instance of the interpolation structure. 07168 * @param[in] X interpolation coordinate in 12.20 format. 07169 * @param[in] Y interpolation coordinate in 12.20 format. 07170 * @return out interpolated value. 07171 */ 07172 07173 static __INLINE q15_t arm_bilinear_interp_q15( 07174 arm_bilinear_interp_instance_q15 * S, 07175 q31_t X, 07176 q31_t Y) 07177 { 07178 q63_t acc = 0; /* output */ 07179 q31_t out; /* Temporary output */ 07180 q15_t x1, x2, y1, y2; /* Nearest output values */ 07181 q31_t xfract, yfract; /* X, Y fractional parts */ 07182 int32_t rI, cI; /* Row and column indices */ 07183 q15_t *pYData = S->pData; /* pointer to output table values */ 07184 uint32_t nCols = S->numCols; /* num of rows */ 07185 07186 /* Input is in 12.20 format */ 07187 /* 12 bits for the table index */ 07188 /* Index value calculation */ 07189 rI = ((X & 0xFFF00000) >> 20); 07190 07191 /* Input is in 12.20 format */ 07192 /* 12 bits for the table index */ 07193 /* Index value calculation */ 07194 cI = ((Y & 0xFFF00000) >> 20); 07195 07196 /* Care taken for table outside boundary */ 07197 /* Returns zero output when values are outside table boundary */ 07198 if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) 07199 { 07200 return (0); 07201 } 07202 07203 /* 20 bits for the fractional part */ 07204 /* xfract should be in 12.20 format */ 07205 xfract = (X & 0x000FFFFF); 07206 07207 /* Read two nearest output values from the index */ 07208 x1 = pYData[(rI) + nCols * (cI)]; 07209 x2 = pYData[(rI) + nCols * (cI) + 1u]; 07210 07211 07212 /* 20 bits for the fractional part */ 07213 /* yfract should be in 12.20 format */ 07214 yfract = (Y & 0x000FFFFF); 07215 07216 /* Read two nearest output values from the index */ 07217 y1 = pYData[(rI) + nCols * (cI + 1)]; 07218 y2 = pYData[(rI) + nCols * (cI + 1) + 1u]; 07219 07220 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */ 07221 07222 /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */ 07223 /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */ 07224 out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u); 07225 acc = ((q63_t) out * (0xFFFFF - yfract)); 07226 07227 /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */ 07228 out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u); 07229 acc += ((q63_t) out * (xfract)); 07230 07231 /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */ 07232 out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u); 07233 acc += ((q63_t) out * (yfract)); 07234 07235 /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */ 07236 out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u); 07237 acc += ((q63_t) out * (yfract)); 07238 07239 /* acc is in 13.51 format and down shift acc by 36 times */ 07240 /* Convert out to 1.15 format */ 07241 return (acc >> 36); 07242 07243 } 07244 07245 /** 07246 * @brief Q7 bilinear interpolation. 07247 * @param[in,out] *S points to an instance of the interpolation structure. 07248 * @param[in] X interpolation coordinate in 12.20 format. 07249 * @param[in] Y interpolation coordinate in 12.20 format. 07250 * @return out interpolated value. 07251 */ 07252 07253 static __INLINE q7_t arm_bilinear_interp_q7( 07254 arm_bilinear_interp_instance_q7 * S, 07255 q31_t X, 07256 q31_t Y) 07257 { 07258 q63_t acc = 0; /* output */ 07259 q31_t out; /* Temporary output */ 07260 q31_t xfract, yfract; /* X, Y fractional parts */ 07261 q7_t x1, x2, y1, y2; /* Nearest output values */ 07262 int32_t rI, cI; /* Row and column indices */ 07263 q7_t *pYData = S->pData; /* pointer to output table values */ 07264 uint32_t nCols = S->numCols; /* num of rows */ 07265 07266 /* Input is in 12.20 format */ 07267 /* 12 bits for the table index */ 07268 /* Index value calculation */ 07269 rI = ((X & 0xFFF00000) >> 20); 07270 07271 /* Input is in 12.20 format */ 07272 /* 12 bits for the table index */ 07273 /* Index value calculation */ 07274 cI = ((Y & 0xFFF00000) >> 20); 07275 07276 /* Care taken for table outside boundary */ 07277 /* Returns zero output when values are outside table boundary */ 07278 if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) 07279 { 07280 return (0); 07281 } 07282 07283 /* 20 bits for the fractional part */ 07284 /* xfract should be in 12.20 format */ 07285 xfract = (X & 0x000FFFFF); 07286 07287 /* Read two nearest output values from the index */ 07288 x1 = pYData[(rI) + nCols * (cI)]; 07289 x2 = pYData[(rI) + nCols * (cI) + 1u]; 07290 07291 07292 /* 20 bits for the fractional part */ 07293 /* yfract should be in 12.20 format */ 07294 yfract = (Y & 0x000FFFFF); 07295 07296 /* Read two nearest output values from the index */ 07297 y1 = pYData[(rI) + nCols * (cI + 1)]; 07298 y2 = pYData[(rI) + nCols * (cI + 1) + 1u]; 07299 07300 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */ 07301 out = ((x1 * (0xFFFFF - xfract))); 07302 acc = (((q63_t) out * (0xFFFFF - yfract))); 07303 07304 /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */ 07305 out = ((x2 * (0xFFFFF - yfract))); 07306 acc += (((q63_t) out * (xfract))); 07307 07308 /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */ 07309 out = ((y1 * (0xFFFFF - xfract))); 07310 acc += (((q63_t) out * (yfract))); 07311 07312 /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */ 07313 out = ((y2 * (yfract))); 07314 acc += (((q63_t) out * (xfract))); 07315 07316 /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */ 07317 return (acc >> 40); 07318 07319 } 07320 07321 /** 07322 * @} end of BilinearInterpolate group 07323 */ 07324 07325 07326 #if defined ( __CC_ARM ) //Keil 07327 //SMMLAR 07328 #define multAcc_32x32_keep32_R(a, x, y) \ 07329 a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32) 07330 07331 //SMMLSR 07332 #define multSub_32x32_keep32_R(a, x, y) \ 07333 a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32) 07334 07335 //SMMULR 07336 #define mult_32x32_keep32_R(a, x, y) \ 07337 a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32) 07338 07339 //Enter low optimization region - place directly above function definition 07340 #define LOW_OPTIMIZATION_ENTER \ 07341 _Pragma ("push") \ 07342 _Pragma ("O1") 07343 07344 //Exit low optimization region - place directly after end of function definition 07345 #define LOW_OPTIMIZATION_EXIT \ 07346 _Pragma ("pop") 07347 07348 //Enter low optimization region - place directly above function definition 07349 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER 07350 07351 //Exit low optimization region - place directly after end of function definition 07352 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT 07353 07354 #elif defined(__ICCARM__) //IAR 07355 //SMMLA 07356 #define multAcc_32x32_keep32_R(a, x, y) \ 07357 a += (q31_t) (((q63_t) x * y) >> 32) 07358 07359 //SMMLS 07360 #define multSub_32x32_keep32_R(a, x, y) \ 07361 a -= (q31_t) (((q63_t) x * y) >> 32) 07362 07363 //SMMUL 07364 #define mult_32x32_keep32_R(a, x, y) \ 07365 a = (q31_t) (((q63_t) x * y ) >> 32) 07366 07367 //Enter low optimization region - place directly above function definition 07368 #define LOW_OPTIMIZATION_ENTER \ 07369 _Pragma ("optimize=low") 07370 07371 //Exit low optimization region - place directly after end of function definition 07372 #define LOW_OPTIMIZATION_EXIT 07373 07374 //Enter low optimization region - place directly above function definition 07375 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \ 07376 _Pragma ("optimize=low") 07377 07378 //Exit low optimization region - place directly after end of function definition 07379 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT 07380 07381 #elif defined(__GNUC__) 07382 //SMMLA 07383 #define multAcc_32x32_keep32_R(a, x, y) \ 07384 a += (q31_t) (((q63_t) x * y) >> 32) 07385 07386 //SMMLS 07387 #define multSub_32x32_keep32_R(a, x, y) \ 07388 a -= (q31_t) (((q63_t) x * y) >> 32) 07389 07390 //SMMUL 07391 #define mult_32x32_keep32_R(a, x, y) \ 07392 a = (q31_t) (((q63_t) x * y ) >> 32) 07393 07394 #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") )) 07395 07396 #define LOW_OPTIMIZATION_EXIT 07397 07398 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER 07399 07400 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT 07401 07402 #elif defined(__CSMC__) // Cosmic 07403 //SMMLA 07404 #define multAcc_32x32_keep32_R(a, x, y) \ 07405 a += (q31_t) (((q63_t) x * y) >> 32) 07406 07407 //SMMLS 07408 #define multSub_32x32_keep32_R(a, x, y) \ 07409 a -= (q31_t) (((q63_t) x * y) >> 32) 07410 07411 //SMMUL 07412 #define mult_32x32_keep32_R(a, x, y) \ 07413 a = (q31_t) (((q63_t) x * y ) >> 32) 07414 07415 #define LOW_OPTIMIZATION_ENTER 07416 #define LOW_OPTIMIZATION_EXIT 07417 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER 07418 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT 07419 07420 #endif 07421 07422 07423 07424 07425 07426 #ifdef __cplusplus 07427 } 07428 #endif 07429 07430 07431 #endif /* _ARM_MATH_H */ 07432 07433 07434 /** 07435 * 07436 * End of file. 07437 */
Generated on Tue Jul 12 2022 20:37:42 by 1.7.2