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