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