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