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