blob: 4be7e8c8488918711e56fa67406c30d8e0fcd9e1 [file] [log] [blame]
Kévin Redon69b92d92019-01-24 16:39:20 +01001/* ----------------------------------------------------------------------
2 * Project: CMSIS DSP Library
3 * Title: arm_math.h
4 * Description: Public header file for CMSIS DSP Library
5 *
6 * $Date: 27. January 2017
7 * $Revision: V.1.5.1
8 *
9 * Target Processor: Cortex-M cores
10 * -------------------------------------------------------------------- */
11/*
12 * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
13 *
14 * SPDX-License-Identifier: Apache-2.0
15 *
16 * Licensed under the Apache License, Version 2.0 (the License); you may
17 * not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
24 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28
29/**
30 \mainpage CMSIS DSP Software Library
31 *
32 * Introduction
33 * ------------
34 *
35 * This user manual describes the CMSIS DSP software library,
36 * a suite of common signal processing functions for use on Cortex-M processor based devices.
37 *
38 * The library is divided into a number of functions each covering a specific category:
39 * - Basic math functions
40 * - Fast math functions
41 * - Complex math functions
42 * - Filters
43 * - Matrix functions
44 * - Transforms
45 * - Motor control functions
46 * - Statistical functions
47 * - Support functions
48 * - Interpolation functions
49 *
50 * The library has separate functions for operating on 8-bit integers, 16-bit integers,
51 * 32-bit integer and 32-bit floating-point values.
52 *
53 * Using the Library
54 * ------------
55 *
56 * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
57 * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit)
58 * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit)
59 * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit)
60 * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on)
61 * - arm_cortexM7l_math.lib (Cortex-M7, Little endian)
62 * - arm_cortexM7b_math.lib (Cortex-M7, Big endian)
63 * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit)
64 * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit)
65 * - arm_cortexM4l_math.lib (Cortex-M4, Little endian)
66 * - arm_cortexM4b_math.lib (Cortex-M4, Big endian)
67 * - arm_cortexM3l_math.lib (Cortex-M3, Little endian)
68 * - arm_cortexM3b_math.lib (Cortex-M3, Big endian)
69 * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian)
70 * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian)
71 * - arm_ARMv8MBLl_math.lib (ARMv8M Baseline, Little endian)
72 * - arm_ARMv8MMLl_math.lib (ARMv8M Mainline, Little endian)
73 * - arm_ARMv8MMLlfsp_math.lib (ARMv8M Mainline, Little endian, Single Precision Floating Point Unit)
74 * - arm_ARMv8MMLld_math.lib (ARMv8M Mainline, Little endian, DSP instructions)
75 * - arm_ARMv8MMLldfsp_math.lib (ARMv8M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit)
76 *
77 * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
78 * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
79 * public header file <code> arm_math.h</code> for Cortex-M cores with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
80 * Define the appropriate pre processor MACRO ARM_MATH_CM7 or ARM_MATH_CM4 or ARM_MATH_CM3 or
81 * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
82 * For ARMv8M cores define pre processor MACRO ARM_MATH_ARMV8MBL or ARM_MATH_ARMV8MML.
83 * Set Pre processor MACRO __DSP_PRESENT if ARMv8M Mainline core supports DSP instructions.
84 *
85 *
86 * Examples
87 * --------
88 *
89 * The library ships with a number of examples which demonstrate how to use the library functions.
90 *
91 * Toolchain Support
92 * ------------
93 *
94 * The library has been developed and tested with MDK-ARM version 5.14.0.0
95 * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
96 *
97 * Building the Library
98 * ------------
99 *
100 * 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.
101 * - arm_cortexM_math.uvprojx
102 *
103 *
104 * 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.
105 *
106 * Pre-processor Macros
107 * ------------
108 *
109 * Each library project have differant pre-processor macros.
110 *
111 * - UNALIGNED_SUPPORT_DISABLE:
112 *
113 * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
114 *
115 * - ARM_MATH_BIG_ENDIAN:
116 *
117 * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
118 *
119 * - ARM_MATH_MATRIX_CHECK:
120 *
121 * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
122 *
123 * - ARM_MATH_ROUNDING:
124 *
125 * Define macro ARM_MATH_ROUNDING for rounding on support functions
126 *
127 * - ARM_MATH_CMx:
128 *
129 * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
130 * and ARM_MATH_CM0 for building library on Cortex-M0 target, ARM_MATH_CM0PLUS for building library on Cortex-M0+ target, and
131 * ARM_MATH_CM7 for building the library on cortex-M7.
132 *
133 * - ARM_MATH_ARMV8MxL:
134 *
135 * Define macro ARM_MATH_ARMV8MBL for building the library on ARMv8M Baseline target, ARM_MATH_ARMV8MBL for building library
136 * on ARMv8M Mainline target.
137 *
138 * - __FPU_PRESENT:
139 *
140 * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for floating point libraries.
141 *
142 * - __DSP_PRESENT:
143 *
144 * Initialize macro __DSP_PRESENT = 1 when ARMv8M Mainline core supports DSP instructions.
145 *
146 * <hr>
147 * CMSIS-DSP in ARM::CMSIS Pack
148 * -----------------------------
149 *
150 * The following files relevant to CMSIS-DSP are present in the <b>ARM::CMSIS</b> Pack directories:
151 * |File/Folder |Content |
152 * |------------------------------|------------------------------------------------------------------------|
153 * |\b CMSIS\\Documentation\\DSP | This documentation |
154 * |\b CMSIS\\DSP_Lib | Software license agreement (license.txt) |
155 * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions |
156 * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library |
157 *
158 * <hr>
159 * Revision History of CMSIS-DSP
160 * ------------
161 * Please refer to \ref ChangeLog_pg.
162 *
163 * Copyright Notice
164 * ------------
165 *
166 * Copyright (C) 2010-2015 ARM Limited. All rights reserved.
167 */
168
169
170/**
171 * @defgroup groupMath Basic Math Functions
172 */
173
174/**
175 * @defgroup groupFastMath Fast Math Functions
176 * This set of functions provides a fast approximation to sine, cosine, and square root.
177 * As compared to most of the other functions in the CMSIS math library, the fast math functions
178 * operate on individual values and not arrays.
179 * There are separate functions for Q15, Q31, and floating-point data.
180 *
181 */
182
183/**
184 * @defgroup groupCmplxMath Complex Math Functions
185 * This set of functions operates on complex data vectors.
186 * The data in the complex arrays is stored in an interleaved fashion
187 * (real, imag, real, imag, ...).
188 * In the API functions, the number of samples in a complex array refers
189 * to the number of complex values; the array contains twice this number of
190 * real values.
191 */
192
193/**
194 * @defgroup groupFilters Filtering Functions
195 */
196
197/**
198 * @defgroup groupMatrix Matrix Functions
199 *
200 * This set of functions provides basic matrix math operations.
201 * The functions operate on matrix data structures. For example,
202 * the type
203 * definition for the floating-point matrix structure is shown
204 * below:
205 * <pre>
206 * typedef struct
207 * {
208 * uint16_t numRows; // number of rows of the matrix.
209 * uint16_t numCols; // number of columns of the matrix.
210 * float32_t *pData; // points to the data of the matrix.
211 * } arm_matrix_instance_f32;
212 * </pre>
213 * There are similar definitions for Q15 and Q31 data types.
214 *
215 * The structure specifies the size of the matrix and then points to
216 * an array of data. The array is of size <code>numRows X numCols</code>
217 * and the values are arranged in row order. That is, the
218 * matrix element (i, j) is stored at:
219 * <pre>
220 * pData[i*numCols + j]
221 * </pre>
222 *
223 * \par Init Functions
224 * There is an associated initialization function for each type of matrix
225 * data structure.
226 * The initialization function sets the values of the internal structure fields.
227 * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
228 * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
229 *
230 * \par
231 * Use of the initialization function is optional. However, if initialization function is used
232 * then the instance structure cannot be placed into a const data section.
233 * To place the instance structure in a const data
234 * section, manually initialize the data structure. For example:
235 * <pre>
236 * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
237 * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
238 * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
239 * </pre>
240 * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
241 * specifies the number of columns, and <code>pData</code> points to the
242 * data array.
243 *
244 * \par Size Checking
245 * By default all of the matrix functions perform size checking on the input and
246 * output matrices. For example, the matrix addition function verifies that the
247 * two input matrices and the output matrix all have the same number of rows and
248 * columns. If the size check fails the functions return:
249 * <pre>
250 * ARM_MATH_SIZE_MISMATCH
251 * </pre>
252 * Otherwise the functions return
253 * <pre>
254 * ARM_MATH_SUCCESS
255 * </pre>
256 * There is some overhead associated with this matrix size checking.
257 * The matrix size checking is enabled via the \#define
258 * <pre>
259 * ARM_MATH_MATRIX_CHECK
260 * </pre>
261 * within the library project settings. By default this macro is defined
262 * and size checking is enabled. By changing the project settings and
263 * undefining this macro size checking is eliminated and the functions
264 * run a bit faster. With size checking disabled the functions always
265 * return <code>ARM_MATH_SUCCESS</code>.
266 */
267
268/**
269 * @defgroup groupTransforms Transform Functions
270 */
271
272/**
273 * @defgroup groupController Controller Functions
274 */
275
276/**
277 * @defgroup groupStats Statistics Functions
278 */
279/**
280 * @defgroup groupSupport Support Functions
281 */
282
283/**
284 * @defgroup groupInterpolation Interpolation Functions
285 * These functions perform 1- and 2-dimensional interpolation of data.
286 * Linear interpolation is used for 1-dimensional data and
287 * bilinear interpolation is used for 2-dimensional data.
288 */
289
290/**
291 * @defgroup groupExamples Examples
292 */
293#ifndef _ARM_MATH_H
294#define _ARM_MATH_H
295
296/* ignore some GCC warnings */
297#if defined ( __GNUC__ )
298#pragma GCC diagnostic push
299#pragma GCC diagnostic ignored "-Wsign-conversion"
300#pragma GCC diagnostic ignored "-Wconversion"
301#pragma GCC diagnostic ignored "-Wunused-parameter"
302#endif
303
304#define __CMSIS_GENERIC /* disable NVIC and Systick functions */
305
306#if defined(ARM_MATH_CM7)
307 #include "core_cm7.h"
308 #define ARM_MATH_DSP
309#elif defined (ARM_MATH_CM4)
310 #include "core_cm4.h"
311 #define ARM_MATH_DSP
312#elif defined (ARM_MATH_CM3)
313 #include "core_cm3.h"
314#elif defined (ARM_MATH_CM0)
315 #include "core_cm0.h"
316 #define ARM_MATH_CM0_FAMILY
317#elif defined (ARM_MATH_CM0PLUS)
318 #include "core_cm0plus.h"
319 #define ARM_MATH_CM0_FAMILY
320#elif defined (ARM_MATH_ARMV8MBL)
321 #include "core_armv8mbl.h"
322 #define ARM_MATH_CM0_FAMILY
323#elif defined (ARM_MATH_ARMV8MML)
324 #include "core_armv8mml.h"
325 #if (defined (__DSP_PRESENT) && (__DSP_PRESENT == 1))
326 #define ARM_MATH_DSP
327 #endif
328#else
329 #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS, ARM_MATH_CM0, ARM_MATH_ARMV8MBL, ARM_MATH_ARMV8MML"
330#endif
331
332#undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
333#include "string.h"
334#include "math.h"
335#ifdef __cplusplus
336extern "C"
337{
338#endif
339
340
341 /**
342 * @brief Macros required for reciprocal calculation in Normalized LMS
343 */
344
345#define DELTA_Q31 (0x100)
346#define DELTA_Q15 0x5
347#define INDEX_MASK 0x0000003F
348#ifndef PI
349 #define PI 3.14159265358979f
350#endif
351
352 /**
353 * @brief Macros required for SINE and COSINE Fast math approximations
354 */
355
356#define FAST_MATH_TABLE_SIZE 512
357#define FAST_MATH_Q31_SHIFT (32 - 10)
358#define FAST_MATH_Q15_SHIFT (16 - 10)
359#define CONTROLLER_Q31_SHIFT (32 - 9)
360#define TABLE_SPACING_Q31 0x400000
361#define TABLE_SPACING_Q15 0x80
362
363 /**
364 * @brief Macros required for SINE and COSINE Controller functions
365 */
366 /* 1.31(q31) Fixed value of 2/360 */
367 /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
368#define INPUT_SPACING 0xB60B61
369
370 /**
371 * @brief Macro for Unaligned Support
372 */
373#ifndef UNALIGNED_SUPPORT_DISABLE
374 #define ALIGN4
375#else
376 #if defined (__GNUC__)
377 #define ALIGN4 __attribute__((aligned(4)))
378 #else
379 #define ALIGN4 __align(4)
380 #endif
381#endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
382
383 /**
384 * @brief Error status returned by some functions in the library.
385 */
386
387 typedef enum
388 {
389 ARM_MATH_SUCCESS = 0, /**< No error */
390 ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
391 ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
392 ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
393 ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
394 ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
395 ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
396 } arm_status;
397
398 /**
399 * @brief 8-bit fractional data type in 1.7 format.
400 */
401 typedef int8_t q7_t;
402
403 /**
404 * @brief 16-bit fractional data type in 1.15 format.
405 */
406 typedef int16_t q15_t;
407
408 /**
409 * @brief 32-bit fractional data type in 1.31 format.
410 */
411 typedef int32_t q31_t;
412
413 /**
414 * @brief 64-bit fractional data type in 1.63 format.
415 */
416 typedef int64_t q63_t;
417
418 /**
419 * @brief 32-bit floating-point type definition.
420 */
421 typedef float float32_t;
422
423 /**
424 * @brief 64-bit floating-point type definition.
425 */
426 typedef double float64_t;
427
428 /**
429 * @brief definition to read/write two 16 bit values.
430 */
431#if defined ( __CC_ARM )
432 #define __SIMD32_TYPE int32_t __packed
433 #define CMSIS_UNUSED __attribute__((unused))
434 #define CMSIS_INLINE __attribute__((always_inline))
435
436#elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
437 #define __SIMD32_TYPE int32_t
438 #define CMSIS_UNUSED __attribute__((unused))
439 #define CMSIS_INLINE __attribute__((always_inline))
440
441#elif defined ( __GNUC__ )
442 #define __SIMD32_TYPE int32_t
443 #define CMSIS_UNUSED __attribute__((unused))
444 #define CMSIS_INLINE __attribute__((always_inline))
445
446#elif defined ( __ICCARM__ )
447 #define __SIMD32_TYPE int32_t __packed
448 #define CMSIS_UNUSED
449 #define CMSIS_INLINE
450
451#elif defined ( __TI_ARM__ )
452 #define __SIMD32_TYPE int32_t
453 #define CMSIS_UNUSED __attribute__((unused))
454 #define CMSIS_INLINE
455
456#elif defined ( __CSMC__ )
457 #define __SIMD32_TYPE int32_t
458 #define CMSIS_UNUSED
459 #define CMSIS_INLINE
460
461#elif defined ( __TASKING__ )
462 #define __SIMD32_TYPE __unaligned int32_t
463 #define CMSIS_UNUSED
464 #define CMSIS_INLINE
465
466#else
467 #error Unknown compiler
468#endif
469
470#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
471#define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
472#define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
473#define __SIMD64(addr) (*(int64_t **) & (addr))
474
475/* #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
476#if !defined (ARM_MATH_DSP)
477 /**
478 * @brief definition to pack two 16 bit values.
479 */
480#define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
481 (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
482#define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
483 (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
484
485/* #endif // defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
486#endif /* !defined (ARM_MATH_DSP) */
487
488 /**
489 * @brief definition to pack four 8 bit values.
490 */
491#ifndef ARM_MATH_BIG_ENDIAN
492
493#define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
494 (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
495 (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
496 (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
497#else
498
499#define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
500 (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
501 (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
502 (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
503
504#endif
505
506
507 /**
508 * @brief Clips Q63 to Q31 values.
509 */
510 CMSIS_INLINE __STATIC_INLINE q31_t clip_q63_to_q31(
511 q63_t x)
512 {
513 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
514 ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
515 }
516
517 /**
518 * @brief Clips Q63 to Q15 values.
519 */
520 CMSIS_INLINE __STATIC_INLINE q15_t clip_q63_to_q15(
521 q63_t x)
522 {
523 return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
524 ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
525 }
526
527 /**
528 * @brief Clips Q31 to Q7 values.
529 */
530 CMSIS_INLINE __STATIC_INLINE q7_t clip_q31_to_q7(
531 q31_t x)
532 {
533 return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
534 ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
535 }
536
537 /**
538 * @brief Clips Q31 to Q15 values.
539 */
540 CMSIS_INLINE __STATIC_INLINE q15_t clip_q31_to_q15(
541 q31_t x)
542 {
543 return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
544 ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
545 }
546
547 /**
548 * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
549 */
550
551 CMSIS_INLINE __STATIC_INLINE q63_t mult32x64(
552 q63_t x,
553 q31_t y)
554 {
555 return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
556 (((q63_t) (x >> 32) * y)));
557 }
558
559/*
560 #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
561 #define __CLZ __clz
562 #endif
563 */
564/* note: function can be removed when all toolchain support __CLZ for Cortex-M0 */
565#if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) )
566 CMSIS_INLINE __STATIC_INLINE uint32_t __CLZ(
567 q31_t data);
568
569 CMSIS_INLINE __STATIC_INLINE uint32_t __CLZ(
570 q31_t data)
571 {
572 uint32_t count = 0;
573 uint32_t mask = 0x80000000;
574
575 while ((data & mask) == 0)
576 {
577 count += 1u;
578 mask = mask >> 1u;
579 }
580
581 return (count);
582 }
583#endif
584
585 /**
586 * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
587 */
588
589 CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q31(
590 q31_t in,
591 q31_t * dst,
592 q31_t * pRecipTable)
593 {
594 q31_t out;
595 uint32_t tempVal;
596 uint32_t index, i;
597 uint32_t signBits;
598
599 if (in > 0)
600 {
601 signBits = ((uint32_t) (__CLZ( in) - 1));
602 }
603 else
604 {
605 signBits = ((uint32_t) (__CLZ(-in) - 1));
606 }
607
608 /* Convert input sample to 1.31 format */
609 in = (in << signBits);
610
611 /* calculation of index for initial approximated Val */
612 index = (uint32_t)(in >> 24);
613 index = (index & INDEX_MASK);
614
615 /* 1.31 with exp 1 */
616 out = pRecipTable[index];
617
618 /* calculation of reciprocal value */
619 /* running approximation for two iterations */
620 for (i = 0u; i < 2u; i++)
621 {
622 tempVal = (uint32_t) (((q63_t) in * out) >> 31);
623 tempVal = 0x7FFFFFFFu - tempVal;
624 /* 1.31 with exp 1 */
625 /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */
626 out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30);
627 }
628
629 /* write output */
630 *dst = out;
631
632 /* return num of signbits of out = 1/in value */
633 return (signBits + 1u);
634 }
635
636
637 /**
638 * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
639 */
640 CMSIS_INLINE __STATIC_INLINE uint32_t arm_recip_q15(
641 q15_t in,
642 q15_t * dst,
643 q15_t * pRecipTable)
644 {
645 q15_t out = 0;
646 uint32_t tempVal = 0;
647 uint32_t index = 0, i = 0;
648 uint32_t signBits = 0;
649
650 if (in > 0)
651 {
652 signBits = ((uint32_t)(__CLZ( in) - 17));
653 }
654 else
655 {
656 signBits = ((uint32_t)(__CLZ(-in) - 17));
657 }
658
659 /* Convert input sample to 1.15 format */
660 in = (in << signBits);
661
662 /* calculation of index for initial approximated Val */
663 index = (uint32_t)(in >> 8);
664 index = (index & INDEX_MASK);
665
666 /* 1.15 with exp 1 */
667 out = pRecipTable[index];
668
669 /* calculation of reciprocal value */
670 /* running approximation for two iterations */
671 for (i = 0u; i < 2u; i++)
672 {
673 tempVal = (uint32_t) (((q31_t) in * out) >> 15);
674 tempVal = 0x7FFFu - tempVal;
675 /* 1.15 with exp 1 */
676 out = (q15_t) (((q31_t) out * tempVal) >> 14);
677 /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */
678 }
679
680 /* write output */
681 *dst = out;
682
683 /* return num of signbits of out = 1/in value */
684 return (signBits + 1);
685 }
686
687
688 /*
689 * @brief C custom defined intrinisic function for only M0 processors
690 */
691#if defined(ARM_MATH_CM0_FAMILY)
692 CMSIS_INLINE __STATIC_INLINE q31_t __SSAT(
693 q31_t x,
694 uint32_t y)
695 {
696 int32_t posMax, negMin;
697 uint32_t i;
698
699 posMax = 1;
700 for (i = 0; i < (y - 1); i++)
701 {
702 posMax = posMax * 2;
703 }
704
705 if (x > 0)
706 {
707 posMax = (posMax - 1);
708
709 if (x > posMax)
710 {
711 x = posMax;
712 }
713 }
714 else
715 {
716 negMin = -posMax;
717
718 if (x < negMin)
719 {
720 x = negMin;
721 }
722 }
723 return (x);
724 }
725#endif /* end of ARM_MATH_CM0_FAMILY */
726
727
728 /*
729 * @brief C custom defined intrinsic function for M3 and M0 processors
730 */
731/* #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
732#if !defined (ARM_MATH_DSP)
733
734 /*
735 * @brief C custom defined QADD8 for M3 and M0 processors
736 */
737 CMSIS_INLINE __STATIC_INLINE uint32_t __QADD8(
738 uint32_t x,
739 uint32_t y)
740 {
741 q31_t r, s, t, u;
742
743 r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
744 s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
745 t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
746 u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
747
748 return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
749 }
750
751
752 /*
753 * @brief C custom defined QSUB8 for M3 and M0 processors
754 */
755 CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB8(
756 uint32_t x,
757 uint32_t y)
758 {
759 q31_t r, s, t, u;
760
761 r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF;
762 s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF;
763 t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF;
764 u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF;
765
766 return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r )));
767 }
768
769
770 /*
771 * @brief C custom defined QADD16 for M3 and M0 processors
772 */
773 CMSIS_INLINE __STATIC_INLINE uint32_t __QADD16(
774 uint32_t x,
775 uint32_t y)
776 {
777/* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */
778 q31_t r = 0, s = 0;
779
780 r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
781 s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
782
783 return ((uint32_t)((s << 16) | (r )));
784 }
785
786
787 /*
788 * @brief C custom defined SHADD16 for M3 and M0 processors
789 */
790 CMSIS_INLINE __STATIC_INLINE uint32_t __SHADD16(
791 uint32_t x,
792 uint32_t y)
793 {
794 q31_t r, s;
795
796 r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
797 s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
798
799 return ((uint32_t)((s << 16) | (r )));
800 }
801
802
803 /*
804 * @brief C custom defined QSUB16 for M3 and M0 processors
805 */
806 CMSIS_INLINE __STATIC_INLINE uint32_t __QSUB16(
807 uint32_t x,
808 uint32_t y)
809 {
810 q31_t r, s;
811
812 r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
813 s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
814
815 return ((uint32_t)((s << 16) | (r )));
816 }
817
818
819 /*
820 * @brief C custom defined SHSUB16 for M3 and M0 processors
821 */
822 CMSIS_INLINE __STATIC_INLINE uint32_t __SHSUB16(
823 uint32_t x,
824 uint32_t y)
825 {
826 q31_t r, s;
827
828 r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
829 s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
830
831 return ((uint32_t)((s << 16) | (r )));
832 }
833
834
835 /*
836 * @brief C custom defined QASX for M3 and M0 processors
837 */
838 CMSIS_INLINE __STATIC_INLINE uint32_t __QASX(
839 uint32_t x,
840 uint32_t y)
841 {
842 q31_t r, s;
843
844 r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
845 s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
846
847 return ((uint32_t)((s << 16) | (r )));
848 }
849
850
851 /*
852 * @brief C custom defined SHASX for M3 and M0 processors
853 */
854 CMSIS_INLINE __STATIC_INLINE uint32_t __SHASX(
855 uint32_t x,
856 uint32_t y)
857 {
858 q31_t r, s;
859
860 r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
861 s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
862
863 return ((uint32_t)((s << 16) | (r )));
864 }
865
866
867 /*
868 * @brief C custom defined QSAX for M3 and M0 processors
869 */
870 CMSIS_INLINE __STATIC_INLINE uint32_t __QSAX(
871 uint32_t x,
872 uint32_t y)
873 {
874 q31_t r, s;
875
876 r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF;
877 s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF;
878
879 return ((uint32_t)((s << 16) | (r )));
880 }
881
882
883 /*
884 * @brief C custom defined SHSAX for M3 and M0 processors
885 */
886 CMSIS_INLINE __STATIC_INLINE uint32_t __SHSAX(
887 uint32_t x,
888 uint32_t y)
889 {
890 q31_t r, s;
891
892 r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF;
893 s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF;
894
895 return ((uint32_t)((s << 16) | (r )));
896 }
897
898
899 /*
900 * @brief C custom defined SMUSDX for M3 and M0 processors
901 */
902 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSDX(
903 uint32_t x,
904 uint32_t y)
905 {
906 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
907 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
908 }
909
910 /*
911 * @brief C custom defined SMUADX for M3 and M0 processors
912 */
913 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUADX(
914 uint32_t x,
915 uint32_t y)
916 {
917 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
918 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) ));
919 }
920
921
922 /*
923 * @brief C custom defined QADD for M3 and M0 processors
924 */
925 CMSIS_INLINE __STATIC_INLINE int32_t __QADD(
926 int32_t x,
927 int32_t y)
928 {
929 return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y)));
930 }
931
932
933 /*
934 * @brief C custom defined QSUB for M3 and M0 processors
935 */
936 CMSIS_INLINE __STATIC_INLINE int32_t __QSUB(
937 int32_t x,
938 int32_t y)
939 {
940 return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y)));
941 }
942
943
944 /*
945 * @brief C custom defined SMLAD for M3 and M0 processors
946 */
947 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLAD(
948 uint32_t x,
949 uint32_t y,
950 uint32_t sum)
951 {
952 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
953 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
954 ( ((q31_t)sum ) ) ));
955 }
956
957
958 /*
959 * @brief C custom defined SMLADX for M3 and M0 processors
960 */
961 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLADX(
962 uint32_t x,
963 uint32_t y,
964 uint32_t sum)
965 {
966 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
967 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
968 ( ((q31_t)sum ) ) ));
969 }
970
971
972 /*
973 * @brief C custom defined SMLSDX for M3 and M0 processors
974 */
975 CMSIS_INLINE __STATIC_INLINE uint32_t __SMLSDX(
976 uint32_t x,
977 uint32_t y,
978 uint32_t sum)
979 {
980 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) -
981 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
982 ( ((q31_t)sum ) ) ));
983 }
984
985
986 /*
987 * @brief C custom defined SMLALD for M3 and M0 processors
988 */
989 CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALD(
990 uint32_t x,
991 uint32_t y,
992 uint64_t sum)
993 {
994/* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */
995 return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
996 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) +
997 ( ((q63_t)sum ) ) ));
998 }
999
1000
1001 /*
1002 * @brief C custom defined SMLALDX for M3 and M0 processors
1003 */
1004 CMSIS_INLINE __STATIC_INLINE uint64_t __SMLALDX(
1005 uint32_t x,
1006 uint32_t y,
1007 uint64_t sum)
1008 {
1009/* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */
1010 return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) +
1011 ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) +
1012 ( ((q63_t)sum ) ) ));
1013 }
1014
1015
1016 /*
1017 * @brief C custom defined SMUAD for M3 and M0 processors
1018 */
1019 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUAD(
1020 uint32_t x,
1021 uint32_t y)
1022 {
1023 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) +
1024 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
1025 }
1026
1027
1028 /*
1029 * @brief C custom defined SMUSD for M3 and M0 processors
1030 */
1031 CMSIS_INLINE __STATIC_INLINE uint32_t __SMUSD(
1032 uint32_t x,
1033 uint32_t y)
1034 {
1035 return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) -
1036 ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) ));
1037 }
1038
1039
1040 /*
1041 * @brief C custom defined SXTB16 for M3 and M0 processors
1042 */
1043 CMSIS_INLINE __STATIC_INLINE uint32_t __SXTB16(
1044 uint32_t x)
1045 {
1046 return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) |
1047 ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) ));
1048 }
1049
1050 /*
1051 * @brief C custom defined SMMLA for M3 and M0 processors
1052 */
1053 CMSIS_INLINE __STATIC_INLINE int32_t __SMMLA(
1054 int32_t x,
1055 int32_t y,
1056 int32_t sum)
1057 {
1058 return (sum + (int32_t) (((int64_t) x * y) >> 32));
1059 }
1060
1061#if 0
1062 /*
1063 * @brief C custom defined PKHBT for unavailable DSP extension
1064 */
1065 CMSIS_INLINE __STATIC_INLINE uint32_t __PKHBT(
1066 uint32_t x,
1067 uint32_t y,
1068 uint32_t leftshift)
1069 {
1070 return ( ((x ) & 0x0000FFFFUL) |
1071 ((y << leftshift) & 0xFFFF0000UL) );
1072 }
1073
1074 /*
1075 * @brief C custom defined PKHTB for unavailable DSP extension
1076 */
1077 CMSIS_INLINE __STATIC_INLINE uint32_t __PKHTB(
1078 uint32_t x,
1079 uint32_t y,
1080 uint32_t rightshift)
1081 {
1082 return ( ((x ) & 0xFFFF0000UL) |
1083 ((y >> rightshift) & 0x0000FFFFUL) );
1084 }
1085#endif
1086
1087/* #endif // defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
1088#endif /* !defined (ARM_MATH_DSP) */
1089
1090
1091 /**
1092 * @brief Instance structure for the Q7 FIR filter.
1093 */
1094 typedef struct
1095 {
1096 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1097 q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1098 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
1099 } arm_fir_instance_q7;
1100
1101 /**
1102 * @brief Instance structure for the Q15 FIR filter.
1103 */
1104 typedef struct
1105 {
1106 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1107 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1108 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
1109 } arm_fir_instance_q15;
1110
1111 /**
1112 * @brief Instance structure for the Q31 FIR filter.
1113 */
1114 typedef struct
1115 {
1116 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1117 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1118 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
1119 } arm_fir_instance_q31;
1120
1121 /**
1122 * @brief Instance structure for the floating-point FIR filter.
1123 */
1124 typedef struct
1125 {
1126 uint16_t numTaps; /**< number of filter coefficients in the filter. */
1127 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
1128 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
1129 } arm_fir_instance_f32;
1130
1131
1132 /**
1133 * @brief Processing function for the Q7 FIR filter.
1134 * @param[in] S points to an instance of the Q7 FIR filter structure.
1135 * @param[in] pSrc points to the block of input data.
1136 * @param[out] pDst points to the block of output data.
1137 * @param[in] blockSize number of samples to process.
1138 */
1139 void arm_fir_q7(
1140 const arm_fir_instance_q7 * S,
1141 q7_t * pSrc,
1142 q7_t * pDst,
1143 uint32_t blockSize);
1144
1145
1146 /**
1147 * @brief Initialization function for the Q7 FIR filter.
1148 * @param[in,out] S points to an instance of the Q7 FIR structure.
1149 * @param[in] numTaps Number of filter coefficients in the filter.
1150 * @param[in] pCoeffs points to the filter coefficients.
1151 * @param[in] pState points to the state buffer.
1152 * @param[in] blockSize number of samples that are processed.
1153 */
1154 void arm_fir_init_q7(
1155 arm_fir_instance_q7 * S,
1156 uint16_t numTaps,
1157 q7_t * pCoeffs,
1158 q7_t * pState,
1159 uint32_t blockSize);
1160
1161
1162 /**
1163 * @brief Processing function for the Q15 FIR filter.
1164 * @param[in] S points to an instance of the Q15 FIR structure.
1165 * @param[in] pSrc points to the block of input data.
1166 * @param[out] pDst points to the block of output data.
1167 * @param[in] blockSize number of samples to process.
1168 */
1169 void arm_fir_q15(
1170 const arm_fir_instance_q15 * S,
1171 q15_t * pSrc,
1172 q15_t * pDst,
1173 uint32_t blockSize);
1174
1175
1176 /**
1177 * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
1178 * @param[in] S points to an instance of the Q15 FIR filter structure.
1179 * @param[in] pSrc points to the block of input data.
1180 * @param[out] pDst points to the block of output data.
1181 * @param[in] blockSize number of samples to process.
1182 */
1183 void arm_fir_fast_q15(
1184 const arm_fir_instance_q15 * S,
1185 q15_t * pSrc,
1186 q15_t * pDst,
1187 uint32_t blockSize);
1188
1189
1190 /**
1191 * @brief Initialization function for the Q15 FIR filter.
1192 * @param[in,out] S points to an instance of the Q15 FIR filter structure.
1193 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
1194 * @param[in] pCoeffs points to the filter coefficients.
1195 * @param[in] pState points to the state buffer.
1196 * @param[in] blockSize number of samples that are processed at a time.
1197 * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
1198 * <code>numTaps</code> is not a supported value.
1199 */
1200 arm_status arm_fir_init_q15(
1201 arm_fir_instance_q15 * S,
1202 uint16_t numTaps,
1203 q15_t * pCoeffs,
1204 q15_t * pState,
1205 uint32_t blockSize);
1206
1207
1208 /**
1209 * @brief Processing function for the Q31 FIR filter.
1210 * @param[in] S points to an instance of the Q31 FIR filter structure.
1211 * @param[in] pSrc points to the block of input data.
1212 * @param[out] pDst points to the block of output data.
1213 * @param[in] blockSize number of samples to process.
1214 */
1215 void arm_fir_q31(
1216 const arm_fir_instance_q31 * S,
1217 q31_t * pSrc,
1218 q31_t * pDst,
1219 uint32_t blockSize);
1220
1221
1222 /**
1223 * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
1224 * @param[in] S points to an instance of the Q31 FIR structure.
1225 * @param[in] pSrc points to the block of input data.
1226 * @param[out] pDst points to the block of output data.
1227 * @param[in] blockSize number of samples to process.
1228 */
1229 void arm_fir_fast_q31(
1230 const arm_fir_instance_q31 * S,
1231 q31_t * pSrc,
1232 q31_t * pDst,
1233 uint32_t blockSize);
1234
1235
1236 /**
1237 * @brief Initialization function for the Q31 FIR filter.
1238 * @param[in,out] S points to an instance of the Q31 FIR structure.
1239 * @param[in] numTaps Number of filter coefficients in the filter.
1240 * @param[in] pCoeffs points to the filter coefficients.
1241 * @param[in] pState points to the state buffer.
1242 * @param[in] blockSize number of samples that are processed at a time.
1243 */
1244 void arm_fir_init_q31(
1245 arm_fir_instance_q31 * S,
1246 uint16_t numTaps,
1247 q31_t * pCoeffs,
1248 q31_t * pState,
1249 uint32_t blockSize);
1250
1251
1252 /**
1253 * @brief Processing function for the floating-point FIR filter.
1254 * @param[in] S points to an instance of the floating-point FIR structure.
1255 * @param[in] pSrc points to the block of input data.
1256 * @param[out] pDst points to the block of output data.
1257 * @param[in] blockSize number of samples to process.
1258 */
1259 void arm_fir_f32(
1260 const arm_fir_instance_f32 * S,
1261 float32_t * pSrc,
1262 float32_t * pDst,
1263 uint32_t blockSize);
1264
1265
1266 /**
1267 * @brief Initialization function for the floating-point FIR filter.
1268 * @param[in,out] S points to an instance of the floating-point FIR filter structure.
1269 * @param[in] numTaps Number of filter coefficients in the filter.
1270 * @param[in] pCoeffs points to the filter coefficients.
1271 * @param[in] pState points to the state buffer.
1272 * @param[in] blockSize number of samples that are processed at a time.
1273 */
1274 void arm_fir_init_f32(
1275 arm_fir_instance_f32 * S,
1276 uint16_t numTaps,
1277 float32_t * pCoeffs,
1278 float32_t * pState,
1279 uint32_t blockSize);
1280
1281
1282 /**
1283 * @brief Instance structure for the Q15 Biquad cascade filter.
1284 */
1285 typedef struct
1286 {
1287 int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1288 q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1289 q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1290 int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
1291 } arm_biquad_casd_df1_inst_q15;
1292
1293 /**
1294 * @brief Instance structure for the Q31 Biquad cascade filter.
1295 */
1296 typedef struct
1297 {
1298 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1299 q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1300 q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1301 uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
1302 } arm_biquad_casd_df1_inst_q31;
1303
1304 /**
1305 * @brief Instance structure for the floating-point Biquad cascade filter.
1306 */
1307 typedef struct
1308 {
1309 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
1310 float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
1311 float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
1312 } arm_biquad_casd_df1_inst_f32;
1313
1314
1315 /**
1316 * @brief Processing function for the Q15 Biquad cascade filter.
1317 * @param[in] S points to an instance of the Q15 Biquad cascade structure.
1318 * @param[in] pSrc points to the block of input data.
1319 * @param[out] pDst points to the block of output data.
1320 * @param[in] blockSize number of samples to process.
1321 */
1322 void arm_biquad_cascade_df1_q15(
1323 const arm_biquad_casd_df1_inst_q15 * S,
1324 q15_t * pSrc,
1325 q15_t * pDst,
1326 uint32_t blockSize);
1327
1328
1329 /**
1330 * @brief Initialization function for the Q15 Biquad cascade filter.
1331 * @param[in,out] S points to an instance of the Q15 Biquad cascade structure.
1332 * @param[in] numStages number of 2nd order stages in the filter.
1333 * @param[in] pCoeffs points to the filter coefficients.
1334 * @param[in] pState points to the state buffer.
1335 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1336 */
1337 void arm_biquad_cascade_df1_init_q15(
1338 arm_biquad_casd_df1_inst_q15 * S,
1339 uint8_t numStages,
1340 q15_t * pCoeffs,
1341 q15_t * pState,
1342 int8_t postShift);
1343
1344
1345 /**
1346 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1347 * @param[in] S points to an instance of the Q15 Biquad cascade structure.
1348 * @param[in] pSrc points to the block of input data.
1349 * @param[out] pDst points to the block of output data.
1350 * @param[in] blockSize number of samples to process.
1351 */
1352 void arm_biquad_cascade_df1_fast_q15(
1353 const arm_biquad_casd_df1_inst_q15 * S,
1354 q15_t * pSrc,
1355 q15_t * pDst,
1356 uint32_t blockSize);
1357
1358
1359 /**
1360 * @brief Processing function for the Q31 Biquad cascade filter
1361 * @param[in] S points to an instance of the Q31 Biquad cascade structure.
1362 * @param[in] pSrc points to the block of input data.
1363 * @param[out] pDst points to the block of output data.
1364 * @param[in] blockSize number of samples to process.
1365 */
1366 void arm_biquad_cascade_df1_q31(
1367 const arm_biquad_casd_df1_inst_q31 * S,
1368 q31_t * pSrc,
1369 q31_t * pDst,
1370 uint32_t blockSize);
1371
1372
1373 /**
1374 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
1375 * @param[in] S points to an instance of the Q31 Biquad cascade structure.
1376 * @param[in] pSrc points to the block of input data.
1377 * @param[out] pDst points to the block of output data.
1378 * @param[in] blockSize number of samples to process.
1379 */
1380 void arm_biquad_cascade_df1_fast_q31(
1381 const arm_biquad_casd_df1_inst_q31 * S,
1382 q31_t * pSrc,
1383 q31_t * pDst,
1384 uint32_t blockSize);
1385
1386
1387 /**
1388 * @brief Initialization function for the Q31 Biquad cascade filter.
1389 * @param[in,out] S points to an instance of the Q31 Biquad cascade structure.
1390 * @param[in] numStages number of 2nd order stages in the filter.
1391 * @param[in] pCoeffs points to the filter coefficients.
1392 * @param[in] pState points to the state buffer.
1393 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
1394 */
1395 void arm_biquad_cascade_df1_init_q31(
1396 arm_biquad_casd_df1_inst_q31 * S,
1397 uint8_t numStages,
1398 q31_t * pCoeffs,
1399 q31_t * pState,
1400 int8_t postShift);
1401
1402
1403 /**
1404 * @brief Processing function for the floating-point Biquad cascade filter.
1405 * @param[in] S points to an instance of the floating-point Biquad cascade structure.
1406 * @param[in] pSrc points to the block of input data.
1407 * @param[out] pDst points to the block of output data.
1408 * @param[in] blockSize number of samples to process.
1409 */
1410 void arm_biquad_cascade_df1_f32(
1411 const arm_biquad_casd_df1_inst_f32 * S,
1412 float32_t * pSrc,
1413 float32_t * pDst,
1414 uint32_t blockSize);
1415
1416
1417 /**
1418 * @brief Initialization function for the floating-point Biquad cascade filter.
1419 * @param[in,out] S points to an instance of the floating-point Biquad cascade structure.
1420 * @param[in] numStages number of 2nd order stages in the filter.
1421 * @param[in] pCoeffs points to the filter coefficients.
1422 * @param[in] pState points to the state buffer.
1423 */
1424 void arm_biquad_cascade_df1_init_f32(
1425 arm_biquad_casd_df1_inst_f32 * S,
1426 uint8_t numStages,
1427 float32_t * pCoeffs,
1428 float32_t * pState);
1429
1430
1431 /**
1432 * @brief Instance structure for the floating-point matrix structure.
1433 */
1434 typedef struct
1435 {
1436 uint16_t numRows; /**< number of rows of the matrix. */
1437 uint16_t numCols; /**< number of columns of the matrix. */
1438 float32_t *pData; /**< points to the data of the matrix. */
1439 } arm_matrix_instance_f32;
1440
1441
1442 /**
1443 * @brief Instance structure for the floating-point matrix structure.
1444 */
1445 typedef struct
1446 {
1447 uint16_t numRows; /**< number of rows of the matrix. */
1448 uint16_t numCols; /**< number of columns of the matrix. */
1449 float64_t *pData; /**< points to the data of the matrix. */
1450 } arm_matrix_instance_f64;
1451
1452 /**
1453 * @brief Instance structure for the Q15 matrix structure.
1454 */
1455 typedef struct
1456 {
1457 uint16_t numRows; /**< number of rows of the matrix. */
1458 uint16_t numCols; /**< number of columns of the matrix. */
1459 q15_t *pData; /**< points to the data of the matrix. */
1460 } arm_matrix_instance_q15;
1461
1462 /**
1463 * @brief Instance structure for the Q31 matrix structure.
1464 */
1465 typedef struct
1466 {
1467 uint16_t numRows; /**< number of rows of the matrix. */
1468 uint16_t numCols; /**< number of columns of the matrix. */
1469 q31_t *pData; /**< points to the data of the matrix. */
1470 } arm_matrix_instance_q31;
1471
1472
1473 /**
1474 * @brief Floating-point matrix addition.
1475 * @param[in] pSrcA points to the first input matrix structure
1476 * @param[in] pSrcB points to the second input matrix structure
1477 * @param[out] pDst points to output matrix structure
1478 * @return The function returns either
1479 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1480 */
1481 arm_status arm_mat_add_f32(
1482 const arm_matrix_instance_f32 * pSrcA,
1483 const arm_matrix_instance_f32 * pSrcB,
1484 arm_matrix_instance_f32 * pDst);
1485
1486
1487 /**
1488 * @brief Q15 matrix addition.
1489 * @param[in] pSrcA points to the first input matrix structure
1490 * @param[in] pSrcB points to the second input matrix structure
1491 * @param[out] pDst points to output matrix structure
1492 * @return The function returns either
1493 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1494 */
1495 arm_status arm_mat_add_q15(
1496 const arm_matrix_instance_q15 * pSrcA,
1497 const arm_matrix_instance_q15 * pSrcB,
1498 arm_matrix_instance_q15 * pDst);
1499
1500
1501 /**
1502 * @brief Q31 matrix addition.
1503 * @param[in] pSrcA points to the first input matrix structure
1504 * @param[in] pSrcB points to the second input matrix structure
1505 * @param[out] pDst points to output matrix structure
1506 * @return The function returns either
1507 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1508 */
1509 arm_status arm_mat_add_q31(
1510 const arm_matrix_instance_q31 * pSrcA,
1511 const arm_matrix_instance_q31 * pSrcB,
1512 arm_matrix_instance_q31 * pDst);
1513
1514
1515 /**
1516 * @brief Floating-point, complex, matrix multiplication.
1517 * @param[in] pSrcA points to the first input matrix structure
1518 * @param[in] pSrcB points to the second input matrix structure
1519 * @param[out] pDst points to output matrix structure
1520 * @return The function returns either
1521 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1522 */
1523 arm_status arm_mat_cmplx_mult_f32(
1524 const arm_matrix_instance_f32 * pSrcA,
1525 const arm_matrix_instance_f32 * pSrcB,
1526 arm_matrix_instance_f32 * pDst);
1527
1528
1529 /**
1530 * @brief Q15, complex, matrix multiplication.
1531 * @param[in] pSrcA points to the first input matrix structure
1532 * @param[in] pSrcB points to the second input matrix structure
1533 * @param[out] pDst points to output matrix structure
1534 * @return The function returns either
1535 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1536 */
1537 arm_status arm_mat_cmplx_mult_q15(
1538 const arm_matrix_instance_q15 * pSrcA,
1539 const arm_matrix_instance_q15 * pSrcB,
1540 arm_matrix_instance_q15 * pDst,
1541 q15_t * pScratch);
1542
1543
1544 /**
1545 * @brief Q31, complex, matrix multiplication.
1546 * @param[in] pSrcA points to the first input matrix structure
1547 * @param[in] pSrcB points to the second input matrix structure
1548 * @param[out] pDst points to output matrix structure
1549 * @return The function returns either
1550 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1551 */
1552 arm_status arm_mat_cmplx_mult_q31(
1553 const arm_matrix_instance_q31 * pSrcA,
1554 const arm_matrix_instance_q31 * pSrcB,
1555 arm_matrix_instance_q31 * pDst);
1556
1557
1558 /**
1559 * @brief Floating-point matrix transpose.
1560 * @param[in] pSrc points to the input matrix
1561 * @param[out] pDst points to the output matrix
1562 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1563 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1564 */
1565 arm_status arm_mat_trans_f32(
1566 const arm_matrix_instance_f32 * pSrc,
1567 arm_matrix_instance_f32 * pDst);
1568
1569
1570 /**
1571 * @brief Q15 matrix transpose.
1572 * @param[in] pSrc points to the input matrix
1573 * @param[out] pDst points to the output matrix
1574 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1575 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1576 */
1577 arm_status arm_mat_trans_q15(
1578 const arm_matrix_instance_q15 * pSrc,
1579 arm_matrix_instance_q15 * pDst);
1580
1581
1582 /**
1583 * @brief Q31 matrix transpose.
1584 * @param[in] pSrc points to the input matrix
1585 * @param[out] pDst points to the output matrix
1586 * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
1587 * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1588 */
1589 arm_status arm_mat_trans_q31(
1590 const arm_matrix_instance_q31 * pSrc,
1591 arm_matrix_instance_q31 * pDst);
1592
1593
1594 /**
1595 * @brief Floating-point matrix multiplication
1596 * @param[in] pSrcA points to the first input matrix structure
1597 * @param[in] pSrcB points to the second input matrix structure
1598 * @param[out] pDst points to output matrix structure
1599 * @return The function returns either
1600 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1601 */
1602 arm_status arm_mat_mult_f32(
1603 const arm_matrix_instance_f32 * pSrcA,
1604 const arm_matrix_instance_f32 * pSrcB,
1605 arm_matrix_instance_f32 * pDst);
1606
1607
1608 /**
1609 * @brief Q15 matrix multiplication
1610 * @param[in] pSrcA points to the first input matrix structure
1611 * @param[in] pSrcB points to the second input matrix structure
1612 * @param[out] pDst points to output matrix structure
1613 * @param[in] pState points to the array for storing intermediate results
1614 * @return The function returns either
1615 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1616 */
1617 arm_status arm_mat_mult_q15(
1618 const arm_matrix_instance_q15 * pSrcA,
1619 const arm_matrix_instance_q15 * pSrcB,
1620 arm_matrix_instance_q15 * pDst,
1621 q15_t * pState);
1622
1623
1624 /**
1625 * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1626 * @param[in] pSrcA points to the first input matrix structure
1627 * @param[in] pSrcB points to the second input matrix structure
1628 * @param[out] pDst points to output matrix structure
1629 * @param[in] pState points to the array for storing intermediate results
1630 * @return The function returns either
1631 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1632 */
1633 arm_status arm_mat_mult_fast_q15(
1634 const arm_matrix_instance_q15 * pSrcA,
1635 const arm_matrix_instance_q15 * pSrcB,
1636 arm_matrix_instance_q15 * pDst,
1637 q15_t * pState);
1638
1639
1640 /**
1641 * @brief Q31 matrix multiplication
1642 * @param[in] pSrcA points to the first input matrix structure
1643 * @param[in] pSrcB points to the second input matrix structure
1644 * @param[out] pDst points to output matrix structure
1645 * @return The function returns either
1646 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1647 */
1648 arm_status arm_mat_mult_q31(
1649 const arm_matrix_instance_q31 * pSrcA,
1650 const arm_matrix_instance_q31 * pSrcB,
1651 arm_matrix_instance_q31 * pDst);
1652
1653
1654 /**
1655 * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
1656 * @param[in] pSrcA points to the first input matrix structure
1657 * @param[in] pSrcB points to the second input matrix structure
1658 * @param[out] pDst points to output matrix structure
1659 * @return The function returns either
1660 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1661 */
1662 arm_status arm_mat_mult_fast_q31(
1663 const arm_matrix_instance_q31 * pSrcA,
1664 const arm_matrix_instance_q31 * pSrcB,
1665 arm_matrix_instance_q31 * pDst);
1666
1667
1668 /**
1669 * @brief Floating-point matrix subtraction
1670 * @param[in] pSrcA points to the first input matrix structure
1671 * @param[in] pSrcB points to the second input matrix structure
1672 * @param[out] pDst points to output matrix structure
1673 * @return The function returns either
1674 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1675 */
1676 arm_status arm_mat_sub_f32(
1677 const arm_matrix_instance_f32 * pSrcA,
1678 const arm_matrix_instance_f32 * pSrcB,
1679 arm_matrix_instance_f32 * pDst);
1680
1681
1682 /**
1683 * @brief Q15 matrix subtraction
1684 * @param[in] pSrcA points to the first input matrix structure
1685 * @param[in] pSrcB points to the second input matrix structure
1686 * @param[out] pDst points to output matrix structure
1687 * @return The function returns either
1688 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1689 */
1690 arm_status arm_mat_sub_q15(
1691 const arm_matrix_instance_q15 * pSrcA,
1692 const arm_matrix_instance_q15 * pSrcB,
1693 arm_matrix_instance_q15 * pDst);
1694
1695
1696 /**
1697 * @brief Q31 matrix subtraction
1698 * @param[in] pSrcA points to the first input matrix structure
1699 * @param[in] pSrcB points to the second input matrix structure
1700 * @param[out] pDst points to output matrix structure
1701 * @return The function returns either
1702 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1703 */
1704 arm_status arm_mat_sub_q31(
1705 const arm_matrix_instance_q31 * pSrcA,
1706 const arm_matrix_instance_q31 * pSrcB,
1707 arm_matrix_instance_q31 * pDst);
1708
1709
1710 /**
1711 * @brief Floating-point matrix scaling.
1712 * @param[in] pSrc points to the input matrix
1713 * @param[in] scale scale factor
1714 * @param[out] pDst points to the output matrix
1715 * @return The function returns either
1716 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1717 */
1718 arm_status arm_mat_scale_f32(
1719 const arm_matrix_instance_f32 * pSrc,
1720 float32_t scale,
1721 arm_matrix_instance_f32 * pDst);
1722
1723
1724 /**
1725 * @brief Q15 matrix scaling.
1726 * @param[in] pSrc points to input matrix
1727 * @param[in] scaleFract fractional portion of the scale factor
1728 * @param[in] shift number of bits to shift the result by
1729 * @param[out] pDst points to output matrix
1730 * @return The function returns either
1731 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1732 */
1733 arm_status arm_mat_scale_q15(
1734 const arm_matrix_instance_q15 * pSrc,
1735 q15_t scaleFract,
1736 int32_t shift,
1737 arm_matrix_instance_q15 * pDst);
1738
1739
1740 /**
1741 * @brief Q31 matrix scaling.
1742 * @param[in] pSrc points to input matrix
1743 * @param[in] scaleFract fractional portion of the scale factor
1744 * @param[in] shift number of bits to shift the result by
1745 * @param[out] pDst points to output matrix structure
1746 * @return The function returns either
1747 * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
1748 */
1749 arm_status arm_mat_scale_q31(
1750 const arm_matrix_instance_q31 * pSrc,
1751 q31_t scaleFract,
1752 int32_t shift,
1753 arm_matrix_instance_q31 * pDst);
1754
1755
1756 /**
1757 * @brief Q31 matrix initialization.
1758 * @param[in,out] S points to an instance of the floating-point matrix structure.
1759 * @param[in] nRows number of rows in the matrix.
1760 * @param[in] nColumns number of columns in the matrix.
1761 * @param[in] pData points to the matrix data array.
1762 */
1763 void arm_mat_init_q31(
1764 arm_matrix_instance_q31 * S,
1765 uint16_t nRows,
1766 uint16_t nColumns,
1767 q31_t * pData);
1768
1769
1770 /**
1771 * @brief Q15 matrix initialization.
1772 * @param[in,out] S points to an instance of the floating-point matrix structure.
1773 * @param[in] nRows number of rows in the matrix.
1774 * @param[in] nColumns number of columns in the matrix.
1775 * @param[in] pData points to the matrix data array.
1776 */
1777 void arm_mat_init_q15(
1778 arm_matrix_instance_q15 * S,
1779 uint16_t nRows,
1780 uint16_t nColumns,
1781 q15_t * pData);
1782
1783
1784 /**
1785 * @brief Floating-point matrix initialization.
1786 * @param[in,out] S points to an instance of the floating-point matrix structure.
1787 * @param[in] nRows number of rows in the matrix.
1788 * @param[in] nColumns number of columns in the matrix.
1789 * @param[in] pData points to the matrix data array.
1790 */
1791 void arm_mat_init_f32(
1792 arm_matrix_instance_f32 * S,
1793 uint16_t nRows,
1794 uint16_t nColumns,
1795 float32_t * pData);
1796
1797
1798
1799 /**
1800 * @brief Instance structure for the Q15 PID Control.
1801 */
1802 typedef struct
1803 {
1804 q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1805#if !defined (ARM_MATH_DSP)
1806 q15_t A1;
1807 q15_t A2;
1808#else
1809 q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
1810#endif
1811 q15_t state[3]; /**< The state array of length 3. */
1812 q15_t Kp; /**< The proportional gain. */
1813 q15_t Ki; /**< The integral gain. */
1814 q15_t Kd; /**< The derivative gain. */
1815 } arm_pid_instance_q15;
1816
1817 /**
1818 * @brief Instance structure for the Q31 PID Control.
1819 */
1820 typedef struct
1821 {
1822 q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1823 q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
1824 q31_t A2; /**< The derived gain, A2 = Kd . */
1825 q31_t state[3]; /**< The state array of length 3. */
1826 q31_t Kp; /**< The proportional gain. */
1827 q31_t Ki; /**< The integral gain. */
1828 q31_t Kd; /**< The derivative gain. */
1829 } arm_pid_instance_q31;
1830
1831 /**
1832 * @brief Instance structure for the floating-point PID Control.
1833 */
1834 typedef struct
1835 {
1836 float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
1837 float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
1838 float32_t A2; /**< The derived gain, A2 = Kd . */
1839 float32_t state[3]; /**< The state array of length 3. */
1840 float32_t Kp; /**< The proportional gain. */
1841 float32_t Ki; /**< The integral gain. */
1842 float32_t Kd; /**< The derivative gain. */
1843 } arm_pid_instance_f32;
1844
1845
1846
1847 /**
1848 * @brief Initialization function for the floating-point PID Control.
1849 * @param[in,out] S points to an instance of the PID structure.
1850 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1851 */
1852 void arm_pid_init_f32(
1853 arm_pid_instance_f32 * S,
1854 int32_t resetStateFlag);
1855
1856
1857 /**
1858 * @brief Reset function for the floating-point PID Control.
1859 * @param[in,out] S is an instance of the floating-point PID Control structure
1860 */
1861 void arm_pid_reset_f32(
1862 arm_pid_instance_f32 * S);
1863
1864
1865 /**
1866 * @brief Initialization function for the Q31 PID Control.
1867 * @param[in,out] S points to an instance of the Q15 PID structure.
1868 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1869 */
1870 void arm_pid_init_q31(
1871 arm_pid_instance_q31 * S,
1872 int32_t resetStateFlag);
1873
1874
1875 /**
1876 * @brief Reset function for the Q31 PID Control.
1877 * @param[in,out] S points to an instance of the Q31 PID Control structure
1878 */
1879
1880 void arm_pid_reset_q31(
1881 arm_pid_instance_q31 * S);
1882
1883
1884 /**
1885 * @brief Initialization function for the Q15 PID Control.
1886 * @param[in,out] S points to an instance of the Q15 PID structure.
1887 * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
1888 */
1889 void arm_pid_init_q15(
1890 arm_pid_instance_q15 * S,
1891 int32_t resetStateFlag);
1892
1893
1894 /**
1895 * @brief Reset function for the Q15 PID Control.
1896 * @param[in,out] S points to an instance of the q15 PID Control structure
1897 */
1898 void arm_pid_reset_q15(
1899 arm_pid_instance_q15 * S);
1900
1901
1902 /**
1903 * @brief Instance structure for the floating-point Linear Interpolate function.
1904 */
1905 typedef struct
1906 {
1907 uint32_t nValues; /**< nValues */
1908 float32_t x1; /**< x1 */
1909 float32_t xSpacing; /**< xSpacing */
1910 float32_t *pYData; /**< pointer to the table of Y values */
1911 } arm_linear_interp_instance_f32;
1912
1913 /**
1914 * @brief Instance structure for the floating-point bilinear interpolation function.
1915 */
1916 typedef struct
1917 {
1918 uint16_t numRows; /**< number of rows in the data table. */
1919 uint16_t numCols; /**< number of columns in the data table. */
1920 float32_t *pData; /**< points to the data table. */
1921 } arm_bilinear_interp_instance_f32;
1922
1923 /**
1924 * @brief Instance structure for the Q31 bilinear interpolation function.
1925 */
1926 typedef struct
1927 {
1928 uint16_t numRows; /**< number of rows in the data table. */
1929 uint16_t numCols; /**< number of columns in the data table. */
1930 q31_t *pData; /**< points to the data table. */
1931 } arm_bilinear_interp_instance_q31;
1932
1933 /**
1934 * @brief Instance structure for the Q15 bilinear interpolation function.
1935 */
1936 typedef struct
1937 {
1938 uint16_t numRows; /**< number of rows in the data table. */
1939 uint16_t numCols; /**< number of columns in the data table. */
1940 q15_t *pData; /**< points to the data table. */
1941 } arm_bilinear_interp_instance_q15;
1942
1943 /**
1944 * @brief Instance structure for the Q15 bilinear interpolation function.
1945 */
1946 typedef struct
1947 {
1948 uint16_t numRows; /**< number of rows in the data table. */
1949 uint16_t numCols; /**< number of columns in the data table. */
1950 q7_t *pData; /**< points to the data table. */
1951 } arm_bilinear_interp_instance_q7;
1952
1953
1954 /**
1955 * @brief Q7 vector multiplication.
1956 * @param[in] pSrcA points to the first input vector
1957 * @param[in] pSrcB points to the second input vector
1958 * @param[out] pDst points to the output vector
1959 * @param[in] blockSize number of samples in each vector
1960 */
1961 void arm_mult_q7(
1962 q7_t * pSrcA,
1963 q7_t * pSrcB,
1964 q7_t * pDst,
1965 uint32_t blockSize);
1966
1967
1968 /**
1969 * @brief Q15 vector multiplication.
1970 * @param[in] pSrcA points to the first input vector
1971 * @param[in] pSrcB points to the second input vector
1972 * @param[out] pDst points to the output vector
1973 * @param[in] blockSize number of samples in each vector
1974 */
1975 void arm_mult_q15(
1976 q15_t * pSrcA,
1977 q15_t * pSrcB,
1978 q15_t * pDst,
1979 uint32_t blockSize);
1980
1981
1982 /**
1983 * @brief Q31 vector multiplication.
1984 * @param[in] pSrcA points to the first input vector
1985 * @param[in] pSrcB points to the second input vector
1986 * @param[out] pDst points to the output vector
1987 * @param[in] blockSize number of samples in each vector
1988 */
1989 void arm_mult_q31(
1990 q31_t * pSrcA,
1991 q31_t * pSrcB,
1992 q31_t * pDst,
1993 uint32_t blockSize);
1994
1995
1996 /**
1997 * @brief Floating-point vector multiplication.
1998 * @param[in] pSrcA points to the first input vector
1999 * @param[in] pSrcB points to the second input vector
2000 * @param[out] pDst points to the output vector
2001 * @param[in] blockSize number of samples in each vector
2002 */
2003 void arm_mult_f32(
2004 float32_t * pSrcA,
2005 float32_t * pSrcB,
2006 float32_t * pDst,
2007 uint32_t blockSize);
2008
2009
2010 /**
2011 * @brief Instance structure for the Q15 CFFT/CIFFT function.
2012 */
2013 typedef struct
2014 {
2015 uint16_t fftLen; /**< length of the FFT. */
2016 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2017 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2018 q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
2019 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2020 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2021 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2022 } arm_cfft_radix2_instance_q15;
2023
2024/* Deprecated */
2025 arm_status arm_cfft_radix2_init_q15(
2026 arm_cfft_radix2_instance_q15 * S,
2027 uint16_t fftLen,
2028 uint8_t ifftFlag,
2029 uint8_t bitReverseFlag);
2030
2031/* Deprecated */
2032 void arm_cfft_radix2_q15(
2033 const arm_cfft_radix2_instance_q15 * S,
2034 q15_t * pSrc);
2035
2036
2037 /**
2038 * @brief Instance structure for the Q15 CFFT/CIFFT function.
2039 */
2040 typedef struct
2041 {
2042 uint16_t fftLen; /**< length of the FFT. */
2043 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2044 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2045 q15_t *pTwiddle; /**< points to the twiddle factor table. */
2046 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2047 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2048 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2049 } arm_cfft_radix4_instance_q15;
2050
2051/* Deprecated */
2052 arm_status arm_cfft_radix4_init_q15(
2053 arm_cfft_radix4_instance_q15 * S,
2054 uint16_t fftLen,
2055 uint8_t ifftFlag,
2056 uint8_t bitReverseFlag);
2057
2058/* Deprecated */
2059 void arm_cfft_radix4_q15(
2060 const arm_cfft_radix4_instance_q15 * S,
2061 q15_t * pSrc);
2062
2063 /**
2064 * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
2065 */
2066 typedef struct
2067 {
2068 uint16_t fftLen; /**< length of the FFT. */
2069 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2070 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2071 q31_t *pTwiddle; /**< points to the Twiddle factor table. */
2072 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2073 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2074 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2075 } arm_cfft_radix2_instance_q31;
2076
2077/* Deprecated */
2078 arm_status arm_cfft_radix2_init_q31(
2079 arm_cfft_radix2_instance_q31 * S,
2080 uint16_t fftLen,
2081 uint8_t ifftFlag,
2082 uint8_t bitReverseFlag);
2083
2084/* Deprecated */
2085 void arm_cfft_radix2_q31(
2086 const arm_cfft_radix2_instance_q31 * S,
2087 q31_t * pSrc);
2088
2089 /**
2090 * @brief Instance structure for the Q31 CFFT/CIFFT function.
2091 */
2092 typedef struct
2093 {
2094 uint16_t fftLen; /**< length of the FFT. */
2095 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2096 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2097 q31_t *pTwiddle; /**< points to the twiddle factor table. */
2098 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2099 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2100 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2101 } arm_cfft_radix4_instance_q31;
2102
2103/* Deprecated */
2104 void arm_cfft_radix4_q31(
2105 const arm_cfft_radix4_instance_q31 * S,
2106 q31_t * pSrc);
2107
2108/* Deprecated */
2109 arm_status arm_cfft_radix4_init_q31(
2110 arm_cfft_radix4_instance_q31 * S,
2111 uint16_t fftLen,
2112 uint8_t ifftFlag,
2113 uint8_t bitReverseFlag);
2114
2115 /**
2116 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2117 */
2118 typedef struct
2119 {
2120 uint16_t fftLen; /**< length of the FFT. */
2121 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2122 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2123 float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2124 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2125 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2126 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2127 float32_t onebyfftLen; /**< value of 1/fftLen. */
2128 } arm_cfft_radix2_instance_f32;
2129
2130/* Deprecated */
2131 arm_status arm_cfft_radix2_init_f32(
2132 arm_cfft_radix2_instance_f32 * S,
2133 uint16_t fftLen,
2134 uint8_t ifftFlag,
2135 uint8_t bitReverseFlag);
2136
2137/* Deprecated */
2138 void arm_cfft_radix2_f32(
2139 const arm_cfft_radix2_instance_f32 * S,
2140 float32_t * pSrc);
2141
2142 /**
2143 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2144 */
2145 typedef struct
2146 {
2147 uint16_t fftLen; /**< length of the FFT. */
2148 uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
2149 uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
2150 float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2151 uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2152 uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2153 uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
2154 float32_t onebyfftLen; /**< value of 1/fftLen. */
2155 } arm_cfft_radix4_instance_f32;
2156
2157/* Deprecated */
2158 arm_status arm_cfft_radix4_init_f32(
2159 arm_cfft_radix4_instance_f32 * S,
2160 uint16_t fftLen,
2161 uint8_t ifftFlag,
2162 uint8_t bitReverseFlag);
2163
2164/* Deprecated */
2165 void arm_cfft_radix4_f32(
2166 const arm_cfft_radix4_instance_f32 * S,
2167 float32_t * pSrc);
2168
2169 /**
2170 * @brief Instance structure for the fixed-point CFFT/CIFFT function.
2171 */
2172 typedef struct
2173 {
2174 uint16_t fftLen; /**< length of the FFT. */
2175 const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
2176 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2177 uint16_t bitRevLength; /**< bit reversal table length. */
2178 } arm_cfft_instance_q15;
2179
2180void arm_cfft_q15(
2181 const arm_cfft_instance_q15 * S,
2182 q15_t * p1,
2183 uint8_t ifftFlag,
2184 uint8_t bitReverseFlag);
2185
2186 /**
2187 * @brief Instance structure for the fixed-point CFFT/CIFFT function.
2188 */
2189 typedef struct
2190 {
2191 uint16_t fftLen; /**< length of the FFT. */
2192 const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
2193 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2194 uint16_t bitRevLength; /**< bit reversal table length. */
2195 } arm_cfft_instance_q31;
2196
2197void arm_cfft_q31(
2198 const arm_cfft_instance_q31 * S,
2199 q31_t * p1,
2200 uint8_t ifftFlag,
2201 uint8_t bitReverseFlag);
2202
2203 /**
2204 * @brief Instance structure for the floating-point CFFT/CIFFT function.
2205 */
2206 typedef struct
2207 {
2208 uint16_t fftLen; /**< length of the FFT. */
2209 const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
2210 const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
2211 uint16_t bitRevLength; /**< bit reversal table length. */
2212 } arm_cfft_instance_f32;
2213
2214 void arm_cfft_f32(
2215 const arm_cfft_instance_f32 * S,
2216 float32_t * p1,
2217 uint8_t ifftFlag,
2218 uint8_t bitReverseFlag);
2219
2220 /**
2221 * @brief Instance structure for the Q15 RFFT/RIFFT function.
2222 */
2223 typedef struct
2224 {
2225 uint32_t fftLenReal; /**< length of the real FFT. */
2226 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2227 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2228 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2229 q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2230 q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2231 const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
2232 } arm_rfft_instance_q15;
2233
2234 arm_status arm_rfft_init_q15(
2235 arm_rfft_instance_q15 * S,
2236 uint32_t fftLenReal,
2237 uint32_t ifftFlagR,
2238 uint32_t bitReverseFlag);
2239
2240 void arm_rfft_q15(
2241 const arm_rfft_instance_q15 * S,
2242 q15_t * pSrc,
2243 q15_t * pDst);
2244
2245 /**
2246 * @brief Instance structure for the Q31 RFFT/RIFFT function.
2247 */
2248 typedef struct
2249 {
2250 uint32_t fftLenReal; /**< length of the real FFT. */
2251 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2252 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2253 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2254 q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2255 q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2256 const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
2257 } arm_rfft_instance_q31;
2258
2259 arm_status arm_rfft_init_q31(
2260 arm_rfft_instance_q31 * S,
2261 uint32_t fftLenReal,
2262 uint32_t ifftFlagR,
2263 uint32_t bitReverseFlag);
2264
2265 void arm_rfft_q31(
2266 const arm_rfft_instance_q31 * S,
2267 q31_t * pSrc,
2268 q31_t * pDst);
2269
2270 /**
2271 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2272 */
2273 typedef struct
2274 {
2275 uint32_t fftLenReal; /**< length of the real FFT. */
2276 uint16_t fftLenBy2; /**< length of the complex FFT. */
2277 uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
2278 uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
2279 uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
2280 float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
2281 float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
2282 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
2283 } arm_rfft_instance_f32;
2284
2285 arm_status arm_rfft_init_f32(
2286 arm_rfft_instance_f32 * S,
2287 arm_cfft_radix4_instance_f32 * S_CFFT,
2288 uint32_t fftLenReal,
2289 uint32_t ifftFlagR,
2290 uint32_t bitReverseFlag);
2291
2292 void arm_rfft_f32(
2293 const arm_rfft_instance_f32 * S,
2294 float32_t * pSrc,
2295 float32_t * pDst);
2296
2297 /**
2298 * @brief Instance structure for the floating-point RFFT/RIFFT function.
2299 */
2300typedef struct
2301 {
2302 arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
2303 uint16_t fftLenRFFT; /**< length of the real sequence */
2304 float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
2305 } arm_rfft_fast_instance_f32 ;
2306
2307arm_status arm_rfft_fast_init_f32 (
2308 arm_rfft_fast_instance_f32 * S,
2309 uint16_t fftLen);
2310
2311void arm_rfft_fast_f32(
2312 arm_rfft_fast_instance_f32 * S,
2313 float32_t * p, float32_t * pOut,
2314 uint8_t ifftFlag);
2315
2316 /**
2317 * @brief Instance structure for the floating-point DCT4/IDCT4 function.
2318 */
2319 typedef struct
2320 {
2321 uint16_t N; /**< length of the DCT4. */
2322 uint16_t Nby2; /**< half of the length of the DCT4. */
2323 float32_t normalize; /**< normalizing factor. */
2324 float32_t *pTwiddle; /**< points to the twiddle factor table. */
2325 float32_t *pCosFactor; /**< points to the cosFactor table. */
2326 arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
2327 arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
2328 } arm_dct4_instance_f32;
2329
2330
2331 /**
2332 * @brief Initialization function for the floating-point DCT4/IDCT4.
2333 * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
2334 * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
2335 * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
2336 * @param[in] N length of the DCT4.
2337 * @param[in] Nby2 half of the length of the DCT4.
2338 * @param[in] normalize normalizing factor.
2339 * @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.
2340 */
2341 arm_status arm_dct4_init_f32(
2342 arm_dct4_instance_f32 * S,
2343 arm_rfft_instance_f32 * S_RFFT,
2344 arm_cfft_radix4_instance_f32 * S_CFFT,
2345 uint16_t N,
2346 uint16_t Nby2,
2347 float32_t normalize);
2348
2349
2350 /**
2351 * @brief Processing function for the floating-point DCT4/IDCT4.
2352 * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
2353 * @param[in] pState points to state buffer.
2354 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2355 */
2356 void arm_dct4_f32(
2357 const arm_dct4_instance_f32 * S,
2358 float32_t * pState,
2359 float32_t * pInlineBuffer);
2360
2361
2362 /**
2363 * @brief Instance structure for the Q31 DCT4/IDCT4 function.
2364 */
2365 typedef struct
2366 {
2367 uint16_t N; /**< length of the DCT4. */
2368 uint16_t Nby2; /**< half of the length of the DCT4. */
2369 q31_t normalize; /**< normalizing factor. */
2370 q31_t *pTwiddle; /**< points to the twiddle factor table. */
2371 q31_t *pCosFactor; /**< points to the cosFactor table. */
2372 arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
2373 arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
2374 } arm_dct4_instance_q31;
2375
2376
2377 /**
2378 * @brief Initialization function for the Q31 DCT4/IDCT4.
2379 * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
2380 * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
2381 * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
2382 * @param[in] N length of the DCT4.
2383 * @param[in] Nby2 half of the length of the DCT4.
2384 * @param[in] normalize normalizing factor.
2385 * @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.
2386 */
2387 arm_status arm_dct4_init_q31(
2388 arm_dct4_instance_q31 * S,
2389 arm_rfft_instance_q31 * S_RFFT,
2390 arm_cfft_radix4_instance_q31 * S_CFFT,
2391 uint16_t N,
2392 uint16_t Nby2,
2393 q31_t normalize);
2394
2395
2396 /**
2397 * @brief Processing function for the Q31 DCT4/IDCT4.
2398 * @param[in] S points to an instance of the Q31 DCT4 structure.
2399 * @param[in] pState points to state buffer.
2400 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2401 */
2402 void arm_dct4_q31(
2403 const arm_dct4_instance_q31 * S,
2404 q31_t * pState,
2405 q31_t * pInlineBuffer);
2406
2407
2408 /**
2409 * @brief Instance structure for the Q15 DCT4/IDCT4 function.
2410 */
2411 typedef struct
2412 {
2413 uint16_t N; /**< length of the DCT4. */
2414 uint16_t Nby2; /**< half of the length of the DCT4. */
2415 q15_t normalize; /**< normalizing factor. */
2416 q15_t *pTwiddle; /**< points to the twiddle factor table. */
2417 q15_t *pCosFactor; /**< points to the cosFactor table. */
2418 arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
2419 arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
2420 } arm_dct4_instance_q15;
2421
2422
2423 /**
2424 * @brief Initialization function for the Q15 DCT4/IDCT4.
2425 * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
2426 * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
2427 * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
2428 * @param[in] N length of the DCT4.
2429 * @param[in] Nby2 half of the length of the DCT4.
2430 * @param[in] normalize normalizing factor.
2431 * @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.
2432 */
2433 arm_status arm_dct4_init_q15(
2434 arm_dct4_instance_q15 * S,
2435 arm_rfft_instance_q15 * S_RFFT,
2436 arm_cfft_radix4_instance_q15 * S_CFFT,
2437 uint16_t N,
2438 uint16_t Nby2,
2439 q15_t normalize);
2440
2441
2442 /**
2443 * @brief Processing function for the Q15 DCT4/IDCT4.
2444 * @param[in] S points to an instance of the Q15 DCT4 structure.
2445 * @param[in] pState points to state buffer.
2446 * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
2447 */
2448 void arm_dct4_q15(
2449 const arm_dct4_instance_q15 * S,
2450 q15_t * pState,
2451 q15_t * pInlineBuffer);
2452
2453
2454 /**
2455 * @brief Floating-point vector addition.
2456 * @param[in] pSrcA points to the first input vector
2457 * @param[in] pSrcB points to the second input vector
2458 * @param[out] pDst points to the output vector
2459 * @param[in] blockSize number of samples in each vector
2460 */
2461 void arm_add_f32(
2462 float32_t * pSrcA,
2463 float32_t * pSrcB,
2464 float32_t * pDst,
2465 uint32_t blockSize);
2466
2467
2468 /**
2469 * @brief Q7 vector addition.
2470 * @param[in] pSrcA points to the first input vector
2471 * @param[in] pSrcB points to the second input vector
2472 * @param[out] pDst points to the output vector
2473 * @param[in] blockSize number of samples in each vector
2474 */
2475 void arm_add_q7(
2476 q7_t * pSrcA,
2477 q7_t * pSrcB,
2478 q7_t * pDst,
2479 uint32_t blockSize);
2480
2481
2482 /**
2483 * @brief Q15 vector addition.
2484 * @param[in] pSrcA points to the first input vector
2485 * @param[in] pSrcB points to the second input vector
2486 * @param[out] pDst points to the output vector
2487 * @param[in] blockSize number of samples in each vector
2488 */
2489 void arm_add_q15(
2490 q15_t * pSrcA,
2491 q15_t * pSrcB,
2492 q15_t * pDst,
2493 uint32_t blockSize);
2494
2495
2496 /**
2497 * @brief Q31 vector addition.
2498 * @param[in] pSrcA points to the first input vector
2499 * @param[in] pSrcB points to the second input vector
2500 * @param[out] pDst points to the output vector
2501 * @param[in] blockSize number of samples in each vector
2502 */
2503 void arm_add_q31(
2504 q31_t * pSrcA,
2505 q31_t * pSrcB,
2506 q31_t * pDst,
2507 uint32_t blockSize);
2508
2509
2510 /**
2511 * @brief Floating-point vector subtraction.
2512 * @param[in] pSrcA points to the first input vector
2513 * @param[in] pSrcB points to the second input vector
2514 * @param[out] pDst points to the output vector
2515 * @param[in] blockSize number of samples in each vector
2516 */
2517 void arm_sub_f32(
2518 float32_t * pSrcA,
2519 float32_t * pSrcB,
2520 float32_t * pDst,
2521 uint32_t blockSize);
2522
2523
2524 /**
2525 * @brief Q7 vector subtraction.
2526 * @param[in] pSrcA points to the first input vector
2527 * @param[in] pSrcB points to the second input vector
2528 * @param[out] pDst points to the output vector
2529 * @param[in] blockSize number of samples in each vector
2530 */
2531 void arm_sub_q7(
2532 q7_t * pSrcA,
2533 q7_t * pSrcB,
2534 q7_t * pDst,
2535 uint32_t blockSize);
2536
2537
2538 /**
2539 * @brief Q15 vector subtraction.
2540 * @param[in] pSrcA points to the first input vector
2541 * @param[in] pSrcB points to the second input vector
2542 * @param[out] pDst points to the output vector
2543 * @param[in] blockSize number of samples in each vector
2544 */
2545 void arm_sub_q15(
2546 q15_t * pSrcA,
2547 q15_t * pSrcB,
2548 q15_t * pDst,
2549 uint32_t blockSize);
2550
2551
2552 /**
2553 * @brief Q31 vector subtraction.
2554 * @param[in] pSrcA points to the first input vector
2555 * @param[in] pSrcB points to the second input vector
2556 * @param[out] pDst points to the output vector
2557 * @param[in] blockSize number of samples in each vector
2558 */
2559 void arm_sub_q31(
2560 q31_t * pSrcA,
2561 q31_t * pSrcB,
2562 q31_t * pDst,
2563 uint32_t blockSize);
2564
2565
2566 /**
2567 * @brief Multiplies a floating-point vector by a scalar.
2568 * @param[in] pSrc points to the input vector
2569 * @param[in] scale scale factor to be applied
2570 * @param[out] pDst points to the output vector
2571 * @param[in] blockSize number of samples in the vector
2572 */
2573 void arm_scale_f32(
2574 float32_t * pSrc,
2575 float32_t scale,
2576 float32_t * pDst,
2577 uint32_t blockSize);
2578
2579
2580 /**
2581 * @brief Multiplies a Q7 vector by a scalar.
2582 * @param[in] pSrc points to the input vector
2583 * @param[in] scaleFract fractional portion of the scale value
2584 * @param[in] shift number of bits to shift the result by
2585 * @param[out] pDst points to the output vector
2586 * @param[in] blockSize number of samples in the vector
2587 */
2588 void arm_scale_q7(
2589 q7_t * pSrc,
2590 q7_t scaleFract,
2591 int8_t shift,
2592 q7_t * pDst,
2593 uint32_t blockSize);
2594
2595
2596 /**
2597 * @brief Multiplies a Q15 vector by a scalar.
2598 * @param[in] pSrc points to the input vector
2599 * @param[in] scaleFract fractional portion of the scale value
2600 * @param[in] shift number of bits to shift the result by
2601 * @param[out] pDst points to the output vector
2602 * @param[in] blockSize number of samples in the vector
2603 */
2604 void arm_scale_q15(
2605 q15_t * pSrc,
2606 q15_t scaleFract,
2607 int8_t shift,
2608 q15_t * pDst,
2609 uint32_t blockSize);
2610
2611
2612 /**
2613 * @brief Multiplies a Q31 vector by a scalar.
2614 * @param[in] pSrc points to the input vector
2615 * @param[in] scaleFract fractional portion of the scale value
2616 * @param[in] shift number of bits to shift the result by
2617 * @param[out] pDst points to the output vector
2618 * @param[in] blockSize number of samples in the vector
2619 */
2620 void arm_scale_q31(
2621 q31_t * pSrc,
2622 q31_t scaleFract,
2623 int8_t shift,
2624 q31_t * pDst,
2625 uint32_t blockSize);
2626
2627
2628 /**
2629 * @brief Q7 vector absolute value.
2630 * @param[in] pSrc points to the input buffer
2631 * @param[out] pDst points to the output buffer
2632 * @param[in] blockSize number of samples in each vector
2633 */
2634 void arm_abs_q7(
2635 q7_t * pSrc,
2636 q7_t * pDst,
2637 uint32_t blockSize);
2638
2639
2640 /**
2641 * @brief Floating-point vector absolute value.
2642 * @param[in] pSrc points to the input buffer
2643 * @param[out] pDst points to the output buffer
2644 * @param[in] blockSize number of samples in each vector
2645 */
2646 void arm_abs_f32(
2647 float32_t * pSrc,
2648 float32_t * pDst,
2649 uint32_t blockSize);
2650
2651
2652 /**
2653 * @brief Q15 vector absolute value.
2654 * @param[in] pSrc points to the input buffer
2655 * @param[out] pDst points to the output buffer
2656 * @param[in] blockSize number of samples in each vector
2657 */
2658 void arm_abs_q15(
2659 q15_t * pSrc,
2660 q15_t * pDst,
2661 uint32_t blockSize);
2662
2663
2664 /**
2665 * @brief Q31 vector absolute value.
2666 * @param[in] pSrc points to the input buffer
2667 * @param[out] pDst points to the output buffer
2668 * @param[in] blockSize number of samples in each vector
2669 */
2670 void arm_abs_q31(
2671 q31_t * pSrc,
2672 q31_t * pDst,
2673 uint32_t blockSize);
2674
2675
2676 /**
2677 * @brief Dot product of floating-point vectors.
2678 * @param[in] pSrcA points to the first input vector
2679 * @param[in] pSrcB points to the second input vector
2680 * @param[in] blockSize number of samples in each vector
2681 * @param[out] result output result returned here
2682 */
2683 void arm_dot_prod_f32(
2684 float32_t * pSrcA,
2685 float32_t * pSrcB,
2686 uint32_t blockSize,
2687 float32_t * result);
2688
2689
2690 /**
2691 * @brief Dot product of Q7 vectors.
2692 * @param[in] pSrcA points to the first input vector
2693 * @param[in] pSrcB points to the second input vector
2694 * @param[in] blockSize number of samples in each vector
2695 * @param[out] result output result returned here
2696 */
2697 void arm_dot_prod_q7(
2698 q7_t * pSrcA,
2699 q7_t * pSrcB,
2700 uint32_t blockSize,
2701 q31_t * result);
2702
2703
2704 /**
2705 * @brief Dot product of Q15 vectors.
2706 * @param[in] pSrcA points to the first input vector
2707 * @param[in] pSrcB points to the second input vector
2708 * @param[in] blockSize number of samples in each vector
2709 * @param[out] result output result returned here
2710 */
2711 void arm_dot_prod_q15(
2712 q15_t * pSrcA,
2713 q15_t * pSrcB,
2714 uint32_t blockSize,
2715 q63_t * result);
2716
2717
2718 /**
2719 * @brief Dot product of Q31 vectors.
2720 * @param[in] pSrcA points to the first input vector
2721 * @param[in] pSrcB points to the second input vector
2722 * @param[in] blockSize number of samples in each vector
2723 * @param[out] result output result returned here
2724 */
2725 void arm_dot_prod_q31(
2726 q31_t * pSrcA,
2727 q31_t * pSrcB,
2728 uint32_t blockSize,
2729 q63_t * result);
2730
2731
2732 /**
2733 * @brief Shifts the elements of a Q7 vector a specified number of bits.
2734 * @param[in] pSrc points to the input vector
2735 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2736 * @param[out] pDst points to the output vector
2737 * @param[in] blockSize number of samples in the vector
2738 */
2739 void arm_shift_q7(
2740 q7_t * pSrc,
2741 int8_t shiftBits,
2742 q7_t * pDst,
2743 uint32_t blockSize);
2744
2745
2746 /**
2747 * @brief Shifts the elements of a Q15 vector a specified number of bits.
2748 * @param[in] pSrc points to the input vector
2749 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2750 * @param[out] pDst points to the output vector
2751 * @param[in] blockSize number of samples in the vector
2752 */
2753 void arm_shift_q15(
2754 q15_t * pSrc,
2755 int8_t shiftBits,
2756 q15_t * pDst,
2757 uint32_t blockSize);
2758
2759
2760 /**
2761 * @brief Shifts the elements of a Q31 vector a specified number of bits.
2762 * @param[in] pSrc points to the input vector
2763 * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
2764 * @param[out] pDst points to the output vector
2765 * @param[in] blockSize number of samples in the vector
2766 */
2767 void arm_shift_q31(
2768 q31_t * pSrc,
2769 int8_t shiftBits,
2770 q31_t * pDst,
2771 uint32_t blockSize);
2772
2773
2774 /**
2775 * @brief Adds a constant offset to a floating-point vector.
2776 * @param[in] pSrc points to the input vector
2777 * @param[in] offset is the offset to be added
2778 * @param[out] pDst points to the output vector
2779 * @param[in] blockSize number of samples in the vector
2780 */
2781 void arm_offset_f32(
2782 float32_t * pSrc,
2783 float32_t offset,
2784 float32_t * pDst,
2785 uint32_t blockSize);
2786
2787
2788 /**
2789 * @brief Adds a constant offset to a Q7 vector.
2790 * @param[in] pSrc points to the input vector
2791 * @param[in] offset is the offset to be added
2792 * @param[out] pDst points to the output vector
2793 * @param[in] blockSize number of samples in the vector
2794 */
2795 void arm_offset_q7(
2796 q7_t * pSrc,
2797 q7_t offset,
2798 q7_t * pDst,
2799 uint32_t blockSize);
2800
2801
2802 /**
2803 * @brief Adds a constant offset to a Q15 vector.
2804 * @param[in] pSrc points to the input vector
2805 * @param[in] offset is the offset to be added
2806 * @param[out] pDst points to the output vector
2807 * @param[in] blockSize number of samples in the vector
2808 */
2809 void arm_offset_q15(
2810 q15_t * pSrc,
2811 q15_t offset,
2812 q15_t * pDst,
2813 uint32_t blockSize);
2814
2815
2816 /**
2817 * @brief Adds a constant offset to a Q31 vector.
2818 * @param[in] pSrc points to the input vector
2819 * @param[in] offset is the offset to be added
2820 * @param[out] pDst points to the output vector
2821 * @param[in] blockSize number of samples in the vector
2822 */
2823 void arm_offset_q31(
2824 q31_t * pSrc,
2825 q31_t offset,
2826 q31_t * pDst,
2827 uint32_t blockSize);
2828
2829
2830 /**
2831 * @brief Negates the elements of a floating-point vector.
2832 * @param[in] pSrc points to the input vector
2833 * @param[out] pDst points to the output vector
2834 * @param[in] blockSize number of samples in the vector
2835 */
2836 void arm_negate_f32(
2837 float32_t * pSrc,
2838 float32_t * pDst,
2839 uint32_t blockSize);
2840
2841
2842 /**
2843 * @brief Negates the elements of a Q7 vector.
2844 * @param[in] pSrc points to the input vector
2845 * @param[out] pDst points to the output vector
2846 * @param[in] blockSize number of samples in the vector
2847 */
2848 void arm_negate_q7(
2849 q7_t * pSrc,
2850 q7_t * pDst,
2851 uint32_t blockSize);
2852
2853
2854 /**
2855 * @brief Negates the elements of a Q15 vector.
2856 * @param[in] pSrc points to the input vector
2857 * @param[out] pDst points to the output vector
2858 * @param[in] blockSize number of samples in the vector
2859 */
2860 void arm_negate_q15(
2861 q15_t * pSrc,
2862 q15_t * pDst,
2863 uint32_t blockSize);
2864
2865
2866 /**
2867 * @brief Negates the elements of a Q31 vector.
2868 * @param[in] pSrc points to the input vector
2869 * @param[out] pDst points to the output vector
2870 * @param[in] blockSize number of samples in the vector
2871 */
2872 void arm_negate_q31(
2873 q31_t * pSrc,
2874 q31_t * pDst,
2875 uint32_t blockSize);
2876
2877
2878 /**
2879 * @brief Copies the elements of a floating-point vector.
2880 * @param[in] pSrc input pointer
2881 * @param[out] pDst output pointer
2882 * @param[in] blockSize number of samples to process
2883 */
2884 void arm_copy_f32(
2885 float32_t * pSrc,
2886 float32_t * pDst,
2887 uint32_t blockSize);
2888
2889
2890 /**
2891 * @brief Copies the elements of a Q7 vector.
2892 * @param[in] pSrc input pointer
2893 * @param[out] pDst output pointer
2894 * @param[in] blockSize number of samples to process
2895 */
2896 void arm_copy_q7(
2897 q7_t * pSrc,
2898 q7_t * pDst,
2899 uint32_t blockSize);
2900
2901
2902 /**
2903 * @brief Copies the elements of a Q15 vector.
2904 * @param[in] pSrc input pointer
2905 * @param[out] pDst output pointer
2906 * @param[in] blockSize number of samples to process
2907 */
2908 void arm_copy_q15(
2909 q15_t * pSrc,
2910 q15_t * pDst,
2911 uint32_t blockSize);
2912
2913
2914 /**
2915 * @brief Copies the elements of a Q31 vector.
2916 * @param[in] pSrc input pointer
2917 * @param[out] pDst output pointer
2918 * @param[in] blockSize number of samples to process
2919 */
2920 void arm_copy_q31(
2921 q31_t * pSrc,
2922 q31_t * pDst,
2923 uint32_t blockSize);
2924
2925
2926 /**
2927 * @brief Fills a constant value into a floating-point vector.
2928 * @param[in] value input value to be filled
2929 * @param[out] pDst output pointer
2930 * @param[in] blockSize number of samples to process
2931 */
2932 void arm_fill_f32(
2933 float32_t value,
2934 float32_t * pDst,
2935 uint32_t blockSize);
2936
2937
2938 /**
2939 * @brief Fills a constant value into a Q7 vector.
2940 * @param[in] value input value to be filled
2941 * @param[out] pDst output pointer
2942 * @param[in] blockSize number of samples to process
2943 */
2944 void arm_fill_q7(
2945 q7_t value,
2946 q7_t * pDst,
2947 uint32_t blockSize);
2948
2949
2950 /**
2951 * @brief Fills a constant value into a Q15 vector.
2952 * @param[in] value input value to be filled
2953 * @param[out] pDst output pointer
2954 * @param[in] blockSize number of samples to process
2955 */
2956 void arm_fill_q15(
2957 q15_t value,
2958 q15_t * pDst,
2959 uint32_t blockSize);
2960
2961
2962 /**
2963 * @brief Fills a constant value into a Q31 vector.
2964 * @param[in] value input value to be filled
2965 * @param[out] pDst output pointer
2966 * @param[in] blockSize number of samples to process
2967 */
2968 void arm_fill_q31(
2969 q31_t value,
2970 q31_t * pDst,
2971 uint32_t blockSize);
2972
2973
2974/**
2975 * @brief Convolution of floating-point sequences.
2976 * @param[in] pSrcA points to the first input sequence.
2977 * @param[in] srcALen length of the first input sequence.
2978 * @param[in] pSrcB points to the second input sequence.
2979 * @param[in] srcBLen length of the second input sequence.
2980 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
2981 */
2982 void arm_conv_f32(
2983 float32_t * pSrcA,
2984 uint32_t srcALen,
2985 float32_t * pSrcB,
2986 uint32_t srcBLen,
2987 float32_t * pDst);
2988
2989
2990 /**
2991 * @brief Convolution of Q15 sequences.
2992 * @param[in] pSrcA points to the first input sequence.
2993 * @param[in] srcALen length of the first input sequence.
2994 * @param[in] pSrcB points to the second input sequence.
2995 * @param[in] srcBLen length of the second input sequence.
2996 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
2997 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
2998 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
2999 */
3000 void arm_conv_opt_q15(
3001 q15_t * pSrcA,
3002 uint32_t srcALen,
3003 q15_t * pSrcB,
3004 uint32_t srcBLen,
3005 q15_t * pDst,
3006 q15_t * pScratch1,
3007 q15_t * pScratch2);
3008
3009
3010/**
3011 * @brief Convolution of Q15 sequences.
3012 * @param[in] pSrcA points to the first input sequence.
3013 * @param[in] srcALen length of the first input sequence.
3014 * @param[in] pSrcB points to the second input sequence.
3015 * @param[in] srcBLen length of the second input sequence.
3016 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
3017 */
3018 void arm_conv_q15(
3019 q15_t * pSrcA,
3020 uint32_t srcALen,
3021 q15_t * pSrcB,
3022 uint32_t srcBLen,
3023 q15_t * pDst);
3024
3025
3026 /**
3027 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3028 * @param[in] pSrcA points to the first input sequence.
3029 * @param[in] srcALen length of the first input sequence.
3030 * @param[in] pSrcB points to the second input sequence.
3031 * @param[in] srcBLen length of the second input sequence.
3032 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3033 */
3034 void arm_conv_fast_q15(
3035 q15_t * pSrcA,
3036 uint32_t srcALen,
3037 q15_t * pSrcB,
3038 uint32_t srcBLen,
3039 q15_t * pDst);
3040
3041
3042 /**
3043 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3044 * @param[in] pSrcA points to the first input sequence.
3045 * @param[in] srcALen length of the first input sequence.
3046 * @param[in] pSrcB points to the second input sequence.
3047 * @param[in] srcBLen length of the second input sequence.
3048 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3049 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3050 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3051 */
3052 void arm_conv_fast_opt_q15(
3053 q15_t * pSrcA,
3054 uint32_t srcALen,
3055 q15_t * pSrcB,
3056 uint32_t srcBLen,
3057 q15_t * pDst,
3058 q15_t * pScratch1,
3059 q15_t * pScratch2);
3060
3061
3062 /**
3063 * @brief Convolution of Q31 sequences.
3064 * @param[in] pSrcA points to the first input sequence.
3065 * @param[in] srcALen length of the first input sequence.
3066 * @param[in] pSrcB points to the second input sequence.
3067 * @param[in] srcBLen length of the second input sequence.
3068 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3069 */
3070 void arm_conv_q31(
3071 q31_t * pSrcA,
3072 uint32_t srcALen,
3073 q31_t * pSrcB,
3074 uint32_t srcBLen,
3075 q31_t * pDst);
3076
3077
3078 /**
3079 * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3080 * @param[in] pSrcA points to the first input sequence.
3081 * @param[in] srcALen length of the first input sequence.
3082 * @param[in] pSrcB points to the second input sequence.
3083 * @param[in] srcBLen length of the second input sequence.
3084 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3085 */
3086 void arm_conv_fast_q31(
3087 q31_t * pSrcA,
3088 uint32_t srcALen,
3089 q31_t * pSrcB,
3090 uint32_t srcBLen,
3091 q31_t * pDst);
3092
3093
3094 /**
3095 * @brief Convolution of Q7 sequences.
3096 * @param[in] pSrcA points to the first input sequence.
3097 * @param[in] srcALen length of the first input sequence.
3098 * @param[in] pSrcB points to the second input sequence.
3099 * @param[in] srcBLen length of the second input sequence.
3100 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3101 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3102 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3103 */
3104 void arm_conv_opt_q7(
3105 q7_t * pSrcA,
3106 uint32_t srcALen,
3107 q7_t * pSrcB,
3108 uint32_t srcBLen,
3109 q7_t * pDst,
3110 q15_t * pScratch1,
3111 q15_t * pScratch2);
3112
3113
3114 /**
3115 * @brief Convolution of Q7 sequences.
3116 * @param[in] pSrcA points to the first input sequence.
3117 * @param[in] srcALen length of the first input sequence.
3118 * @param[in] pSrcB points to the second input sequence.
3119 * @param[in] srcBLen length of the second input sequence.
3120 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1.
3121 */
3122 void arm_conv_q7(
3123 q7_t * pSrcA,
3124 uint32_t srcALen,
3125 q7_t * pSrcB,
3126 uint32_t srcBLen,
3127 q7_t * pDst);
3128
3129
3130 /**
3131 * @brief Partial convolution of floating-point sequences.
3132 * @param[in] pSrcA points to the first input sequence.
3133 * @param[in] srcALen length of the first input sequence.
3134 * @param[in] pSrcB points to the second input sequence.
3135 * @param[in] srcBLen length of the second input sequence.
3136 * @param[out] pDst points to the block of output data
3137 * @param[in] firstIndex is the first output sample to start with.
3138 * @param[in] numPoints is the number of output points to be computed.
3139 * @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].
3140 */
3141 arm_status arm_conv_partial_f32(
3142 float32_t * pSrcA,
3143 uint32_t srcALen,
3144 float32_t * pSrcB,
3145 uint32_t srcBLen,
3146 float32_t * pDst,
3147 uint32_t firstIndex,
3148 uint32_t numPoints);
3149
3150
3151 /**
3152 * @brief Partial convolution of Q15 sequences.
3153 * @param[in] pSrcA points to the first input sequence.
3154 * @param[in] srcALen length of the first input sequence.
3155 * @param[in] pSrcB points to the second input sequence.
3156 * @param[in] srcBLen length of the second input sequence.
3157 * @param[out] pDst points to the block of output data
3158 * @param[in] firstIndex is the first output sample to start with.
3159 * @param[in] numPoints is the number of output points to be computed.
3160 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3161 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3162 * @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].
3163 */
3164 arm_status arm_conv_partial_opt_q15(
3165 q15_t * pSrcA,
3166 uint32_t srcALen,
3167 q15_t * pSrcB,
3168 uint32_t srcBLen,
3169 q15_t * pDst,
3170 uint32_t firstIndex,
3171 uint32_t numPoints,
3172 q15_t * pScratch1,
3173 q15_t * pScratch2);
3174
3175
3176 /**
3177 * @brief Partial convolution of Q15 sequences.
3178 * @param[in] pSrcA points to the first input sequence.
3179 * @param[in] srcALen length of the first input sequence.
3180 * @param[in] pSrcB points to the second input sequence.
3181 * @param[in] srcBLen length of the second input sequence.
3182 * @param[out] pDst points to the block of output data
3183 * @param[in] firstIndex is the first output sample to start with.
3184 * @param[in] numPoints is the number of output points to be computed.
3185 * @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].
3186 */
3187 arm_status arm_conv_partial_q15(
3188 q15_t * pSrcA,
3189 uint32_t srcALen,
3190 q15_t * pSrcB,
3191 uint32_t srcBLen,
3192 q15_t * pDst,
3193 uint32_t firstIndex,
3194 uint32_t numPoints);
3195
3196
3197 /**
3198 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3199 * @param[in] pSrcA points to the first input sequence.
3200 * @param[in] srcALen length of the first input sequence.
3201 * @param[in] pSrcB points to the second input sequence.
3202 * @param[in] srcBLen length of the second input sequence.
3203 * @param[out] pDst points to the block of output data
3204 * @param[in] firstIndex is the first output sample to start with.
3205 * @param[in] numPoints is the number of output points to be computed.
3206 * @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].
3207 */
3208 arm_status arm_conv_partial_fast_q15(
3209 q15_t * pSrcA,
3210 uint32_t srcALen,
3211 q15_t * pSrcB,
3212 uint32_t srcBLen,
3213 q15_t * pDst,
3214 uint32_t firstIndex,
3215 uint32_t numPoints);
3216
3217
3218 /**
3219 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
3220 * @param[in] pSrcA points to the first input sequence.
3221 * @param[in] srcALen length of the first input sequence.
3222 * @param[in] pSrcB points to the second input sequence.
3223 * @param[in] srcBLen length of the second input sequence.
3224 * @param[out] pDst points to the block of output data
3225 * @param[in] firstIndex is the first output sample to start with.
3226 * @param[in] numPoints is the number of output points to be computed.
3227 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3228 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
3229 * @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].
3230 */
3231 arm_status arm_conv_partial_fast_opt_q15(
3232 q15_t * pSrcA,
3233 uint32_t srcALen,
3234 q15_t * pSrcB,
3235 uint32_t srcBLen,
3236 q15_t * pDst,
3237 uint32_t firstIndex,
3238 uint32_t numPoints,
3239 q15_t * pScratch1,
3240 q15_t * pScratch2);
3241
3242
3243 /**
3244 * @brief Partial convolution of Q31 sequences.
3245 * @param[in] pSrcA points to the first input sequence.
3246 * @param[in] srcALen length of the first input sequence.
3247 * @param[in] pSrcB points to the second input sequence.
3248 * @param[in] srcBLen length of the second input sequence.
3249 * @param[out] pDst points to the block of output data
3250 * @param[in] firstIndex is the first output sample to start with.
3251 * @param[in] numPoints is the number of output points to be computed.
3252 * @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].
3253 */
3254 arm_status arm_conv_partial_q31(
3255 q31_t * pSrcA,
3256 uint32_t srcALen,
3257 q31_t * pSrcB,
3258 uint32_t srcBLen,
3259 q31_t * pDst,
3260 uint32_t firstIndex,
3261 uint32_t numPoints);
3262
3263
3264 /**
3265 * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
3266 * @param[in] pSrcA points to the first input sequence.
3267 * @param[in] srcALen length of the first input sequence.
3268 * @param[in] pSrcB points to the second input sequence.
3269 * @param[in] srcBLen length of the second input sequence.
3270 * @param[out] pDst points to the block of output data
3271 * @param[in] firstIndex is the first output sample to start with.
3272 * @param[in] numPoints is the number of output points to be computed.
3273 * @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].
3274 */
3275 arm_status arm_conv_partial_fast_q31(
3276 q31_t * pSrcA,
3277 uint32_t srcALen,
3278 q31_t * pSrcB,
3279 uint32_t srcBLen,
3280 q31_t * pDst,
3281 uint32_t firstIndex,
3282 uint32_t numPoints);
3283
3284
3285 /**
3286 * @brief Partial convolution of Q7 sequences
3287 * @param[in] pSrcA points to the first input sequence.
3288 * @param[in] srcALen length of the first input sequence.
3289 * @param[in] pSrcB points to the second input sequence.
3290 * @param[in] srcBLen length of the second input sequence.
3291 * @param[out] pDst points to the block of output data
3292 * @param[in] firstIndex is the first output sample to start with.
3293 * @param[in] numPoints is the number of output points to be computed.
3294 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
3295 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
3296 * @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].
3297 */
3298 arm_status arm_conv_partial_opt_q7(
3299 q7_t * pSrcA,
3300 uint32_t srcALen,
3301 q7_t * pSrcB,
3302 uint32_t srcBLen,
3303 q7_t * pDst,
3304 uint32_t firstIndex,
3305 uint32_t numPoints,
3306 q15_t * pScratch1,
3307 q15_t * pScratch2);
3308
3309
3310/**
3311 * @brief Partial convolution of Q7 sequences.
3312 * @param[in] pSrcA points to the first input sequence.
3313 * @param[in] srcALen length of the first input sequence.
3314 * @param[in] pSrcB points to the second input sequence.
3315 * @param[in] srcBLen length of the second input sequence.
3316 * @param[out] pDst points to the block of output data
3317 * @param[in] firstIndex is the first output sample to start with.
3318 * @param[in] numPoints is the number of output points to be computed.
3319 * @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].
3320 */
3321 arm_status arm_conv_partial_q7(
3322 q7_t * pSrcA,
3323 uint32_t srcALen,
3324 q7_t * pSrcB,
3325 uint32_t srcBLen,
3326 q7_t * pDst,
3327 uint32_t firstIndex,
3328 uint32_t numPoints);
3329
3330
3331 /**
3332 * @brief Instance structure for the Q15 FIR decimator.
3333 */
3334 typedef struct
3335 {
3336 uint8_t M; /**< decimation factor. */
3337 uint16_t numTaps; /**< number of coefficients in the filter. */
3338 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3339 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3340 } arm_fir_decimate_instance_q15;
3341
3342 /**
3343 * @brief Instance structure for the Q31 FIR decimator.
3344 */
3345 typedef struct
3346 {
3347 uint8_t M; /**< decimation factor. */
3348 uint16_t numTaps; /**< number of coefficients in the filter. */
3349 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3350 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3351 } arm_fir_decimate_instance_q31;
3352
3353 /**
3354 * @brief Instance structure for the floating-point FIR decimator.
3355 */
3356 typedef struct
3357 {
3358 uint8_t M; /**< decimation factor. */
3359 uint16_t numTaps; /**< number of coefficients in the filter. */
3360 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
3361 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
3362 } arm_fir_decimate_instance_f32;
3363
3364
3365 /**
3366 * @brief Processing function for the floating-point FIR decimator.
3367 * @param[in] S points to an instance of the floating-point FIR decimator structure.
3368 * @param[in] pSrc points to the block of input data.
3369 * @param[out] pDst points to the block of output data
3370 * @param[in] blockSize number of input samples to process per call.
3371 */
3372 void arm_fir_decimate_f32(
3373 const arm_fir_decimate_instance_f32 * S,
3374 float32_t * pSrc,
3375 float32_t * pDst,
3376 uint32_t blockSize);
3377
3378
3379 /**
3380 * @brief Initialization function for the floating-point FIR decimator.
3381 * @param[in,out] S points to an instance of the floating-point FIR decimator structure.
3382 * @param[in] numTaps number of coefficients in the filter.
3383 * @param[in] M decimation factor.
3384 * @param[in] pCoeffs points to the filter coefficients.
3385 * @param[in] pState points to the state buffer.
3386 * @param[in] blockSize number of input samples to process per call.
3387 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3388 * <code>blockSize</code> is not a multiple of <code>M</code>.
3389 */
3390 arm_status arm_fir_decimate_init_f32(
3391 arm_fir_decimate_instance_f32 * S,
3392 uint16_t numTaps,
3393 uint8_t M,
3394 float32_t * pCoeffs,
3395 float32_t * pState,
3396 uint32_t blockSize);
3397
3398
3399 /**
3400 * @brief Processing function for the Q15 FIR decimator.
3401 * @param[in] S points to an instance of the Q15 FIR decimator structure.
3402 * @param[in] pSrc points to the block of input data.
3403 * @param[out] pDst points to the block of output data
3404 * @param[in] blockSize number of input samples to process per call.
3405 */
3406 void arm_fir_decimate_q15(
3407 const arm_fir_decimate_instance_q15 * S,
3408 q15_t * pSrc,
3409 q15_t * pDst,
3410 uint32_t blockSize);
3411
3412
3413 /**
3414 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3415 * @param[in] S points to an instance of the Q15 FIR decimator structure.
3416 * @param[in] pSrc points to the block of input data.
3417 * @param[out] pDst points to the block of output data
3418 * @param[in] blockSize number of input samples to process per call.
3419 */
3420 void arm_fir_decimate_fast_q15(
3421 const arm_fir_decimate_instance_q15 * S,
3422 q15_t * pSrc,
3423 q15_t * pDst,
3424 uint32_t blockSize);
3425
3426
3427 /**
3428 * @brief Initialization function for the Q15 FIR decimator.
3429 * @param[in,out] S points to an instance of the Q15 FIR decimator structure.
3430 * @param[in] numTaps number of coefficients in the filter.
3431 * @param[in] M decimation factor.
3432 * @param[in] pCoeffs points to the filter coefficients.
3433 * @param[in] pState points to the state buffer.
3434 * @param[in] blockSize number of input samples to process per call.
3435 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3436 * <code>blockSize</code> is not a multiple of <code>M</code>.
3437 */
3438 arm_status arm_fir_decimate_init_q15(
3439 arm_fir_decimate_instance_q15 * S,
3440 uint16_t numTaps,
3441 uint8_t M,
3442 q15_t * pCoeffs,
3443 q15_t * pState,
3444 uint32_t blockSize);
3445
3446
3447 /**
3448 * @brief Processing function for the Q31 FIR decimator.
3449 * @param[in] S points to an instance of the Q31 FIR decimator structure.
3450 * @param[in] pSrc points to the block of input data.
3451 * @param[out] pDst points to the block of output data
3452 * @param[in] blockSize number of input samples to process per call.
3453 */
3454 void arm_fir_decimate_q31(
3455 const arm_fir_decimate_instance_q31 * S,
3456 q31_t * pSrc,
3457 q31_t * pDst,
3458 uint32_t blockSize);
3459
3460 /**
3461 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
3462 * @param[in] S points to an instance of the Q31 FIR decimator structure.
3463 * @param[in] pSrc points to the block of input data.
3464 * @param[out] pDst points to the block of output data
3465 * @param[in] blockSize number of input samples to process per call.
3466 */
3467 void arm_fir_decimate_fast_q31(
3468 arm_fir_decimate_instance_q31 * S,
3469 q31_t * pSrc,
3470 q31_t * pDst,
3471 uint32_t blockSize);
3472
3473
3474 /**
3475 * @brief Initialization function for the Q31 FIR decimator.
3476 * @param[in,out] S points to an instance of the Q31 FIR decimator structure.
3477 * @param[in] numTaps number of coefficients in the filter.
3478 * @param[in] M decimation factor.
3479 * @param[in] pCoeffs points to the filter coefficients.
3480 * @param[in] pState points to the state buffer.
3481 * @param[in] blockSize number of input samples to process per call.
3482 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3483 * <code>blockSize</code> is not a multiple of <code>M</code>.
3484 */
3485 arm_status arm_fir_decimate_init_q31(
3486 arm_fir_decimate_instance_q31 * S,
3487 uint16_t numTaps,
3488 uint8_t M,
3489 q31_t * pCoeffs,
3490 q31_t * pState,
3491 uint32_t blockSize);
3492
3493
3494 /**
3495 * @brief Instance structure for the Q15 FIR interpolator.
3496 */
3497 typedef struct
3498 {
3499 uint8_t L; /**< upsample factor. */
3500 uint16_t phaseLength; /**< length of each polyphase filter component. */
3501 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3502 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3503 } arm_fir_interpolate_instance_q15;
3504
3505 /**
3506 * @brief Instance structure for the Q31 FIR interpolator.
3507 */
3508 typedef struct
3509 {
3510 uint8_t L; /**< upsample factor. */
3511 uint16_t phaseLength; /**< length of each polyphase filter component. */
3512 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3513 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
3514 } arm_fir_interpolate_instance_q31;
3515
3516 /**
3517 * @brief Instance structure for the floating-point FIR interpolator.
3518 */
3519 typedef struct
3520 {
3521 uint8_t L; /**< upsample factor. */
3522 uint16_t phaseLength; /**< length of each polyphase filter component. */
3523 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
3524 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
3525 } arm_fir_interpolate_instance_f32;
3526
3527
3528 /**
3529 * @brief Processing function for the Q15 FIR interpolator.
3530 * @param[in] S points to an instance of the Q15 FIR interpolator structure.
3531 * @param[in] pSrc points to the block of input data.
3532 * @param[out] pDst points to the block of output data.
3533 * @param[in] blockSize number of input samples to process per call.
3534 */
3535 void arm_fir_interpolate_q15(
3536 const arm_fir_interpolate_instance_q15 * S,
3537 q15_t * pSrc,
3538 q15_t * pDst,
3539 uint32_t blockSize);
3540
3541
3542 /**
3543 * @brief Initialization function for the Q15 FIR interpolator.
3544 * @param[in,out] S points to an instance of the Q15 FIR interpolator structure.
3545 * @param[in] L upsample factor.
3546 * @param[in] numTaps number of filter coefficients in the filter.
3547 * @param[in] pCoeffs points to the filter coefficient buffer.
3548 * @param[in] pState points to the state buffer.
3549 * @param[in] blockSize number of input samples to process per call.
3550 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3551 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3552 */
3553 arm_status arm_fir_interpolate_init_q15(
3554 arm_fir_interpolate_instance_q15 * S,
3555 uint8_t L,
3556 uint16_t numTaps,
3557 q15_t * pCoeffs,
3558 q15_t * pState,
3559 uint32_t blockSize);
3560
3561
3562 /**
3563 * @brief Processing function for the Q31 FIR interpolator.
3564 * @param[in] S points to an instance of the Q15 FIR interpolator structure.
3565 * @param[in] pSrc points to the block of input data.
3566 * @param[out] pDst points to the block of output data.
3567 * @param[in] blockSize number of input samples to process per call.
3568 */
3569 void arm_fir_interpolate_q31(
3570 const arm_fir_interpolate_instance_q31 * S,
3571 q31_t * pSrc,
3572 q31_t * pDst,
3573 uint32_t blockSize);
3574
3575
3576 /**
3577 * @brief Initialization function for the Q31 FIR interpolator.
3578 * @param[in,out] S points to an instance of the Q31 FIR interpolator structure.
3579 * @param[in] L upsample factor.
3580 * @param[in] numTaps number of filter coefficients in the filter.
3581 * @param[in] pCoeffs points to the filter coefficient buffer.
3582 * @param[in] pState points to the state buffer.
3583 * @param[in] blockSize number of input samples to process per call.
3584 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3585 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3586 */
3587 arm_status arm_fir_interpolate_init_q31(
3588 arm_fir_interpolate_instance_q31 * S,
3589 uint8_t L,
3590 uint16_t numTaps,
3591 q31_t * pCoeffs,
3592 q31_t * pState,
3593 uint32_t blockSize);
3594
3595
3596 /**
3597 * @brief Processing function for the floating-point FIR interpolator.
3598 * @param[in] S points to an instance of the floating-point FIR interpolator structure.
3599 * @param[in] pSrc points to the block of input data.
3600 * @param[out] pDst points to the block of output data.
3601 * @param[in] blockSize number of input samples to process per call.
3602 */
3603 void arm_fir_interpolate_f32(
3604 const arm_fir_interpolate_instance_f32 * S,
3605 float32_t * pSrc,
3606 float32_t * pDst,
3607 uint32_t blockSize);
3608
3609
3610 /**
3611 * @brief Initialization function for the floating-point FIR interpolator.
3612 * @param[in,out] S points to an instance of the floating-point FIR interpolator structure.
3613 * @param[in] L upsample factor.
3614 * @param[in] numTaps number of filter coefficients in the filter.
3615 * @param[in] pCoeffs points to the filter coefficient buffer.
3616 * @param[in] pState points to the state buffer.
3617 * @param[in] blockSize number of input samples to process per call.
3618 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
3619 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
3620 */
3621 arm_status arm_fir_interpolate_init_f32(
3622 arm_fir_interpolate_instance_f32 * S,
3623 uint8_t L,
3624 uint16_t numTaps,
3625 float32_t * pCoeffs,
3626 float32_t * pState,
3627 uint32_t blockSize);
3628
3629
3630 /**
3631 * @brief Instance structure for the high precision Q31 Biquad cascade filter.
3632 */
3633 typedef struct
3634 {
3635 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3636 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3637 q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3638 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
3639 } arm_biquad_cas_df1_32x64_ins_q31;
3640
3641
3642 /**
3643 * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure.
3644 * @param[in] pSrc points to the block of input data.
3645 * @param[out] pDst points to the block of output data
3646 * @param[in] blockSize number of samples to process.
3647 */
3648 void arm_biquad_cas_df1_32x64_q31(
3649 const arm_biquad_cas_df1_32x64_ins_q31 * S,
3650 q31_t * pSrc,
3651 q31_t * pDst,
3652 uint32_t blockSize);
3653
3654
3655 /**
3656 * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure.
3657 * @param[in] numStages number of 2nd order stages in the filter.
3658 * @param[in] pCoeffs points to the filter coefficients.
3659 * @param[in] pState points to the state buffer.
3660 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
3661 */
3662 void arm_biquad_cas_df1_32x64_init_q31(
3663 arm_biquad_cas_df1_32x64_ins_q31 * S,
3664 uint8_t numStages,
3665 q31_t * pCoeffs,
3666 q63_t * pState,
3667 uint8_t postShift);
3668
3669
3670 /**
3671 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3672 */
3673 typedef struct
3674 {
3675 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3676 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3677 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3678 } arm_biquad_cascade_df2T_instance_f32;
3679
3680 /**
3681 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3682 */
3683 typedef struct
3684 {
3685 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3686 float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
3687 float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3688 } arm_biquad_cascade_stereo_df2T_instance_f32;
3689
3690 /**
3691 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
3692 */
3693 typedef struct
3694 {
3695 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
3696 float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
3697 float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
3698 } arm_biquad_cascade_df2T_instance_f64;
3699
3700
3701 /**
3702 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3703 * @param[in] S points to an instance of the filter data structure.
3704 * @param[in] pSrc points to the block of input data.
3705 * @param[out] pDst points to the block of output data
3706 * @param[in] blockSize number of samples to process.
3707 */
3708 void arm_biquad_cascade_df2T_f32(
3709 const arm_biquad_cascade_df2T_instance_f32 * S,
3710 float32_t * pSrc,
3711 float32_t * pDst,
3712 uint32_t blockSize);
3713
3714
3715 /**
3716 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels
3717 * @param[in] S points to an instance of the filter data structure.
3718 * @param[in] pSrc points to the block of input data.
3719 * @param[out] pDst points to the block of output data
3720 * @param[in] blockSize number of samples to process.
3721 */
3722 void arm_biquad_cascade_stereo_df2T_f32(
3723 const arm_biquad_cascade_stereo_df2T_instance_f32 * S,
3724 float32_t * pSrc,
3725 float32_t * pDst,
3726 uint32_t blockSize);
3727
3728
3729 /**
3730 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
3731 * @param[in] S points to an instance of the filter data structure.
3732 * @param[in] pSrc points to the block of input data.
3733 * @param[out] pDst points to the block of output data
3734 * @param[in] blockSize number of samples to process.
3735 */
3736 void arm_biquad_cascade_df2T_f64(
3737 const arm_biquad_cascade_df2T_instance_f64 * S,
3738 float64_t * pSrc,
3739 float64_t * pDst,
3740 uint32_t blockSize);
3741
3742
3743 /**
3744 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3745 * @param[in,out] S points to an instance of the filter data structure.
3746 * @param[in] numStages number of 2nd order stages in the filter.
3747 * @param[in] pCoeffs points to the filter coefficients.
3748 * @param[in] pState points to the state buffer.
3749 */
3750 void arm_biquad_cascade_df2T_init_f32(
3751 arm_biquad_cascade_df2T_instance_f32 * S,
3752 uint8_t numStages,
3753 float32_t * pCoeffs,
3754 float32_t * pState);
3755
3756
3757 /**
3758 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3759 * @param[in,out] S points to an instance of the filter data structure.
3760 * @param[in] numStages number of 2nd order stages in the filter.
3761 * @param[in] pCoeffs points to the filter coefficients.
3762 * @param[in] pState points to the state buffer.
3763 */
3764 void arm_biquad_cascade_stereo_df2T_init_f32(
3765 arm_biquad_cascade_stereo_df2T_instance_f32 * S,
3766 uint8_t numStages,
3767 float32_t * pCoeffs,
3768 float32_t * pState);
3769
3770
3771 /**
3772 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
3773 * @param[in,out] S points to an instance of the filter data structure.
3774 * @param[in] numStages number of 2nd order stages in the filter.
3775 * @param[in] pCoeffs points to the filter coefficients.
3776 * @param[in] pState points to the state buffer.
3777 */
3778 void arm_biquad_cascade_df2T_init_f64(
3779 arm_biquad_cascade_df2T_instance_f64 * S,
3780 uint8_t numStages,
3781 float64_t * pCoeffs,
3782 float64_t * pState);
3783
3784
3785 /**
3786 * @brief Instance structure for the Q15 FIR lattice filter.
3787 */
3788 typedef struct
3789 {
3790 uint16_t numStages; /**< number of filter stages. */
3791 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
3792 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3793 } arm_fir_lattice_instance_q15;
3794
3795 /**
3796 * @brief Instance structure for the Q31 FIR lattice filter.
3797 */
3798 typedef struct
3799 {
3800 uint16_t numStages; /**< number of filter stages. */
3801 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
3802 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3803 } arm_fir_lattice_instance_q31;
3804
3805 /**
3806 * @brief Instance structure for the floating-point FIR lattice filter.
3807 */
3808 typedef struct
3809 {
3810 uint16_t numStages; /**< number of filter stages. */
3811 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
3812 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
3813 } arm_fir_lattice_instance_f32;
3814
3815
3816 /**
3817 * @brief Initialization function for the Q15 FIR lattice filter.
3818 * @param[in] S points to an instance of the Q15 FIR lattice structure.
3819 * @param[in] numStages number of filter stages.
3820 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3821 * @param[in] pState points to the state buffer. The array is of length numStages.
3822 */
3823 void arm_fir_lattice_init_q15(
3824 arm_fir_lattice_instance_q15 * S,
3825 uint16_t numStages,
3826 q15_t * pCoeffs,
3827 q15_t * pState);
3828
3829
3830 /**
3831 * @brief Processing function for the Q15 FIR lattice filter.
3832 * @param[in] S points to an instance of the Q15 FIR lattice structure.
3833 * @param[in] pSrc points to the block of input data.
3834 * @param[out] pDst points to the block of output data.
3835 * @param[in] blockSize number of samples to process.
3836 */
3837 void arm_fir_lattice_q15(
3838 const arm_fir_lattice_instance_q15 * S,
3839 q15_t * pSrc,
3840 q15_t * pDst,
3841 uint32_t blockSize);
3842
3843
3844 /**
3845 * @brief Initialization function for the Q31 FIR lattice filter.
3846 * @param[in] S points to an instance of the Q31 FIR lattice structure.
3847 * @param[in] numStages number of filter stages.
3848 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3849 * @param[in] pState points to the state buffer. The array is of length numStages.
3850 */
3851 void arm_fir_lattice_init_q31(
3852 arm_fir_lattice_instance_q31 * S,
3853 uint16_t numStages,
3854 q31_t * pCoeffs,
3855 q31_t * pState);
3856
3857
3858 /**
3859 * @brief Processing function for the Q31 FIR lattice filter.
3860 * @param[in] S points to an instance of the Q31 FIR lattice structure.
3861 * @param[in] pSrc points to the block of input data.
3862 * @param[out] pDst points to the block of output data
3863 * @param[in] blockSize number of samples to process.
3864 */
3865 void arm_fir_lattice_q31(
3866 const arm_fir_lattice_instance_q31 * S,
3867 q31_t * pSrc,
3868 q31_t * pDst,
3869 uint32_t blockSize);
3870
3871
3872/**
3873 * @brief Initialization function for the floating-point FIR lattice filter.
3874 * @param[in] S points to an instance of the floating-point FIR lattice structure.
3875 * @param[in] numStages number of filter stages.
3876 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages.
3877 * @param[in] pState points to the state buffer. The array is of length numStages.
3878 */
3879 void arm_fir_lattice_init_f32(
3880 arm_fir_lattice_instance_f32 * S,
3881 uint16_t numStages,
3882 float32_t * pCoeffs,
3883 float32_t * pState);
3884
3885
3886 /**
3887 * @brief Processing function for the floating-point FIR lattice filter.
3888 * @param[in] S points to an instance of the floating-point FIR lattice structure.
3889 * @param[in] pSrc points to the block of input data.
3890 * @param[out] pDst points to the block of output data
3891 * @param[in] blockSize number of samples to process.
3892 */
3893 void arm_fir_lattice_f32(
3894 const arm_fir_lattice_instance_f32 * S,
3895 float32_t * pSrc,
3896 float32_t * pDst,
3897 uint32_t blockSize);
3898
3899
3900 /**
3901 * @brief Instance structure for the Q15 IIR lattice filter.
3902 */
3903 typedef struct
3904 {
3905 uint16_t numStages; /**< number of stages in the filter. */
3906 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3907 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3908 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3909 } arm_iir_lattice_instance_q15;
3910
3911 /**
3912 * @brief Instance structure for the Q31 IIR lattice filter.
3913 */
3914 typedef struct
3915 {
3916 uint16_t numStages; /**< number of stages in the filter. */
3917 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3918 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3919 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3920 } arm_iir_lattice_instance_q31;
3921
3922 /**
3923 * @brief Instance structure for the floating-point IIR lattice filter.
3924 */
3925 typedef struct
3926 {
3927 uint16_t numStages; /**< number of stages in the filter. */
3928 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
3929 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
3930 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
3931 } arm_iir_lattice_instance_f32;
3932
3933
3934 /**
3935 * @brief Processing function for the floating-point IIR lattice filter.
3936 * @param[in] S points to an instance of the floating-point IIR lattice structure.
3937 * @param[in] pSrc points to the block of input data.
3938 * @param[out] pDst points to the block of output data.
3939 * @param[in] blockSize number of samples to process.
3940 */
3941 void arm_iir_lattice_f32(
3942 const arm_iir_lattice_instance_f32 * S,
3943 float32_t * pSrc,
3944 float32_t * pDst,
3945 uint32_t blockSize);
3946
3947
3948 /**
3949 * @brief Initialization function for the floating-point IIR lattice filter.
3950 * @param[in] S points to an instance of the floating-point IIR lattice structure.
3951 * @param[in] numStages number of stages in the filter.
3952 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3953 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3954 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1.
3955 * @param[in] blockSize number of samples to process.
3956 */
3957 void arm_iir_lattice_init_f32(
3958 arm_iir_lattice_instance_f32 * S,
3959 uint16_t numStages,
3960 float32_t * pkCoeffs,
3961 float32_t * pvCoeffs,
3962 float32_t * pState,
3963 uint32_t blockSize);
3964
3965
3966 /**
3967 * @brief Processing function for the Q31 IIR lattice filter.
3968 * @param[in] S points to an instance of the Q31 IIR lattice structure.
3969 * @param[in] pSrc points to the block of input data.
3970 * @param[out] pDst points to the block of output data.
3971 * @param[in] blockSize number of samples to process.
3972 */
3973 void arm_iir_lattice_q31(
3974 const arm_iir_lattice_instance_q31 * S,
3975 q31_t * pSrc,
3976 q31_t * pDst,
3977 uint32_t blockSize);
3978
3979
3980 /**
3981 * @brief Initialization function for the Q31 IIR lattice filter.
3982 * @param[in] S points to an instance of the Q31 IIR lattice structure.
3983 * @param[in] numStages number of stages in the filter.
3984 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
3985 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
3986 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize.
3987 * @param[in] blockSize number of samples to process.
3988 */
3989 void arm_iir_lattice_init_q31(
3990 arm_iir_lattice_instance_q31 * S,
3991 uint16_t numStages,
3992 q31_t * pkCoeffs,
3993 q31_t * pvCoeffs,
3994 q31_t * pState,
3995 uint32_t blockSize);
3996
3997
3998 /**
3999 * @brief Processing function for the Q15 IIR lattice filter.
4000 * @param[in] S points to an instance of the Q15 IIR lattice structure.
4001 * @param[in] pSrc points to the block of input data.
4002 * @param[out] pDst points to the block of output data.
4003 * @param[in] blockSize number of samples to process.
4004 */
4005 void arm_iir_lattice_q15(
4006 const arm_iir_lattice_instance_q15 * S,
4007 q15_t * pSrc,
4008 q15_t * pDst,
4009 uint32_t blockSize);
4010
4011
4012/**
4013 * @brief Initialization function for the Q15 IIR lattice filter.
4014 * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure.
4015 * @param[in] numStages number of stages in the filter.
4016 * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
4017 * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
4018 * @param[in] pState points to state buffer. The array is of length numStages+blockSize.
4019 * @param[in] blockSize number of samples to process per call.
4020 */
4021 void arm_iir_lattice_init_q15(
4022 arm_iir_lattice_instance_q15 * S,
4023 uint16_t numStages,
4024 q15_t * pkCoeffs,
4025 q15_t * pvCoeffs,
4026 q15_t * pState,
4027 uint32_t blockSize);
4028
4029
4030 /**
4031 * @brief Instance structure for the floating-point LMS filter.
4032 */
4033 typedef struct
4034 {
4035 uint16_t numTaps; /**< number of coefficients in the filter. */
4036 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4037 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4038 float32_t mu; /**< step size that controls filter coefficient updates. */
4039 } arm_lms_instance_f32;
4040
4041
4042 /**
4043 * @brief Processing function for floating-point LMS filter.
4044 * @param[in] S points to an instance of the floating-point LMS filter structure.
4045 * @param[in] pSrc points to the block of input data.
4046 * @param[in] pRef points to the block of reference data.
4047 * @param[out] pOut points to the block of output data.
4048 * @param[out] pErr points to the block of error data.
4049 * @param[in] blockSize number of samples to process.
4050 */
4051 void arm_lms_f32(
4052 const arm_lms_instance_f32 * S,
4053 float32_t * pSrc,
4054 float32_t * pRef,
4055 float32_t * pOut,
4056 float32_t * pErr,
4057 uint32_t blockSize);
4058
4059
4060 /**
4061 * @brief Initialization function for floating-point LMS filter.
4062 * @param[in] S points to an instance of the floating-point LMS filter structure.
4063 * @param[in] numTaps number of filter coefficients.
4064 * @param[in] pCoeffs points to the coefficient buffer.
4065 * @param[in] pState points to state buffer.
4066 * @param[in] mu step size that controls filter coefficient updates.
4067 * @param[in] blockSize number of samples to process.
4068 */
4069 void arm_lms_init_f32(
4070 arm_lms_instance_f32 * S,
4071 uint16_t numTaps,
4072 float32_t * pCoeffs,
4073 float32_t * pState,
4074 float32_t mu,
4075 uint32_t blockSize);
4076
4077
4078 /**
4079 * @brief Instance structure for the Q15 LMS filter.
4080 */
4081 typedef struct
4082 {
4083 uint16_t numTaps; /**< number of coefficients in the filter. */
4084 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4085 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4086 q15_t mu; /**< step size that controls filter coefficient updates. */
4087 uint32_t postShift; /**< bit shift applied to coefficients. */
4088 } arm_lms_instance_q15;
4089
4090
4091 /**
4092 * @brief Initialization function for the Q15 LMS filter.
4093 * @param[in] S points to an instance of the Q15 LMS filter structure.
4094 * @param[in] numTaps number of filter coefficients.
4095 * @param[in] pCoeffs points to the coefficient buffer.
4096 * @param[in] pState points to the state buffer.
4097 * @param[in] mu step size that controls filter coefficient updates.
4098 * @param[in] blockSize number of samples to process.
4099 * @param[in] postShift bit shift applied to coefficients.
4100 */
4101 void arm_lms_init_q15(
4102 arm_lms_instance_q15 * S,
4103 uint16_t numTaps,
4104 q15_t * pCoeffs,
4105 q15_t * pState,
4106 q15_t mu,
4107 uint32_t blockSize,
4108 uint32_t postShift);
4109
4110
4111 /**
4112 * @brief Processing function for Q15 LMS filter.
4113 * @param[in] S points to an instance of the Q15 LMS filter structure.
4114 * @param[in] pSrc points to the block of input data.
4115 * @param[in] pRef points to the block of reference data.
4116 * @param[out] pOut points to the block of output data.
4117 * @param[out] pErr points to the block of error data.
4118 * @param[in] blockSize number of samples to process.
4119 */
4120 void arm_lms_q15(
4121 const arm_lms_instance_q15 * S,
4122 q15_t * pSrc,
4123 q15_t * pRef,
4124 q15_t * pOut,
4125 q15_t * pErr,
4126 uint32_t blockSize);
4127
4128
4129 /**
4130 * @brief Instance structure for the Q31 LMS filter.
4131 */
4132 typedef struct
4133 {
4134 uint16_t numTaps; /**< number of coefficients in the filter. */
4135 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4136 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4137 q31_t mu; /**< step size that controls filter coefficient updates. */
4138 uint32_t postShift; /**< bit shift applied to coefficients. */
4139 } arm_lms_instance_q31;
4140
4141
4142 /**
4143 * @brief Processing function for Q31 LMS filter.
4144 * @param[in] S points to an instance of the Q15 LMS filter structure.
4145 * @param[in] pSrc points to the block of input data.
4146 * @param[in] pRef points to the block of reference data.
4147 * @param[out] pOut points to the block of output data.
4148 * @param[out] pErr points to the block of error data.
4149 * @param[in] blockSize number of samples to process.
4150 */
4151 void arm_lms_q31(
4152 const arm_lms_instance_q31 * S,
4153 q31_t * pSrc,
4154 q31_t * pRef,
4155 q31_t * pOut,
4156 q31_t * pErr,
4157 uint32_t blockSize);
4158
4159
4160 /**
4161 * @brief Initialization function for Q31 LMS filter.
4162 * @param[in] S points to an instance of the Q31 LMS filter structure.
4163 * @param[in] numTaps number of filter coefficients.
4164 * @param[in] pCoeffs points to coefficient buffer.
4165 * @param[in] pState points to state buffer.
4166 * @param[in] mu step size that controls filter coefficient updates.
4167 * @param[in] blockSize number of samples to process.
4168 * @param[in] postShift bit shift applied to coefficients.
4169 */
4170 void arm_lms_init_q31(
4171 arm_lms_instance_q31 * S,
4172 uint16_t numTaps,
4173 q31_t * pCoeffs,
4174 q31_t * pState,
4175 q31_t mu,
4176 uint32_t blockSize,
4177 uint32_t postShift);
4178
4179
4180 /**
4181 * @brief Instance structure for the floating-point normalized LMS filter.
4182 */
4183 typedef struct
4184 {
4185 uint16_t numTaps; /**< number of coefficients in the filter. */
4186 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4187 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4188 float32_t mu; /**< step size that control filter coefficient updates. */
4189 float32_t energy; /**< saves previous frame energy. */
4190 float32_t x0; /**< saves previous input sample. */
4191 } arm_lms_norm_instance_f32;
4192
4193
4194 /**
4195 * @brief Processing function for floating-point normalized LMS filter.
4196 * @param[in] S points to an instance of the floating-point normalized LMS filter structure.
4197 * @param[in] pSrc points to the block of input data.
4198 * @param[in] pRef points to the block of reference data.
4199 * @param[out] pOut points to the block of output data.
4200 * @param[out] pErr points to the block of error data.
4201 * @param[in] blockSize number of samples to process.
4202 */
4203 void arm_lms_norm_f32(
4204 arm_lms_norm_instance_f32 * S,
4205 float32_t * pSrc,
4206 float32_t * pRef,
4207 float32_t * pOut,
4208 float32_t * pErr,
4209 uint32_t blockSize);
4210
4211
4212 /**
4213 * @brief Initialization function for floating-point normalized LMS filter.
4214 * @param[in] S points to an instance of the floating-point LMS filter structure.
4215 * @param[in] numTaps number of filter coefficients.
4216 * @param[in] pCoeffs points to coefficient buffer.
4217 * @param[in] pState points to state buffer.
4218 * @param[in] mu step size that controls filter coefficient updates.
4219 * @param[in] blockSize number of samples to process.
4220 */
4221 void arm_lms_norm_init_f32(
4222 arm_lms_norm_instance_f32 * S,
4223 uint16_t numTaps,
4224 float32_t * pCoeffs,
4225 float32_t * pState,
4226 float32_t mu,
4227 uint32_t blockSize);
4228
4229
4230 /**
4231 * @brief Instance structure for the Q31 normalized LMS filter.
4232 */
4233 typedef struct
4234 {
4235 uint16_t numTaps; /**< number of coefficients in the filter. */
4236 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4237 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4238 q31_t mu; /**< step size that controls filter coefficient updates. */
4239 uint8_t postShift; /**< bit shift applied to coefficients. */
4240 q31_t *recipTable; /**< points to the reciprocal initial value table. */
4241 q31_t energy; /**< saves previous frame energy. */
4242 q31_t x0; /**< saves previous input sample. */
4243 } arm_lms_norm_instance_q31;
4244
4245
4246 /**
4247 * @brief Processing function for Q31 normalized LMS filter.
4248 * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
4249 * @param[in] pSrc points to the block of input data.
4250 * @param[in] pRef points to the block of reference data.
4251 * @param[out] pOut points to the block of output data.
4252 * @param[out] pErr points to the block of error data.
4253 * @param[in] blockSize number of samples to process.
4254 */
4255 void arm_lms_norm_q31(
4256 arm_lms_norm_instance_q31 * S,
4257 q31_t * pSrc,
4258 q31_t * pRef,
4259 q31_t * pOut,
4260 q31_t * pErr,
4261 uint32_t blockSize);
4262
4263
4264 /**
4265 * @brief Initialization function for Q31 normalized LMS filter.
4266 * @param[in] S points to an instance of the Q31 normalized LMS filter structure.
4267 * @param[in] numTaps number of filter coefficients.
4268 * @param[in] pCoeffs points to coefficient buffer.
4269 * @param[in] pState points to state buffer.
4270 * @param[in] mu step size that controls filter coefficient updates.
4271 * @param[in] blockSize number of samples to process.
4272 * @param[in] postShift bit shift applied to coefficients.
4273 */
4274 void arm_lms_norm_init_q31(
4275 arm_lms_norm_instance_q31 * S,
4276 uint16_t numTaps,
4277 q31_t * pCoeffs,
4278 q31_t * pState,
4279 q31_t mu,
4280 uint32_t blockSize,
4281 uint8_t postShift);
4282
4283
4284 /**
4285 * @brief Instance structure for the Q15 normalized LMS filter.
4286 */
4287 typedef struct
4288 {
4289 uint16_t numTaps; /**< Number of coefficients in the filter. */
4290 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
4291 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
4292 q15_t mu; /**< step size that controls filter coefficient updates. */
4293 uint8_t postShift; /**< bit shift applied to coefficients. */
4294 q15_t *recipTable; /**< Points to the reciprocal initial value table. */
4295 q15_t energy; /**< saves previous frame energy. */
4296 q15_t x0; /**< saves previous input sample. */
4297 } arm_lms_norm_instance_q15;
4298
4299
4300 /**
4301 * @brief Processing function for Q15 normalized LMS filter.
4302 * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
4303 * @param[in] pSrc points to the block of input data.
4304 * @param[in] pRef points to the block of reference data.
4305 * @param[out] pOut points to the block of output data.
4306 * @param[out] pErr points to the block of error data.
4307 * @param[in] blockSize number of samples to process.
4308 */
4309 void arm_lms_norm_q15(
4310 arm_lms_norm_instance_q15 * S,
4311 q15_t * pSrc,
4312 q15_t * pRef,
4313 q15_t * pOut,
4314 q15_t * pErr,
4315 uint32_t blockSize);
4316
4317
4318 /**
4319 * @brief Initialization function for Q15 normalized LMS filter.
4320 * @param[in] S points to an instance of the Q15 normalized LMS filter structure.
4321 * @param[in] numTaps number of filter coefficients.
4322 * @param[in] pCoeffs points to coefficient buffer.
4323 * @param[in] pState points to state buffer.
4324 * @param[in] mu step size that controls filter coefficient updates.
4325 * @param[in] blockSize number of samples to process.
4326 * @param[in] postShift bit shift applied to coefficients.
4327 */
4328 void arm_lms_norm_init_q15(
4329 arm_lms_norm_instance_q15 * S,
4330 uint16_t numTaps,
4331 q15_t * pCoeffs,
4332 q15_t * pState,
4333 q15_t mu,
4334 uint32_t blockSize,
4335 uint8_t postShift);
4336
4337
4338 /**
4339 * @brief Correlation of floating-point sequences.
4340 * @param[in] pSrcA points to the first input sequence.
4341 * @param[in] srcALen length of the first input sequence.
4342 * @param[in] pSrcB points to the second input sequence.
4343 * @param[in] srcBLen length of the second input sequence.
4344 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4345 */
4346 void arm_correlate_f32(
4347 float32_t * pSrcA,
4348 uint32_t srcALen,
4349 float32_t * pSrcB,
4350 uint32_t srcBLen,
4351 float32_t * pDst);
4352
4353
4354 /**
4355 * @brief Correlation of Q15 sequences
4356 * @param[in] pSrcA points to the first input sequence.
4357 * @param[in] srcALen length of the first input sequence.
4358 * @param[in] pSrcB points to the second input sequence.
4359 * @param[in] srcBLen length of the second input sequence.
4360 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4361 * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4362 */
4363 void arm_correlate_opt_q15(
4364 q15_t * pSrcA,
4365 uint32_t srcALen,
4366 q15_t * pSrcB,
4367 uint32_t srcBLen,
4368 q15_t * pDst,
4369 q15_t * pScratch);
4370
4371
4372 /**
4373 * @brief Correlation of Q15 sequences.
4374 * @param[in] pSrcA points to the first input sequence.
4375 * @param[in] srcALen length of the first input sequence.
4376 * @param[in] pSrcB points to the second input sequence.
4377 * @param[in] srcBLen length of the second input sequence.
4378 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4379 */
4380
4381 void arm_correlate_q15(
4382 q15_t * pSrcA,
4383 uint32_t srcALen,
4384 q15_t * pSrcB,
4385 uint32_t srcBLen,
4386 q15_t * pDst);
4387
4388
4389 /**
4390 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4391 * @param[in] pSrcA points to the first input sequence.
4392 * @param[in] srcALen length of the first input sequence.
4393 * @param[in] pSrcB points to the second input sequence.
4394 * @param[in] srcBLen length of the second input sequence.
4395 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4396 */
4397
4398 void arm_correlate_fast_q15(
4399 q15_t * pSrcA,
4400 uint32_t srcALen,
4401 q15_t * pSrcB,
4402 uint32_t srcBLen,
4403 q15_t * pDst);
4404
4405
4406 /**
4407 * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
4408 * @param[in] pSrcA points to the first input sequence.
4409 * @param[in] srcALen length of the first input sequence.
4410 * @param[in] pSrcB points to the second input sequence.
4411 * @param[in] srcBLen length of the second input sequence.
4412 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4413 * @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4414 */
4415 void arm_correlate_fast_opt_q15(
4416 q15_t * pSrcA,
4417 uint32_t srcALen,
4418 q15_t * pSrcB,
4419 uint32_t srcBLen,
4420 q15_t * pDst,
4421 q15_t * pScratch);
4422
4423
4424 /**
4425 * @brief Correlation of Q31 sequences.
4426 * @param[in] pSrcA points to the first input sequence.
4427 * @param[in] srcALen length of the first input sequence.
4428 * @param[in] pSrcB points to the second input sequence.
4429 * @param[in] srcBLen length of the second input sequence.
4430 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4431 */
4432 void arm_correlate_q31(
4433 q31_t * pSrcA,
4434 uint32_t srcALen,
4435 q31_t * pSrcB,
4436 uint32_t srcBLen,
4437 q31_t * pDst);
4438
4439
4440 /**
4441 * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
4442 * @param[in] pSrcA points to the first input sequence.
4443 * @param[in] srcALen length of the first input sequence.
4444 * @param[in] pSrcB points to the second input sequence.
4445 * @param[in] srcBLen length of the second input sequence.
4446 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4447 */
4448 void arm_correlate_fast_q31(
4449 q31_t * pSrcA,
4450 uint32_t srcALen,
4451 q31_t * pSrcB,
4452 uint32_t srcBLen,
4453 q31_t * pDst);
4454
4455
4456 /**
4457 * @brief Correlation of Q7 sequences.
4458 * @param[in] pSrcA points to the first input sequence.
4459 * @param[in] srcALen length of the first input sequence.
4460 * @param[in] pSrcB points to the second input sequence.
4461 * @param[in] srcBLen length of the second input sequence.
4462 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4463 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
4464 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
4465 */
4466 void arm_correlate_opt_q7(
4467 q7_t * pSrcA,
4468 uint32_t srcALen,
4469 q7_t * pSrcB,
4470 uint32_t srcBLen,
4471 q7_t * pDst,
4472 q15_t * pScratch1,
4473 q15_t * pScratch2);
4474
4475
4476 /**
4477 * @brief Correlation of Q7 sequences.
4478 * @param[in] pSrcA points to the first input sequence.
4479 * @param[in] srcALen length of the first input sequence.
4480 * @param[in] pSrcB points to the second input sequence.
4481 * @param[in] srcBLen length of the second input sequence.
4482 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
4483 */
4484 void arm_correlate_q7(
4485 q7_t * pSrcA,
4486 uint32_t srcALen,
4487 q7_t * pSrcB,
4488 uint32_t srcBLen,
4489 q7_t * pDst);
4490
4491
4492 /**
4493 * @brief Instance structure for the floating-point sparse FIR filter.
4494 */
4495 typedef struct
4496 {
4497 uint16_t numTaps; /**< number of coefficients in the filter. */
4498 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4499 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4500 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4501 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4502 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4503 } arm_fir_sparse_instance_f32;
4504
4505 /**
4506 * @brief Instance structure for the Q31 sparse FIR filter.
4507 */
4508 typedef struct
4509 {
4510 uint16_t numTaps; /**< number of coefficients in the filter. */
4511 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4512 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4513 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4514 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4515 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4516 } arm_fir_sparse_instance_q31;
4517
4518 /**
4519 * @brief Instance structure for the Q15 sparse FIR filter.
4520 */
4521 typedef struct
4522 {
4523 uint16_t numTaps; /**< number of coefficients in the filter. */
4524 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4525 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4526 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4527 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4528 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4529 } arm_fir_sparse_instance_q15;
4530
4531 /**
4532 * @brief Instance structure for the Q7 sparse FIR filter.
4533 */
4534 typedef struct
4535 {
4536 uint16_t numTaps; /**< number of coefficients in the filter. */
4537 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
4538 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
4539 q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
4540 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
4541 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
4542 } arm_fir_sparse_instance_q7;
4543
4544
4545 /**
4546 * @brief Processing function for the floating-point sparse FIR filter.
4547 * @param[in] S points to an instance of the floating-point sparse FIR structure.
4548 * @param[in] pSrc points to the block of input data.
4549 * @param[out] pDst points to the block of output data
4550 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4551 * @param[in] blockSize number of input samples to process per call.
4552 */
4553 void arm_fir_sparse_f32(
4554 arm_fir_sparse_instance_f32 * S,
4555 float32_t * pSrc,
4556 float32_t * pDst,
4557 float32_t * pScratchIn,
4558 uint32_t blockSize);
4559
4560
4561 /**
4562 * @brief Initialization function for the floating-point sparse FIR filter.
4563 * @param[in,out] S points to an instance of the floating-point sparse FIR structure.
4564 * @param[in] numTaps number of nonzero coefficients in the filter.
4565 * @param[in] pCoeffs points to the array of filter coefficients.
4566 * @param[in] pState points to the state buffer.
4567 * @param[in] pTapDelay points to the array of offset times.
4568 * @param[in] maxDelay maximum offset time supported.
4569 * @param[in] blockSize number of samples that will be processed per block.
4570 */
4571 void arm_fir_sparse_init_f32(
4572 arm_fir_sparse_instance_f32 * S,
4573 uint16_t numTaps,
4574 float32_t * pCoeffs,
4575 float32_t * pState,
4576 int32_t * pTapDelay,
4577 uint16_t maxDelay,
4578 uint32_t blockSize);
4579
4580
4581 /**
4582 * @brief Processing function for the Q31 sparse FIR filter.
4583 * @param[in] S points to an instance of the Q31 sparse FIR structure.
4584 * @param[in] pSrc points to the block of input data.
4585 * @param[out] pDst points to the block of output data
4586 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4587 * @param[in] blockSize number of input samples to process per call.
4588 */
4589 void arm_fir_sparse_q31(
4590 arm_fir_sparse_instance_q31 * S,
4591 q31_t * pSrc,
4592 q31_t * pDst,
4593 q31_t * pScratchIn,
4594 uint32_t blockSize);
4595
4596
4597 /**
4598 * @brief Initialization function for the Q31 sparse FIR filter.
4599 * @param[in,out] S points to an instance of the Q31 sparse FIR structure.
4600 * @param[in] numTaps number of nonzero coefficients in the filter.
4601 * @param[in] pCoeffs points to the array of filter coefficients.
4602 * @param[in] pState points to the state buffer.
4603 * @param[in] pTapDelay points to the array of offset times.
4604 * @param[in] maxDelay maximum offset time supported.
4605 * @param[in] blockSize number of samples that will be processed per block.
4606 */
4607 void arm_fir_sparse_init_q31(
4608 arm_fir_sparse_instance_q31 * S,
4609 uint16_t numTaps,
4610 q31_t * pCoeffs,
4611 q31_t * pState,
4612 int32_t * pTapDelay,
4613 uint16_t maxDelay,
4614 uint32_t blockSize);
4615
4616
4617 /**
4618 * @brief Processing function for the Q15 sparse FIR filter.
4619 * @param[in] S points to an instance of the Q15 sparse FIR structure.
4620 * @param[in] pSrc points to the block of input data.
4621 * @param[out] pDst points to the block of output data
4622 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4623 * @param[in] pScratchOut points to a temporary buffer of size blockSize.
4624 * @param[in] blockSize number of input samples to process per call.
4625 */
4626 void arm_fir_sparse_q15(
4627 arm_fir_sparse_instance_q15 * S,
4628 q15_t * pSrc,
4629 q15_t * pDst,
4630 q15_t * pScratchIn,
4631 q31_t * pScratchOut,
4632 uint32_t blockSize);
4633
4634
4635 /**
4636 * @brief Initialization function for the Q15 sparse FIR filter.
4637 * @param[in,out] S points to an instance of the Q15 sparse FIR structure.
4638 * @param[in] numTaps number of nonzero coefficients in the filter.
4639 * @param[in] pCoeffs points to the array of filter coefficients.
4640 * @param[in] pState points to the state buffer.
4641 * @param[in] pTapDelay points to the array of offset times.
4642 * @param[in] maxDelay maximum offset time supported.
4643 * @param[in] blockSize number of samples that will be processed per block.
4644 */
4645 void arm_fir_sparse_init_q15(
4646 arm_fir_sparse_instance_q15 * S,
4647 uint16_t numTaps,
4648 q15_t * pCoeffs,
4649 q15_t * pState,
4650 int32_t * pTapDelay,
4651 uint16_t maxDelay,
4652 uint32_t blockSize);
4653
4654
4655 /**
4656 * @brief Processing function for the Q7 sparse FIR filter.
4657 * @param[in] S points to an instance of the Q7 sparse FIR structure.
4658 * @param[in] pSrc points to the block of input data.
4659 * @param[out] pDst points to the block of output data
4660 * @param[in] pScratchIn points to a temporary buffer of size blockSize.
4661 * @param[in] pScratchOut points to a temporary buffer of size blockSize.
4662 * @param[in] blockSize number of input samples to process per call.
4663 */
4664 void arm_fir_sparse_q7(
4665 arm_fir_sparse_instance_q7 * S,
4666 q7_t * pSrc,
4667 q7_t * pDst,
4668 q7_t * pScratchIn,
4669 q31_t * pScratchOut,
4670 uint32_t blockSize);
4671
4672
4673 /**
4674 * @brief Initialization function for the Q7 sparse FIR filter.
4675 * @param[in,out] S points to an instance of the Q7 sparse FIR structure.
4676 * @param[in] numTaps number of nonzero coefficients in the filter.
4677 * @param[in] pCoeffs points to the array of filter coefficients.
4678 * @param[in] pState points to the state buffer.
4679 * @param[in] pTapDelay points to the array of offset times.
4680 * @param[in] maxDelay maximum offset time supported.
4681 * @param[in] blockSize number of samples that will be processed per block.
4682 */
4683 void arm_fir_sparse_init_q7(
4684 arm_fir_sparse_instance_q7 * S,
4685 uint16_t numTaps,
4686 q7_t * pCoeffs,
4687 q7_t * pState,
4688 int32_t * pTapDelay,
4689 uint16_t maxDelay,
4690 uint32_t blockSize);
4691
4692
4693 /**
4694 * @brief Floating-point sin_cos function.
4695 * @param[in] theta input value in degrees
4696 * @param[out] pSinVal points to the processed sine output.
4697 * @param[out] pCosVal points to the processed cos output.
4698 */
4699 void arm_sin_cos_f32(
4700 float32_t theta,
4701 float32_t * pSinVal,
4702 float32_t * pCosVal);
4703
4704
4705 /**
4706 * @brief Q31 sin_cos function.
4707 * @param[in] theta scaled input value in degrees
4708 * @param[out] pSinVal points to the processed sine output.
4709 * @param[out] pCosVal points to the processed cosine output.
4710 */
4711 void arm_sin_cos_q31(
4712 q31_t theta,
4713 q31_t * pSinVal,
4714 q31_t * pCosVal);
4715
4716
4717 /**
4718 * @brief Floating-point complex conjugate.
4719 * @param[in] pSrc points to the input vector
4720 * @param[out] pDst points to the output vector
4721 * @param[in] numSamples number of complex samples in each vector
4722 */
4723 void arm_cmplx_conj_f32(
4724 float32_t * pSrc,
4725 float32_t * pDst,
4726 uint32_t numSamples);
4727
4728 /**
4729 * @brief Q31 complex conjugate.
4730 * @param[in] pSrc points to the input vector
4731 * @param[out] pDst points to the output vector
4732 * @param[in] numSamples number of complex samples in each vector
4733 */
4734 void arm_cmplx_conj_q31(
4735 q31_t * pSrc,
4736 q31_t * pDst,
4737 uint32_t numSamples);
4738
4739
4740 /**
4741 * @brief Q15 complex conjugate.
4742 * @param[in] pSrc points to the input vector
4743 * @param[out] pDst points to the output vector
4744 * @param[in] numSamples number of complex samples in each vector
4745 */
4746 void arm_cmplx_conj_q15(
4747 q15_t * pSrc,
4748 q15_t * pDst,
4749 uint32_t numSamples);
4750
4751
4752 /**
4753 * @brief Floating-point complex magnitude squared
4754 * @param[in] pSrc points to the complex input vector
4755 * @param[out] pDst points to the real output vector
4756 * @param[in] numSamples number of complex samples in the input vector
4757 */
4758 void arm_cmplx_mag_squared_f32(
4759 float32_t * pSrc,
4760 float32_t * pDst,
4761 uint32_t numSamples);
4762
4763
4764 /**
4765 * @brief Q31 complex magnitude squared
4766 * @param[in] pSrc points to the complex input vector
4767 * @param[out] pDst points to the real output vector
4768 * @param[in] numSamples number of complex samples in the input vector
4769 */
4770 void arm_cmplx_mag_squared_q31(
4771 q31_t * pSrc,
4772 q31_t * pDst,
4773 uint32_t numSamples);
4774
4775
4776 /**
4777 * @brief Q15 complex magnitude squared
4778 * @param[in] pSrc points to the complex input vector
4779 * @param[out] pDst points to the real output vector
4780 * @param[in] numSamples number of complex samples in the input vector
4781 */
4782 void arm_cmplx_mag_squared_q15(
4783 q15_t * pSrc,
4784 q15_t * pDst,
4785 uint32_t numSamples);
4786
4787
4788 /**
4789 * @ingroup groupController
4790 */
4791
4792 /**
4793 * @defgroup PID PID Motor Control
4794 *
4795 * A Proportional Integral Derivative (PID) controller is a generic feedback control
4796 * loop mechanism widely used in industrial control systems.
4797 * A PID controller is the most commonly used type of feedback controller.
4798 *
4799 * This set of functions implements (PID) controllers
4800 * for Q15, Q31, and floating-point data types. The functions operate on a single sample
4801 * of data and each call to the function returns a single processed value.
4802 * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
4803 * is the input sample value. The functions return the output value.
4804 *
4805 * \par Algorithm:
4806 * <pre>
4807 * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
4808 * A0 = Kp + Ki + Kd
4809 * A1 = (-Kp ) - (2 * Kd )
4810 * A2 = Kd </pre>
4811 *
4812 * \par
4813 * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
4814 *
4815 * \par
4816 * \image html PID.gif "Proportional Integral Derivative Controller"
4817 *
4818 * \par
4819 * The PID controller calculates an "error" value as the difference between
4820 * the measured output and the reference input.
4821 * The controller attempts to minimize the error by adjusting the process control inputs.
4822 * The proportional value determines the reaction to the current error,
4823 * the integral value determines the reaction based on the sum of recent errors,
4824 * and the derivative value determines the reaction based on the rate at which the error has been changing.
4825 *
4826 * \par Instance Structure
4827 * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
4828 * A separate instance structure must be defined for each PID Controller.
4829 * There are separate instance structure declarations for each of the 3 supported data types.
4830 *
4831 * \par Reset Functions
4832 * There is also an associated reset function for each data type which clears the state array.
4833 *
4834 * \par Initialization Functions
4835 * There is also an associated initialization function for each data type.
4836 * The initialization function performs the following operations:
4837 * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
4838 * - Zeros out the values in the state buffer.
4839 *
4840 * \par
4841 * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
4842 *
4843 * \par Fixed-Point Behavior
4844 * Care must be taken when using the fixed-point versions of the PID Controller functions.
4845 * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
4846 * Refer to the function specific documentation below for usage guidelines.
4847 */
4848
4849 /**
4850 * @addtogroup PID
4851 * @{
4852 */
4853
4854 /**
4855 * @brief Process function for the floating-point PID Control.
4856 * @param[in,out] S is an instance of the floating-point PID Control structure
4857 * @param[in] in input sample to process
4858 * @return out processed output sample.
4859 */
4860 CMSIS_INLINE __STATIC_INLINE float32_t arm_pid_f32(
4861 arm_pid_instance_f32 * S,
4862 float32_t in)
4863 {
4864 float32_t out;
4865
4866 /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
4867 out = (S->A0 * in) +
4868 (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
4869
4870 /* Update state */
4871 S->state[1] = S->state[0];
4872 S->state[0] = in;
4873 S->state[2] = out;
4874
4875 /* return to application */
4876 return (out);
4877
4878 }
4879
4880 /**
4881 * @brief Process function for the Q31 PID Control.
4882 * @param[in,out] S points to an instance of the Q31 PID Control structure
4883 * @param[in] in input sample to process
4884 * @return out processed output sample.
4885 *
4886 * <b>Scaling and Overflow Behavior:</b>
4887 * \par
4888 * The function is implemented using an internal 64-bit accumulator.
4889 * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
4890 * Thus, if the accumulator result overflows it wraps around rather than clip.
4891 * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
4892 * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
4893 */
4894 CMSIS_INLINE __STATIC_INLINE q31_t arm_pid_q31(
4895 arm_pid_instance_q31 * S,
4896 q31_t in)
4897 {
4898 q63_t acc;
4899 q31_t out;
4900
4901 /* acc = A0 * x[n] */
4902 acc = (q63_t) S->A0 * in;
4903
4904 /* acc += A1 * x[n-1] */
4905 acc += (q63_t) S->A1 * S->state[0];
4906
4907 /* acc += A2 * x[n-2] */
4908 acc += (q63_t) S->A2 * S->state[1];
4909
4910 /* convert output to 1.31 format to add y[n-1] */
4911 out = (q31_t) (acc >> 31u);
4912
4913 /* out += y[n-1] */
4914 out += S->state[2];
4915
4916 /* Update state */
4917 S->state[1] = S->state[0];
4918 S->state[0] = in;
4919 S->state[2] = out;
4920
4921 /* return to application */
4922 return (out);
4923 }
4924
4925
4926 /**
4927 * @brief Process function for the Q15 PID Control.
4928 * @param[in,out] S points to an instance of the Q15 PID Control structure
4929 * @param[in] in input sample to process
4930 * @return out processed output sample.
4931 *
4932 * <b>Scaling and Overflow Behavior:</b>
4933 * \par
4934 * The function is implemented using a 64-bit internal accumulator.
4935 * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
4936 * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
4937 * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
4938 * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
4939 * Lastly, the accumulator is saturated to yield a result in 1.15 format.
4940 */
4941 CMSIS_INLINE __STATIC_INLINE q15_t arm_pid_q15(
4942 arm_pid_instance_q15 * S,
4943 q15_t in)
4944 {
4945 q63_t acc;
4946 q15_t out;
4947
4948#if defined (ARM_MATH_DSP)
4949 __SIMD32_TYPE *vstate;
4950
4951 /* Implementation of PID controller */
4952
4953 /* acc = A0 * x[n] */
4954 acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in);
4955
4956 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4957 vstate = __SIMD32_CONST(S->state);
4958 acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (uint64_t)acc);
4959#else
4960 /* acc = A0 * x[n] */
4961 acc = ((q31_t) S->A0) * in;
4962
4963 /* acc += A1 * x[n-1] + A2 * x[n-2] */
4964 acc += (q31_t) S->A1 * S->state[0];
4965 acc += (q31_t) S->A2 * S->state[1];
4966#endif
4967
4968 /* acc += y[n-1] */
4969 acc += (q31_t) S->state[2] << 15;
4970
4971 /* saturate the output */
4972 out = (q15_t) (__SSAT((acc >> 15), 16));
4973
4974 /* Update state */
4975 S->state[1] = S->state[0];
4976 S->state[0] = in;
4977 S->state[2] = out;
4978
4979 /* return to application */
4980 return (out);
4981 }
4982
4983 /**
4984 * @} end of PID group
4985 */
4986
4987
4988 /**
4989 * @brief Floating-point matrix inverse.
4990 * @param[in] src points to the instance of the input floating-point matrix structure.
4991 * @param[out] dst points to the instance of the output floating-point matrix structure.
4992 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
4993 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
4994 */
4995 arm_status arm_mat_inverse_f32(
4996 const arm_matrix_instance_f32 * src,
4997 arm_matrix_instance_f32 * dst);
4998
4999
5000 /**
5001 * @brief Floating-point matrix inverse.
5002 * @param[in] src points to the instance of the input floating-point matrix structure.
5003 * @param[out] dst points to the instance of the output floating-point matrix structure.
5004 * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
5005 * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
5006 */
5007 arm_status arm_mat_inverse_f64(
5008 const arm_matrix_instance_f64 * src,
5009 arm_matrix_instance_f64 * dst);
5010
5011
5012
5013 /**
5014 * @ingroup groupController
5015 */
5016
5017 /**
5018 * @defgroup clarke Vector Clarke Transform
5019 * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
5020 * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
5021 * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
5022 * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
5023 * \image html clarke.gif Stator current space vector and its components in (a,b).
5024 * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
5025 * can be calculated using only <code>Ia</code> and <code>Ib</code>.
5026 *
5027 * The function operates on a single sample of data and each call to the function returns the processed output.
5028 * The library provides separate functions for Q31 and floating-point data types.
5029 * \par Algorithm
5030 * \image html clarkeFormula.gif
5031 * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
5032 * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
5033 * \par Fixed-Point Behavior
5034 * Care must be taken when using the Q31 version of the Clarke transform.
5035 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5036 * Refer to the function specific documentation below for usage guidelines.
5037 */
5038
5039 /**
5040 * @addtogroup clarke
5041 * @{
5042 */
5043
5044 /**
5045 *
5046 * @brief Floating-point Clarke transform
5047 * @param[in] Ia input three-phase coordinate <code>a</code>
5048 * @param[in] Ib input three-phase coordinate <code>b</code>
5049 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5050 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5051 */
5052 CMSIS_INLINE __STATIC_INLINE void arm_clarke_f32(
5053 float32_t Ia,
5054 float32_t Ib,
5055 float32_t * pIalpha,
5056 float32_t * pIbeta)
5057 {
5058 /* Calculate pIalpha using the equation, pIalpha = Ia */
5059 *pIalpha = Ia;
5060
5061 /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
5062 *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
5063 }
5064
5065
5066 /**
5067 * @brief Clarke transform for Q31 version
5068 * @param[in] Ia input three-phase coordinate <code>a</code>
5069 * @param[in] Ib input three-phase coordinate <code>b</code>
5070 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5071 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5072 *
5073 * <b>Scaling and Overflow Behavior:</b>
5074 * \par
5075 * The function is implemented using an internal 32-bit accumulator.
5076 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5077 * There is saturation on the addition, hence there is no risk of overflow.
5078 */
5079 CMSIS_INLINE __STATIC_INLINE void arm_clarke_q31(
5080 q31_t Ia,
5081 q31_t Ib,
5082 q31_t * pIalpha,
5083 q31_t * pIbeta)
5084 {
5085 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5086
5087 /* Calculating pIalpha from Ia by equation pIalpha = Ia */
5088 *pIalpha = Ia;
5089
5090 /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
5091 product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
5092
5093 /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
5094 product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
5095
5096 /* pIbeta is calculated by adding the intermediate products */
5097 *pIbeta = __QADD(product1, product2);
5098 }
5099
5100 /**
5101 * @} end of clarke group
5102 */
5103
5104 /**
5105 * @brief Converts the elements of the Q7 vector to Q31 vector.
5106 * @param[in] pSrc input pointer
5107 * @param[out] pDst output pointer
5108 * @param[in] blockSize number of samples to process
5109 */
5110 void arm_q7_to_q31(
5111 q7_t * pSrc,
5112 q31_t * pDst,
5113 uint32_t blockSize);
5114
5115
5116
5117 /**
5118 * @ingroup groupController
5119 */
5120
5121 /**
5122 * @defgroup inv_clarke Vector Inverse Clarke Transform
5123 * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
5124 *
5125 * The function operates on a single sample of data and each call to the function returns the processed output.
5126 * The library provides separate functions for Q31 and floating-point data types.
5127 * \par Algorithm
5128 * \image html clarkeInvFormula.gif
5129 * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
5130 * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
5131 * \par Fixed-Point Behavior
5132 * Care must be taken when using the Q31 version of the Clarke transform.
5133 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5134 * Refer to the function specific documentation below for usage guidelines.
5135 */
5136
5137 /**
5138 * @addtogroup inv_clarke
5139 * @{
5140 */
5141
5142 /**
5143 * @brief Floating-point Inverse Clarke transform
5144 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5145 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5146 * @param[out] pIa points to output three-phase coordinate <code>a</code>
5147 * @param[out] pIb points to output three-phase coordinate <code>b</code>
5148 */
5149 CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_f32(
5150 float32_t Ialpha,
5151 float32_t Ibeta,
5152 float32_t * pIa,
5153 float32_t * pIb)
5154 {
5155 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5156 *pIa = Ialpha;
5157
5158 /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
5159 *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta;
5160 }
5161
5162
5163 /**
5164 * @brief Inverse Clarke transform for Q31 version
5165 * @param[in] Ialpha input two-phase orthogonal vector axis alpha
5166 * @param[in] Ibeta input two-phase orthogonal vector axis beta
5167 * @param[out] pIa points to output three-phase coordinate <code>a</code>
5168 * @param[out] pIb points to output three-phase coordinate <code>b</code>
5169 *
5170 * <b>Scaling and Overflow Behavior:</b>
5171 * \par
5172 * The function is implemented using an internal 32-bit accumulator.
5173 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5174 * There is saturation on the subtraction, hence there is no risk of overflow.
5175 */
5176 CMSIS_INLINE __STATIC_INLINE void arm_inv_clarke_q31(
5177 q31_t Ialpha,
5178 q31_t Ibeta,
5179 q31_t * pIa,
5180 q31_t * pIb)
5181 {
5182 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5183
5184 /* Calculating pIa from Ialpha by equation pIa = Ialpha */
5185 *pIa = Ialpha;
5186
5187 /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
5188 product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
5189
5190 /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
5191 product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
5192
5193 /* pIb is calculated by subtracting the products */
5194 *pIb = __QSUB(product2, product1);
5195 }
5196
5197 /**
5198 * @} end of inv_clarke group
5199 */
5200
5201 /**
5202 * @brief Converts the elements of the Q7 vector to Q15 vector.
5203 * @param[in] pSrc input pointer
5204 * @param[out] pDst output pointer
5205 * @param[in] blockSize number of samples to process
5206 */
5207 void arm_q7_to_q15(
5208 q7_t * pSrc,
5209 q15_t * pDst,
5210 uint32_t blockSize);
5211
5212
5213
5214 /**
5215 * @ingroup groupController
5216 */
5217
5218 /**
5219 * @defgroup park Vector Park Transform
5220 *
5221 * Forward Park transform converts the input two-coordinate vector to flux and torque components.
5222 * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
5223 * from the stationary to the moving reference frame and control the spatial relationship between
5224 * the stator vector current and rotor flux vector.
5225 * If we consider the d axis aligned with the rotor flux, the diagram below shows the
5226 * current vector and the relationship from the two reference frames:
5227 * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
5228 *
5229 * The function operates on a single sample of data and each call to the function returns the processed output.
5230 * The library provides separate functions for Q31 and floating-point data types.
5231 * \par Algorithm
5232 * \image html parkFormula.gif
5233 * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
5234 * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5235 * cosine and sine values of theta (rotor flux position).
5236 * \par Fixed-Point Behavior
5237 * Care must be taken when using the Q31 version of the Park transform.
5238 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5239 * Refer to the function specific documentation below for usage guidelines.
5240 */
5241
5242 /**
5243 * @addtogroup park
5244 * @{
5245 */
5246
5247 /**
5248 * @brief Floating-point Park transform
5249 * @param[in] Ialpha input two-phase vector coordinate alpha
5250 * @param[in] Ibeta input two-phase vector coordinate beta
5251 * @param[out] pId points to output rotor reference frame d
5252 * @param[out] pIq points to output rotor reference frame q
5253 * @param[in] sinVal sine value of rotation angle theta
5254 * @param[in] cosVal cosine value of rotation angle theta
5255 *
5256 * The function implements the forward Park transform.
5257 *
5258 */
5259 CMSIS_INLINE __STATIC_INLINE void arm_park_f32(
5260 float32_t Ialpha,
5261 float32_t Ibeta,
5262 float32_t * pId,
5263 float32_t * pIq,
5264 float32_t sinVal,
5265 float32_t cosVal)
5266 {
5267 /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
5268 *pId = Ialpha * cosVal + Ibeta * sinVal;
5269
5270 /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
5271 *pIq = -Ialpha * sinVal + Ibeta * cosVal;
5272 }
5273
5274
5275 /**
5276 * @brief Park transform for Q31 version
5277 * @param[in] Ialpha input two-phase vector coordinate alpha
5278 * @param[in] Ibeta input two-phase vector coordinate beta
5279 * @param[out] pId points to output rotor reference frame d
5280 * @param[out] pIq points to output rotor reference frame q
5281 * @param[in] sinVal sine value of rotation angle theta
5282 * @param[in] cosVal cosine value of rotation angle theta
5283 *
5284 * <b>Scaling and Overflow Behavior:</b>
5285 * \par
5286 * The function is implemented using an internal 32-bit accumulator.
5287 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5288 * There is saturation on the addition and subtraction, hence there is no risk of overflow.
5289 */
5290 CMSIS_INLINE __STATIC_INLINE void arm_park_q31(
5291 q31_t Ialpha,
5292 q31_t Ibeta,
5293 q31_t * pId,
5294 q31_t * pIq,
5295 q31_t sinVal,
5296 q31_t cosVal)
5297 {
5298 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5299 q31_t product3, product4; /* Temporary variables used to store intermediate results */
5300
5301 /* Intermediate product is calculated by (Ialpha * cosVal) */
5302 product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
5303
5304 /* Intermediate product is calculated by (Ibeta * sinVal) */
5305 product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
5306
5307
5308 /* Intermediate product is calculated by (Ialpha * sinVal) */
5309 product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
5310
5311 /* Intermediate product is calculated by (Ibeta * cosVal) */
5312 product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
5313
5314 /* Calculate pId by adding the two intermediate products 1 and 2 */
5315 *pId = __QADD(product1, product2);
5316
5317 /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
5318 *pIq = __QSUB(product4, product3);
5319 }
5320
5321 /**
5322 * @} end of park group
5323 */
5324
5325 /**
5326 * @brief Converts the elements of the Q7 vector to floating-point vector.
5327 * @param[in] pSrc is input pointer
5328 * @param[out] pDst is output pointer
5329 * @param[in] blockSize is the number of samples to process
5330 */
5331 void arm_q7_to_float(
5332 q7_t * pSrc,
5333 float32_t * pDst,
5334 uint32_t blockSize);
5335
5336
5337 /**
5338 * @ingroup groupController
5339 */
5340
5341 /**
5342 * @defgroup inv_park Vector Inverse Park transform
5343 * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
5344 *
5345 * The function operates on a single sample of data and each call to the function returns the processed output.
5346 * The library provides separate functions for Q31 and floating-point data types.
5347 * \par Algorithm
5348 * \image html parkInvFormula.gif
5349 * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
5350 * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
5351 * cosine and sine values of theta (rotor flux position).
5352 * \par Fixed-Point Behavior
5353 * Care must be taken when using the Q31 version of the Park transform.
5354 * In particular, the overflow and saturation behavior of the accumulator used must be considered.
5355 * Refer to the function specific documentation below for usage guidelines.
5356 */
5357
5358 /**
5359 * @addtogroup inv_park
5360 * @{
5361 */
5362
5363 /**
5364 * @brief Floating-point Inverse Park transform
5365 * @param[in] Id input coordinate of rotor reference frame d
5366 * @param[in] Iq input coordinate of rotor reference frame q
5367 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5368 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5369 * @param[in] sinVal sine value of rotation angle theta
5370 * @param[in] cosVal cosine value of rotation angle theta
5371 */
5372 CMSIS_INLINE __STATIC_INLINE void arm_inv_park_f32(
5373 float32_t Id,
5374 float32_t Iq,
5375 float32_t * pIalpha,
5376 float32_t * pIbeta,
5377 float32_t sinVal,
5378 float32_t cosVal)
5379 {
5380 /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
5381 *pIalpha = Id * cosVal - Iq * sinVal;
5382
5383 /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
5384 *pIbeta = Id * sinVal + Iq * cosVal;
5385 }
5386
5387
5388 /**
5389 * @brief Inverse Park transform for Q31 version
5390 * @param[in] Id input coordinate of rotor reference frame d
5391 * @param[in] Iq input coordinate of rotor reference frame q
5392 * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha
5393 * @param[out] pIbeta points to output two-phase orthogonal vector axis beta
5394 * @param[in] sinVal sine value of rotation angle theta
5395 * @param[in] cosVal cosine value of rotation angle theta
5396 *
5397 * <b>Scaling and Overflow Behavior:</b>
5398 * \par
5399 * The function is implemented using an internal 32-bit accumulator.
5400 * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
5401 * There is saturation on the addition, hence there is no risk of overflow.
5402 */
5403 CMSIS_INLINE __STATIC_INLINE void arm_inv_park_q31(
5404 q31_t Id,
5405 q31_t Iq,
5406 q31_t * pIalpha,
5407 q31_t * pIbeta,
5408 q31_t sinVal,
5409 q31_t cosVal)
5410 {
5411 q31_t product1, product2; /* Temporary variables used to store intermediate results */
5412 q31_t product3, product4; /* Temporary variables used to store intermediate results */
5413
5414 /* Intermediate product is calculated by (Id * cosVal) */
5415 product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
5416
5417 /* Intermediate product is calculated by (Iq * sinVal) */
5418 product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
5419
5420
5421 /* Intermediate product is calculated by (Id * sinVal) */
5422 product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
5423
5424 /* Intermediate product is calculated by (Iq * cosVal) */
5425 product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
5426
5427 /* Calculate pIalpha by using the two intermediate products 1 and 2 */
5428 *pIalpha = __QSUB(product1, product2);
5429
5430 /* Calculate pIbeta by using the two intermediate products 3 and 4 */
5431 *pIbeta = __QADD(product4, product3);
5432 }
5433
5434 /**
5435 * @} end of Inverse park group
5436 */
5437
5438
5439 /**
5440 * @brief Converts the elements of the Q31 vector to floating-point vector.
5441 * @param[in] pSrc is input pointer
5442 * @param[out] pDst is output pointer
5443 * @param[in] blockSize is the number of samples to process
5444 */
5445 void arm_q31_to_float(
5446 q31_t * pSrc,
5447 float32_t * pDst,
5448 uint32_t blockSize);
5449
5450 /**
5451 * @ingroup groupInterpolation
5452 */
5453
5454 /**
5455 * @defgroup LinearInterpolate Linear Interpolation
5456 *
5457 * Linear interpolation is a method of curve fitting using linear polynomials.
5458 * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
5459 *
5460 * \par
5461 * \image html LinearInterp.gif "Linear interpolation"
5462 *
5463 * \par
5464 * A Linear Interpolate function calculates an output value(y), for the input(x)
5465 * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
5466 *
5467 * \par Algorithm:
5468 * <pre>
5469 * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
5470 * where x0, x1 are nearest values of input x
5471 * y0, y1 are nearest values to output y
5472 * </pre>
5473 *
5474 * \par
5475 * This set of functions implements Linear interpolation process
5476 * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
5477 * sample of data and each call to the function returns a single processed value.
5478 * <code>S</code> points to an instance of the Linear Interpolate function data structure.
5479 * <code>x</code> is the input sample value. The functions returns the output value.
5480 *
5481 * \par
5482 * if x is outside of the table boundary, Linear interpolation returns first value of the table
5483 * if x is below input range and returns last value of table if x is above range.
5484 */
5485
5486 /**
5487 * @addtogroup LinearInterpolate
5488 * @{
5489 */
5490
5491 /**
5492 * @brief Process function for the floating-point Linear Interpolation Function.
5493 * @param[in,out] S is an instance of the floating-point Linear Interpolation structure
5494 * @param[in] x input sample to process
5495 * @return y processed output sample.
5496 *
5497 */
5498 CMSIS_INLINE __STATIC_INLINE float32_t arm_linear_interp_f32(
5499 arm_linear_interp_instance_f32 * S,
5500 float32_t x)
5501 {
5502 float32_t y;
5503 float32_t x0, x1; /* Nearest input values */
5504 float32_t y0, y1; /* Nearest output values */
5505 float32_t xSpacing = S->xSpacing; /* spacing between input values */
5506 int32_t i; /* Index variable */
5507 float32_t *pYData = S->pYData; /* pointer to output table */
5508
5509 /* Calculation of index */
5510 i = (int32_t) ((x - S->x1) / xSpacing);
5511
5512 if (i < 0)
5513 {
5514 /* Iniatilize output for below specified range as least output value of table */
5515 y = pYData[0];
5516 }
5517 else if ((uint32_t)i >= S->nValues)
5518 {
5519 /* Iniatilize output for above specified range as last output value of table */
5520 y = pYData[S->nValues - 1];
5521 }
5522 else
5523 {
5524 /* Calculation of nearest input values */
5525 x0 = S->x1 + i * xSpacing;
5526 x1 = S->x1 + (i + 1) * xSpacing;
5527
5528 /* Read of nearest output values */
5529 y0 = pYData[i];
5530 y1 = pYData[i + 1];
5531
5532 /* Calculation of output */
5533 y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
5534
5535 }
5536
5537 /* returns output value */
5538 return (y);
5539 }
5540
5541
5542 /**
5543 *
5544 * @brief Process function for the Q31 Linear Interpolation Function.
5545 * @param[in] pYData pointer to Q31 Linear Interpolation table
5546 * @param[in] x input sample to process
5547 * @param[in] nValues number of table values
5548 * @return y processed output sample.
5549 *
5550 * \par
5551 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5552 * This function can support maximum of table size 2^12.
5553 *
5554 */
5555 CMSIS_INLINE __STATIC_INLINE q31_t arm_linear_interp_q31(
5556 q31_t * pYData,
5557 q31_t x,
5558 uint32_t nValues)
5559 {
5560 q31_t y; /* output */
5561 q31_t y0, y1; /* Nearest output values */
5562 q31_t fract; /* fractional part */
5563 int32_t index; /* Index to read nearest output values */
5564
5565 /* Input is in 12.20 format */
5566 /* 12 bits for the table index */
5567 /* Index value calculation */
5568 index = ((x & (q31_t)0xFFF00000) >> 20);
5569
5570 if (index >= (int32_t)(nValues - 1))
5571 {
5572 return (pYData[nValues - 1]);
5573 }
5574 else if (index < 0)
5575 {
5576 return (pYData[0]);
5577 }
5578 else
5579 {
5580 /* 20 bits for the fractional part */
5581 /* shift left by 11 to keep fract in 1.31 format */
5582 fract = (x & 0x000FFFFF) << 11;
5583
5584 /* Read two nearest output values from the index in 1.31(q31) format */
5585 y0 = pYData[index];
5586 y1 = pYData[index + 1];
5587
5588 /* Calculation of y0 * (1-fract) and y is in 2.30 format */
5589 y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
5590
5591 /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
5592 y += ((q31_t) (((q63_t) y1 * fract) >> 32));
5593
5594 /* Convert y to 1.31 format */
5595 return (y << 1u);
5596 }
5597 }
5598
5599
5600 /**
5601 *
5602 * @brief Process function for the Q15 Linear Interpolation Function.
5603 * @param[in] pYData pointer to Q15 Linear Interpolation table
5604 * @param[in] x input sample to process
5605 * @param[in] nValues number of table values
5606 * @return y processed output sample.
5607 *
5608 * \par
5609 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5610 * This function can support maximum of table size 2^12.
5611 *
5612 */
5613 CMSIS_INLINE __STATIC_INLINE q15_t arm_linear_interp_q15(
5614 q15_t * pYData,
5615 q31_t x,
5616 uint32_t nValues)
5617 {
5618 q63_t y; /* output */
5619 q15_t y0, y1; /* Nearest output values */
5620 q31_t fract; /* fractional part */
5621 int32_t index; /* Index to read nearest output values */
5622
5623 /* Input is in 12.20 format */
5624 /* 12 bits for the table index */
5625 /* Index value calculation */
5626 index = ((x & (int32_t)0xFFF00000) >> 20);
5627
5628 if (index >= (int32_t)(nValues - 1))
5629 {
5630 return (pYData[nValues - 1]);
5631 }
5632 else if (index < 0)
5633 {
5634 return (pYData[0]);
5635 }
5636 else
5637 {
5638 /* 20 bits for the fractional part */
5639 /* fract is in 12.20 format */
5640 fract = (x & 0x000FFFFF);
5641
5642 /* Read two nearest output values from the index */
5643 y0 = pYData[index];
5644 y1 = pYData[index + 1];
5645
5646 /* Calculation of y0 * (1-fract) and y is in 13.35 format */
5647 y = ((q63_t) y0 * (0xFFFFF - fract));
5648
5649 /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
5650 y += ((q63_t) y1 * (fract));
5651
5652 /* convert y to 1.15 format */
5653 return (q15_t) (y >> 20);
5654 }
5655 }
5656
5657
5658 /**
5659 *
5660 * @brief Process function for the Q7 Linear Interpolation Function.
5661 * @param[in] pYData pointer to Q7 Linear Interpolation table
5662 * @param[in] x input sample to process
5663 * @param[in] nValues number of table values
5664 * @return y processed output sample.
5665 *
5666 * \par
5667 * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
5668 * This function can support maximum of table size 2^12.
5669 */
5670 CMSIS_INLINE __STATIC_INLINE q7_t arm_linear_interp_q7(
5671 q7_t * pYData,
5672 q31_t x,
5673 uint32_t nValues)
5674 {
5675 q31_t y; /* output */
5676 q7_t y0, y1; /* Nearest output values */
5677 q31_t fract; /* fractional part */
5678 uint32_t index; /* Index to read nearest output values */
5679
5680 /* Input is in 12.20 format */
5681 /* 12 bits for the table index */
5682 /* Index value calculation */
5683 if (x < 0)
5684 {
5685 return (pYData[0]);
5686 }
5687 index = (x >> 20) & 0xfff;
5688
5689 if (index >= (nValues - 1))
5690 {
5691 return (pYData[nValues - 1]);
5692 }
5693 else
5694 {
5695 /* 20 bits for the fractional part */
5696 /* fract is in 12.20 format */
5697 fract = (x & 0x000FFFFF);
5698
5699 /* Read two nearest output values from the index and are in 1.7(q7) format */
5700 y0 = pYData[index];
5701 y1 = pYData[index + 1];
5702
5703 /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
5704 y = ((y0 * (0xFFFFF - fract)));
5705
5706 /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
5707 y += (y1 * fract);
5708
5709 /* convert y to 1.7(q7) format */
5710 return (q7_t) (y >> 20);
5711 }
5712 }
5713
5714 /**
5715 * @} end of LinearInterpolate group
5716 */
5717
5718 /**
5719 * @brief Fast approximation to the trigonometric sine function for floating-point data.
5720 * @param[in] x input value in radians.
5721 * @return sin(x).
5722 */
5723 float32_t arm_sin_f32(
5724 float32_t x);
5725
5726
5727 /**
5728 * @brief Fast approximation to the trigonometric sine function for Q31 data.
5729 * @param[in] x Scaled input value in radians.
5730 * @return sin(x).
5731 */
5732 q31_t arm_sin_q31(
5733 q31_t x);
5734
5735
5736 /**
5737 * @brief Fast approximation to the trigonometric sine function for Q15 data.
5738 * @param[in] x Scaled input value in radians.
5739 * @return sin(x).
5740 */
5741 q15_t arm_sin_q15(
5742 q15_t x);
5743
5744
5745 /**
5746 * @brief Fast approximation to the trigonometric cosine function for floating-point data.
5747 * @param[in] x input value in radians.
5748 * @return cos(x).
5749 */
5750 float32_t arm_cos_f32(
5751 float32_t x);
5752
5753
5754 /**
5755 * @brief Fast approximation to the trigonometric cosine function for Q31 data.
5756 * @param[in] x Scaled input value in radians.
5757 * @return cos(x).
5758 */
5759 q31_t arm_cos_q31(
5760 q31_t x);
5761
5762
5763 /**
5764 * @brief Fast approximation to the trigonometric cosine function for Q15 data.
5765 * @param[in] x Scaled input value in radians.
5766 * @return cos(x).
5767 */
5768 q15_t arm_cos_q15(
5769 q15_t x);
5770
5771
5772 /**
5773 * @ingroup groupFastMath
5774 */
5775
5776
5777 /**
5778 * @defgroup SQRT Square Root
5779 *
5780 * Computes the square root of a number.
5781 * There are separate functions for Q15, Q31, and floating-point data types.
5782 * The square root function is computed using the Newton-Raphson algorithm.
5783 * This is an iterative algorithm of the form:
5784 * <pre>
5785 * x1 = x0 - f(x0)/f'(x0)
5786 * </pre>
5787 * where <code>x1</code> is the current estimate,
5788 * <code>x0</code> is the previous estimate, and
5789 * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
5790 * For the square root function, the algorithm reduces to:
5791 * <pre>
5792 * x0 = in/2 [initial guess]
5793 * x1 = 1/2 * ( x0 + in / x0) [each iteration]
5794 * </pre>
5795 */
5796
5797
5798 /**
5799 * @addtogroup SQRT
5800 * @{
5801 */
5802
5803 /**
5804 * @brief Floating-point square root function.
5805 * @param[in] in input value.
5806 * @param[out] pOut square root of input value.
5807 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5808 * <code>in</code> is negative value and returns zero output for negative values.
5809 */
5810 CMSIS_INLINE __STATIC_INLINE arm_status arm_sqrt_f32(
5811 float32_t in,
5812 float32_t * pOut)
5813 {
5814 if (in >= 0.0f)
5815 {
5816
5817#if (__FPU_USED == 1) && defined ( __CC_ARM )
5818 *pOut = __sqrtf(in);
5819#elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050))
5820 *pOut = __builtin_sqrtf(in);
5821#elif (__FPU_USED == 1) && defined(__GNUC__)
5822 *pOut = __builtin_sqrtf(in);
5823#elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000)
5824 __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in));
5825#else
5826 *pOut = sqrtf(in);
5827#endif
5828
5829 return (ARM_MATH_SUCCESS);
5830 }
5831 else
5832 {
5833 *pOut = 0.0f;
5834 return (ARM_MATH_ARGUMENT_ERROR);
5835 }
5836 }
5837
5838
5839 /**
5840 * @brief Q31 square root function.
5841 * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
5842 * @param[out] pOut square root of input value.
5843 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5844 * <code>in</code> is negative value and returns zero output for negative values.
5845 */
5846 arm_status arm_sqrt_q31(
5847 q31_t in,
5848 q31_t * pOut);
5849
5850
5851 /**
5852 * @brief Q15 square root function.
5853 * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
5854 * @param[out] pOut square root of input value.
5855 * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
5856 * <code>in</code> is negative value and returns zero output for negative values.
5857 */
5858 arm_status arm_sqrt_q15(
5859 q15_t in,
5860 q15_t * pOut);
5861
5862 /**
5863 * @} end of SQRT group
5864 */
5865
5866
5867 /**
5868 * @brief floating-point Circular write function.
5869 */
5870 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_f32(
5871 int32_t * circBuffer,
5872 int32_t L,
5873 uint16_t * writeOffset,
5874 int32_t bufferInc,
5875 const int32_t * src,
5876 int32_t srcInc,
5877 uint32_t blockSize)
5878 {
5879 uint32_t i = 0u;
5880 int32_t wOffset;
5881
5882 /* Copy the value of Index pointer that points
5883 * to the current location where the input samples to be copied */
5884 wOffset = *writeOffset;
5885
5886 /* Loop over the blockSize */
5887 i = blockSize;
5888
5889 while (i > 0u)
5890 {
5891 /* copy the input sample to the circular buffer */
5892 circBuffer[wOffset] = *src;
5893
5894 /* Update the input pointer */
5895 src += srcInc;
5896
5897 /* Circularly update wOffset. Watch out for positive and negative value */
5898 wOffset += bufferInc;
5899 if (wOffset >= L)
5900 wOffset -= L;
5901
5902 /* Decrement the loop counter */
5903 i--;
5904 }
5905
5906 /* Update the index pointer */
5907 *writeOffset = (uint16_t)wOffset;
5908 }
5909
5910
5911
5912 /**
5913 * @brief floating-point Circular Read function.
5914 */
5915 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_f32(
5916 int32_t * circBuffer,
5917 int32_t L,
5918 int32_t * readOffset,
5919 int32_t bufferInc,
5920 int32_t * dst,
5921 int32_t * dst_base,
5922 int32_t dst_length,
5923 int32_t dstInc,
5924 uint32_t blockSize)
5925 {
5926 uint32_t i = 0u;
5927 int32_t rOffset, dst_end;
5928
5929 /* Copy the value of Index pointer that points
5930 * to the current location from where the input samples to be read */
5931 rOffset = *readOffset;
5932 dst_end = (int32_t) (dst_base + dst_length);
5933
5934 /* Loop over the blockSize */
5935 i = blockSize;
5936
5937 while (i > 0u)
5938 {
5939 /* copy the sample from the circular buffer to the destination buffer */
5940 *dst = circBuffer[rOffset];
5941
5942 /* Update the input pointer */
5943 dst += dstInc;
5944
5945 if (dst == (int32_t *) dst_end)
5946 {
5947 dst = dst_base;
5948 }
5949
5950 /* Circularly update rOffset. Watch out for positive and negative value */
5951 rOffset += bufferInc;
5952
5953 if (rOffset >= L)
5954 {
5955 rOffset -= L;
5956 }
5957
5958 /* Decrement the loop counter */
5959 i--;
5960 }
5961
5962 /* Update the index pointer */
5963 *readOffset = rOffset;
5964 }
5965
5966
5967 /**
5968 * @brief Q15 Circular write function.
5969 */
5970 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q15(
5971 q15_t * circBuffer,
5972 int32_t L,
5973 uint16_t * writeOffset,
5974 int32_t bufferInc,
5975 const q15_t * src,
5976 int32_t srcInc,
5977 uint32_t blockSize)
5978 {
5979 uint32_t i = 0u;
5980 int32_t wOffset;
5981
5982 /* Copy the value of Index pointer that points
5983 * to the current location where the input samples to be copied */
5984 wOffset = *writeOffset;
5985
5986 /* Loop over the blockSize */
5987 i = blockSize;
5988
5989 while (i > 0u)
5990 {
5991 /* copy the input sample to the circular buffer */
5992 circBuffer[wOffset] = *src;
5993
5994 /* Update the input pointer */
5995 src += srcInc;
5996
5997 /* Circularly update wOffset. Watch out for positive and negative value */
5998 wOffset += bufferInc;
5999 if (wOffset >= L)
6000 wOffset -= L;
6001
6002 /* Decrement the loop counter */
6003 i--;
6004 }
6005
6006 /* Update the index pointer */
6007 *writeOffset = (uint16_t)wOffset;
6008 }
6009
6010
6011 /**
6012 * @brief Q15 Circular Read function.
6013 */
6014 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q15(
6015 q15_t * circBuffer,
6016 int32_t L,
6017 int32_t * readOffset,
6018 int32_t bufferInc,
6019 q15_t * dst,
6020 q15_t * dst_base,
6021 int32_t dst_length,
6022 int32_t dstInc,
6023 uint32_t blockSize)
6024 {
6025 uint32_t i = 0;
6026 int32_t rOffset, dst_end;
6027
6028 /* Copy the value of Index pointer that points
6029 * to the current location from where the input samples to be read */
6030 rOffset = *readOffset;
6031
6032 dst_end = (int32_t) (dst_base + dst_length);
6033
6034 /* Loop over the blockSize */
6035 i = blockSize;
6036
6037 while (i > 0u)
6038 {
6039 /* copy the sample from the circular buffer to the destination buffer */
6040 *dst = circBuffer[rOffset];
6041
6042 /* Update the input pointer */
6043 dst += dstInc;
6044
6045 if (dst == (q15_t *) dst_end)
6046 {
6047 dst = dst_base;
6048 }
6049
6050 /* Circularly update wOffset. Watch out for positive and negative value */
6051 rOffset += bufferInc;
6052
6053 if (rOffset >= L)
6054 {
6055 rOffset -= L;
6056 }
6057
6058 /* Decrement the loop counter */
6059 i--;
6060 }
6061
6062 /* Update the index pointer */
6063 *readOffset = rOffset;
6064 }
6065
6066
6067 /**
6068 * @brief Q7 Circular write function.
6069 */
6070 CMSIS_INLINE __STATIC_INLINE void arm_circularWrite_q7(
6071 q7_t * circBuffer,
6072 int32_t L,
6073 uint16_t * writeOffset,
6074 int32_t bufferInc,
6075 const q7_t * src,
6076 int32_t srcInc,
6077 uint32_t blockSize)
6078 {
6079 uint32_t i = 0u;
6080 int32_t wOffset;
6081
6082 /* Copy the value of Index pointer that points
6083 * to the current location where the input samples to be copied */
6084 wOffset = *writeOffset;
6085
6086 /* Loop over the blockSize */
6087 i = blockSize;
6088
6089 while (i > 0u)
6090 {
6091 /* copy the input sample to the circular buffer */
6092 circBuffer[wOffset] = *src;
6093
6094 /* Update the input pointer */
6095 src += srcInc;
6096
6097 /* Circularly update wOffset. Watch out for positive and negative value */
6098 wOffset += bufferInc;
6099 if (wOffset >= L)
6100 wOffset -= L;
6101
6102 /* Decrement the loop counter */
6103 i--;
6104 }
6105
6106 /* Update the index pointer */
6107 *writeOffset = (uint16_t)wOffset;
6108 }
6109
6110
6111 /**
6112 * @brief Q7 Circular Read function.
6113 */
6114 CMSIS_INLINE __STATIC_INLINE void arm_circularRead_q7(
6115 q7_t * circBuffer,
6116 int32_t L,
6117 int32_t * readOffset,
6118 int32_t bufferInc,
6119 q7_t * dst,
6120 q7_t * dst_base,
6121 int32_t dst_length,
6122 int32_t dstInc,
6123 uint32_t blockSize)
6124 {
6125 uint32_t i = 0;
6126 int32_t rOffset, dst_end;
6127
6128 /* Copy the value of Index pointer that points
6129 * to the current location from where the input samples to be read */
6130 rOffset = *readOffset;
6131
6132 dst_end = (int32_t) (dst_base + dst_length);
6133
6134 /* Loop over the blockSize */
6135 i = blockSize;
6136
6137 while (i > 0u)
6138 {
6139 /* copy the sample from the circular buffer to the destination buffer */
6140 *dst = circBuffer[rOffset];
6141
6142 /* Update the input pointer */
6143 dst += dstInc;
6144
6145 if (dst == (q7_t *) dst_end)
6146 {
6147 dst = dst_base;
6148 }
6149
6150 /* Circularly update rOffset. Watch out for positive and negative value */
6151 rOffset += bufferInc;
6152
6153 if (rOffset >= L)
6154 {
6155 rOffset -= L;
6156 }
6157
6158 /* Decrement the loop counter */
6159 i--;
6160 }
6161
6162 /* Update the index pointer */
6163 *readOffset = rOffset;
6164 }
6165
6166
6167 /**
6168 * @brief Sum of the squares of the elements of a Q31 vector.
6169 * @param[in] pSrc is input pointer
6170 * @param[in] blockSize is the number of samples to process
6171 * @param[out] pResult is output value.
6172 */
6173 void arm_power_q31(
6174 q31_t * pSrc,
6175 uint32_t blockSize,
6176 q63_t * pResult);
6177
6178
6179 /**
6180 * @brief Sum of the squares of the elements of a floating-point vector.
6181 * @param[in] pSrc is input pointer
6182 * @param[in] blockSize is the number of samples to process
6183 * @param[out] pResult is output value.
6184 */
6185 void arm_power_f32(
6186 float32_t * pSrc,
6187 uint32_t blockSize,
6188 float32_t * pResult);
6189
6190
6191 /**
6192 * @brief Sum of the squares of the elements of a Q15 vector.
6193 * @param[in] pSrc is input pointer
6194 * @param[in] blockSize is the number of samples to process
6195 * @param[out] pResult is output value.
6196 */
6197 void arm_power_q15(
6198 q15_t * pSrc,
6199 uint32_t blockSize,
6200 q63_t * pResult);
6201
6202
6203 /**
6204 * @brief Sum of the squares of the elements of a Q7 vector.
6205 * @param[in] pSrc is input pointer
6206 * @param[in] blockSize is the number of samples to process
6207 * @param[out] pResult is output value.
6208 */
6209 void arm_power_q7(
6210 q7_t * pSrc,
6211 uint32_t blockSize,
6212 q31_t * pResult);
6213
6214
6215 /**
6216 * @brief Mean value of a Q7 vector.
6217 * @param[in] pSrc is input pointer
6218 * @param[in] blockSize is the number of samples to process
6219 * @param[out] pResult is output value.
6220 */
6221 void arm_mean_q7(
6222 q7_t * pSrc,
6223 uint32_t blockSize,
6224 q7_t * pResult);
6225
6226
6227 /**
6228 * @brief Mean value of a Q15 vector.
6229 * @param[in] pSrc is input pointer
6230 * @param[in] blockSize is the number of samples to process
6231 * @param[out] pResult is output value.
6232 */
6233 void arm_mean_q15(
6234 q15_t * pSrc,
6235 uint32_t blockSize,
6236 q15_t * pResult);
6237
6238
6239 /**
6240 * @brief Mean value of a Q31 vector.
6241 * @param[in] pSrc is input pointer
6242 * @param[in] blockSize is the number of samples to process
6243 * @param[out] pResult is output value.
6244 */
6245 void arm_mean_q31(
6246 q31_t * pSrc,
6247 uint32_t blockSize,
6248 q31_t * pResult);
6249
6250
6251 /**
6252 * @brief Mean value of a floating-point vector.
6253 * @param[in] pSrc is input pointer
6254 * @param[in] blockSize is the number of samples to process
6255 * @param[out] pResult is output value.
6256 */
6257 void arm_mean_f32(
6258 float32_t * pSrc,
6259 uint32_t blockSize,
6260 float32_t * pResult);
6261
6262
6263 /**
6264 * @brief Variance of the elements of a floating-point vector.
6265 * @param[in] pSrc is input pointer
6266 * @param[in] blockSize is the number of samples to process
6267 * @param[out] pResult is output value.
6268 */
6269 void arm_var_f32(
6270 float32_t * pSrc,
6271 uint32_t blockSize,
6272 float32_t * pResult);
6273
6274
6275 /**
6276 * @brief Variance of the elements of a Q31 vector.
6277 * @param[in] pSrc is input pointer
6278 * @param[in] blockSize is the number of samples to process
6279 * @param[out] pResult is output value.
6280 */
6281 void arm_var_q31(
6282 q31_t * pSrc,
6283 uint32_t blockSize,
6284 q31_t * pResult);
6285
6286
6287 /**
6288 * @brief Variance of the elements of a Q15 vector.
6289 * @param[in] pSrc is input pointer
6290 * @param[in] blockSize is the number of samples to process
6291 * @param[out] pResult is output value.
6292 */
6293 void arm_var_q15(
6294 q15_t * pSrc,
6295 uint32_t blockSize,
6296 q15_t * pResult);
6297
6298
6299 /**
6300 * @brief Root Mean Square of the elements of a floating-point vector.
6301 * @param[in] pSrc is input pointer
6302 * @param[in] blockSize is the number of samples to process
6303 * @param[out] pResult is output value.
6304 */
6305 void arm_rms_f32(
6306 float32_t * pSrc,
6307 uint32_t blockSize,
6308 float32_t * pResult);
6309
6310
6311 /**
6312 * @brief Root Mean Square of the elements of a Q31 vector.
6313 * @param[in] pSrc is input pointer
6314 * @param[in] blockSize is the number of samples to process
6315 * @param[out] pResult is output value.
6316 */
6317 void arm_rms_q31(
6318 q31_t * pSrc,
6319 uint32_t blockSize,
6320 q31_t * pResult);
6321
6322
6323 /**
6324 * @brief Root Mean Square of the elements of a Q15 vector.
6325 * @param[in] pSrc is input pointer
6326 * @param[in] blockSize is the number of samples to process
6327 * @param[out] pResult is output value.
6328 */
6329 void arm_rms_q15(
6330 q15_t * pSrc,
6331 uint32_t blockSize,
6332 q15_t * pResult);
6333
6334
6335 /**
6336 * @brief Standard deviation of the elements of a floating-point vector.
6337 * @param[in] pSrc is input pointer
6338 * @param[in] blockSize is the number of samples to process
6339 * @param[out] pResult is output value.
6340 */
6341 void arm_std_f32(
6342 float32_t * pSrc,
6343 uint32_t blockSize,
6344 float32_t * pResult);
6345
6346
6347 /**
6348 * @brief Standard deviation of the elements of a Q31 vector.
6349 * @param[in] pSrc is input pointer
6350 * @param[in] blockSize is the number of samples to process
6351 * @param[out] pResult is output value.
6352 */
6353 void arm_std_q31(
6354 q31_t * pSrc,
6355 uint32_t blockSize,
6356 q31_t * pResult);
6357
6358
6359 /**
6360 * @brief Standard deviation of the elements of a Q15 vector.
6361 * @param[in] pSrc is input pointer
6362 * @param[in] blockSize is the number of samples to process
6363 * @param[out] pResult is output value.
6364 */
6365 void arm_std_q15(
6366 q15_t * pSrc,
6367 uint32_t blockSize,
6368 q15_t * pResult);
6369
6370
6371 /**
6372 * @brief Floating-point complex magnitude
6373 * @param[in] pSrc points to the complex input vector
6374 * @param[out] pDst points to the real output vector
6375 * @param[in] numSamples number of complex samples in the input vector
6376 */
6377 void arm_cmplx_mag_f32(
6378 float32_t * pSrc,
6379 float32_t * pDst,
6380 uint32_t numSamples);
6381
6382
6383 /**
6384 * @brief Q31 complex magnitude
6385 * @param[in] pSrc points to the complex input vector
6386 * @param[out] pDst points to the real output vector
6387 * @param[in] numSamples number of complex samples in the input vector
6388 */
6389 void arm_cmplx_mag_q31(
6390 q31_t * pSrc,
6391 q31_t * pDst,
6392 uint32_t numSamples);
6393
6394
6395 /**
6396 * @brief Q15 complex magnitude
6397 * @param[in] pSrc points to the complex input vector
6398 * @param[out] pDst points to the real output vector
6399 * @param[in] numSamples number of complex samples in the input vector
6400 */
6401 void arm_cmplx_mag_q15(
6402 q15_t * pSrc,
6403 q15_t * pDst,
6404 uint32_t numSamples);
6405
6406
6407 /**
6408 * @brief Q15 complex dot product
6409 * @param[in] pSrcA points to the first input vector
6410 * @param[in] pSrcB points to the second input vector
6411 * @param[in] numSamples number of complex samples in each vector
6412 * @param[out] realResult real part of the result returned here
6413 * @param[out] imagResult imaginary part of the result returned here
6414 */
6415 void arm_cmplx_dot_prod_q15(
6416 q15_t * pSrcA,
6417 q15_t * pSrcB,
6418 uint32_t numSamples,
6419 q31_t * realResult,
6420 q31_t * imagResult);
6421
6422
6423 /**
6424 * @brief Q31 complex dot product
6425 * @param[in] pSrcA points to the first input vector
6426 * @param[in] pSrcB points to the second input vector
6427 * @param[in] numSamples number of complex samples in each vector
6428 * @param[out] realResult real part of the result returned here
6429 * @param[out] imagResult imaginary part of the result returned here
6430 */
6431 void arm_cmplx_dot_prod_q31(
6432 q31_t * pSrcA,
6433 q31_t * pSrcB,
6434 uint32_t numSamples,
6435 q63_t * realResult,
6436 q63_t * imagResult);
6437
6438
6439 /**
6440 * @brief Floating-point complex dot product
6441 * @param[in] pSrcA points to the first input vector
6442 * @param[in] pSrcB points to the second input vector
6443 * @param[in] numSamples number of complex samples in each vector
6444 * @param[out] realResult real part of the result returned here
6445 * @param[out] imagResult imaginary part of the result returned here
6446 */
6447 void arm_cmplx_dot_prod_f32(
6448 float32_t * pSrcA,
6449 float32_t * pSrcB,
6450 uint32_t numSamples,
6451 float32_t * realResult,
6452 float32_t * imagResult);
6453
6454
6455 /**
6456 * @brief Q15 complex-by-real multiplication
6457 * @param[in] pSrcCmplx points to the complex input vector
6458 * @param[in] pSrcReal points to the real input vector
6459 * @param[out] pCmplxDst points to the complex output vector
6460 * @param[in] numSamples number of samples in each vector
6461 */
6462 void arm_cmplx_mult_real_q15(
6463 q15_t * pSrcCmplx,
6464 q15_t * pSrcReal,
6465 q15_t * pCmplxDst,
6466 uint32_t numSamples);
6467
6468
6469 /**
6470 * @brief Q31 complex-by-real multiplication
6471 * @param[in] pSrcCmplx points to the complex input vector
6472 * @param[in] pSrcReal points to the real input vector
6473 * @param[out] pCmplxDst points to the complex output vector
6474 * @param[in] numSamples number of samples in each vector
6475 */
6476 void arm_cmplx_mult_real_q31(
6477 q31_t * pSrcCmplx,
6478 q31_t * pSrcReal,
6479 q31_t * pCmplxDst,
6480 uint32_t numSamples);
6481
6482
6483 /**
6484 * @brief Floating-point complex-by-real multiplication
6485 * @param[in] pSrcCmplx points to the complex input vector
6486 * @param[in] pSrcReal points to the real input vector
6487 * @param[out] pCmplxDst points to the complex output vector
6488 * @param[in] numSamples number of samples in each vector
6489 */
6490 void arm_cmplx_mult_real_f32(
6491 float32_t * pSrcCmplx,
6492 float32_t * pSrcReal,
6493 float32_t * pCmplxDst,
6494 uint32_t numSamples);
6495
6496
6497 /**
6498 * @brief Minimum value of a Q7 vector.
6499 * @param[in] pSrc is input pointer
6500 * @param[in] blockSize is the number of samples to process
6501 * @param[out] result is output pointer
6502 * @param[in] index is the array index of the minimum value in the input buffer.
6503 */
6504 void arm_min_q7(
6505 q7_t * pSrc,
6506 uint32_t blockSize,
6507 q7_t * result,
6508 uint32_t * index);
6509
6510
6511 /**
6512 * @brief Minimum value of a Q15 vector.
6513 * @param[in] pSrc is input pointer
6514 * @param[in] blockSize is the number of samples to process
6515 * @param[out] pResult is output pointer
6516 * @param[in] pIndex is the array index of the minimum value in the input buffer.
6517 */
6518 void arm_min_q15(
6519 q15_t * pSrc,
6520 uint32_t blockSize,
6521 q15_t * pResult,
6522 uint32_t * pIndex);
6523
6524
6525 /**
6526 * @brief Minimum value of a Q31 vector.
6527 * @param[in] pSrc is input pointer
6528 * @param[in] blockSize is the number of samples to process
6529 * @param[out] pResult is output pointer
6530 * @param[out] pIndex is the array index of the minimum value in the input buffer.
6531 */
6532 void arm_min_q31(
6533 q31_t * pSrc,
6534 uint32_t blockSize,
6535 q31_t * pResult,
6536 uint32_t * pIndex);
6537
6538
6539 /**
6540 * @brief Minimum value of a floating-point vector.
6541 * @param[in] pSrc is input pointer
6542 * @param[in] blockSize is the number of samples to process
6543 * @param[out] pResult is output pointer
6544 * @param[out] pIndex is the array index of the minimum value in the input buffer.
6545 */
6546 void arm_min_f32(
6547 float32_t * pSrc,
6548 uint32_t blockSize,
6549 float32_t * pResult,
6550 uint32_t * pIndex);
6551
6552
6553/**
6554 * @brief Maximum value of a Q7 vector.
6555 * @param[in] pSrc points to the input buffer
6556 * @param[in] blockSize length of the input vector
6557 * @param[out] pResult maximum value returned here
6558 * @param[out] pIndex index of maximum value returned here
6559 */
6560 void arm_max_q7(
6561 q7_t * pSrc,
6562 uint32_t blockSize,
6563 q7_t * pResult,
6564 uint32_t * pIndex);
6565
6566
6567/**
6568 * @brief Maximum value of a Q15 vector.
6569 * @param[in] pSrc points to the input buffer
6570 * @param[in] blockSize length of the input vector
6571 * @param[out] pResult maximum value returned here
6572 * @param[out] pIndex index of maximum value returned here
6573 */
6574 void arm_max_q15(
6575 q15_t * pSrc,
6576 uint32_t blockSize,
6577 q15_t * pResult,
6578 uint32_t * pIndex);
6579
6580
6581/**
6582 * @brief Maximum value of a Q31 vector.
6583 * @param[in] pSrc points to the input buffer
6584 * @param[in] blockSize length of the input vector
6585 * @param[out] pResult maximum value returned here
6586 * @param[out] pIndex index of maximum value returned here
6587 */
6588 void arm_max_q31(
6589 q31_t * pSrc,
6590 uint32_t blockSize,
6591 q31_t * pResult,
6592 uint32_t * pIndex);
6593
6594
6595/**
6596 * @brief Maximum value of a floating-point vector.
6597 * @param[in] pSrc points to the input buffer
6598 * @param[in] blockSize length of the input vector
6599 * @param[out] pResult maximum value returned here
6600 * @param[out] pIndex index of maximum value returned here
6601 */
6602 void arm_max_f32(
6603 float32_t * pSrc,
6604 uint32_t blockSize,
6605 float32_t * pResult,
6606 uint32_t * pIndex);
6607
6608
6609 /**
6610 * @brief Q15 complex-by-complex multiplication
6611 * @param[in] pSrcA points to the first input vector
6612 * @param[in] pSrcB points to the second input vector
6613 * @param[out] pDst points to the output vector
6614 * @param[in] numSamples number of complex samples in each vector
6615 */
6616 void arm_cmplx_mult_cmplx_q15(
6617 q15_t * pSrcA,
6618 q15_t * pSrcB,
6619 q15_t * pDst,
6620 uint32_t numSamples);
6621
6622
6623 /**
6624 * @brief Q31 complex-by-complex multiplication
6625 * @param[in] pSrcA points to the first input vector
6626 * @param[in] pSrcB points to the second input vector
6627 * @param[out] pDst points to the output vector
6628 * @param[in] numSamples number of complex samples in each vector
6629 */
6630 void arm_cmplx_mult_cmplx_q31(
6631 q31_t * pSrcA,
6632 q31_t * pSrcB,
6633 q31_t * pDst,
6634 uint32_t numSamples);
6635
6636
6637 /**
6638 * @brief Floating-point complex-by-complex multiplication
6639 * @param[in] pSrcA points to the first input vector
6640 * @param[in] pSrcB points to the second input vector
6641 * @param[out] pDst points to the output vector
6642 * @param[in] numSamples number of complex samples in each vector
6643 */
6644 void arm_cmplx_mult_cmplx_f32(
6645 float32_t * pSrcA,
6646 float32_t * pSrcB,
6647 float32_t * pDst,
6648 uint32_t numSamples);
6649
6650
6651 /**
6652 * @brief Converts the elements of the floating-point vector to Q31 vector.
6653 * @param[in] pSrc points to the floating-point input vector
6654 * @param[out] pDst points to the Q31 output vector
6655 * @param[in] blockSize length of the input vector
6656 */
6657 void arm_float_to_q31(
6658 float32_t * pSrc,
6659 q31_t * pDst,
6660 uint32_t blockSize);
6661
6662
6663 /**
6664 * @brief Converts the elements of the floating-point vector to Q15 vector.
6665 * @param[in] pSrc points to the floating-point input vector
6666 * @param[out] pDst points to the Q15 output vector
6667 * @param[in] blockSize length of the input vector
6668 */
6669 void arm_float_to_q15(
6670 float32_t * pSrc,
6671 q15_t * pDst,
6672 uint32_t blockSize);
6673
6674
6675 /**
6676 * @brief Converts the elements of the floating-point vector to Q7 vector.
6677 * @param[in] pSrc points to the floating-point input vector
6678 * @param[out] pDst points to the Q7 output vector
6679 * @param[in] blockSize length of the input vector
6680 */
6681 void arm_float_to_q7(
6682 float32_t * pSrc,
6683 q7_t * pDst,
6684 uint32_t blockSize);
6685
6686
6687 /**
6688 * @brief Converts the elements of the Q31 vector to Q15 vector.
6689 * @param[in] pSrc is input pointer
6690 * @param[out] pDst is output pointer
6691 * @param[in] blockSize is the number of samples to process
6692 */
6693 void arm_q31_to_q15(
6694 q31_t * pSrc,
6695 q15_t * pDst,
6696 uint32_t blockSize);
6697
6698
6699 /**
6700 * @brief Converts the elements of the Q31 vector to Q7 vector.
6701 * @param[in] pSrc is input pointer
6702 * @param[out] pDst is output pointer
6703 * @param[in] blockSize is the number of samples to process
6704 */
6705 void arm_q31_to_q7(
6706 q31_t * pSrc,
6707 q7_t * pDst,
6708 uint32_t blockSize);
6709
6710
6711 /**
6712 * @brief Converts the elements of the Q15 vector to floating-point vector.
6713 * @param[in] pSrc is input pointer
6714 * @param[out] pDst is output pointer
6715 * @param[in] blockSize is the number of samples to process
6716 */
6717 void arm_q15_to_float(
6718 q15_t * pSrc,
6719 float32_t * pDst,
6720 uint32_t blockSize);
6721
6722
6723 /**
6724 * @brief Converts the elements of the Q15 vector to Q31 vector.
6725 * @param[in] pSrc is input pointer
6726 * @param[out] pDst is output pointer
6727 * @param[in] blockSize is the number of samples to process
6728 */
6729 void arm_q15_to_q31(
6730 q15_t * pSrc,
6731 q31_t * pDst,
6732 uint32_t blockSize);
6733
6734
6735 /**
6736 * @brief Converts the elements of the Q15 vector to Q7 vector.
6737 * @param[in] pSrc is input pointer
6738 * @param[out] pDst is output pointer
6739 * @param[in] blockSize is the number of samples to process
6740 */
6741 void arm_q15_to_q7(
6742 q15_t * pSrc,
6743 q7_t * pDst,
6744 uint32_t blockSize);
6745
6746
6747 /**
6748 * @ingroup groupInterpolation
6749 */
6750
6751 /**
6752 * @defgroup BilinearInterpolate Bilinear Interpolation
6753 *
6754 * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
6755 * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
6756 * determines values between the grid points.
6757 * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
6758 * Bilinear interpolation is often used in image processing to rescale images.
6759 * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
6760 *
6761 * <b>Algorithm</b>
6762 * \par
6763 * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
6764 * For floating-point, the instance structure is defined as:
6765 * <pre>
6766 * typedef struct
6767 * {
6768 * uint16_t numRows;
6769 * uint16_t numCols;
6770 * float32_t *pData;
6771 * } arm_bilinear_interp_instance_f32;
6772 * </pre>
6773 *
6774 * \par
6775 * where <code>numRows</code> specifies the number of rows in the table;
6776 * <code>numCols</code> specifies the number of columns in the table;
6777 * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
6778 * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
6779 * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
6780 *
6781 * \par
6782 * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
6783 * <pre>
6784 * XF = floor(x)
6785 * YF = floor(y)
6786 * </pre>
6787 * \par
6788 * The interpolated output point is computed as:
6789 * <pre>
6790 * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
6791 * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
6792 * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
6793 * + f(XF+1, YF+1) * (x-XF)*(y-YF)
6794 * </pre>
6795 * Note that the coordinates (x, y) contain integer and fractional components.
6796 * The integer components specify which portion of the table to use while the
6797 * fractional components control the interpolation processor.
6798 *
6799 * \par
6800 * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
6801 */
6802
6803 /**
6804 * @addtogroup BilinearInterpolate
6805 * @{
6806 */
6807
6808
6809 /**
6810 *
6811 * @brief Floating-point bilinear interpolation.
6812 * @param[in,out] S points to an instance of the interpolation structure.
6813 * @param[in] X interpolation coordinate.
6814 * @param[in] Y interpolation coordinate.
6815 * @return out interpolated value.
6816 */
6817 CMSIS_INLINE __STATIC_INLINE float32_t arm_bilinear_interp_f32(
6818 const arm_bilinear_interp_instance_f32 * S,
6819 float32_t X,
6820 float32_t Y)
6821 {
6822 float32_t out;
6823 float32_t f00, f01, f10, f11;
6824 float32_t *pData = S->pData;
6825 int32_t xIndex, yIndex, index;
6826 float32_t xdiff, ydiff;
6827 float32_t b1, b2, b3, b4;
6828
6829 xIndex = (int32_t) X;
6830 yIndex = (int32_t) Y;
6831
6832 /* Care taken for table outside boundary */
6833 /* Returns zero output when values are outside table boundary */
6834 if (xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1))
6835 {
6836 return (0);
6837 }
6838
6839 /* Calculation of index for two nearest points in X-direction */
6840 index = (xIndex - 1) + (yIndex - 1) * S->numCols;
6841
6842
6843 /* Read two nearest points in X-direction */
6844 f00 = pData[index];
6845 f01 = pData[index + 1];
6846
6847 /* Calculation of index for two nearest points in Y-direction */
6848 index = (xIndex - 1) + (yIndex) * S->numCols;
6849
6850
6851 /* Read two nearest points in Y-direction */
6852 f10 = pData[index];
6853 f11 = pData[index + 1];
6854
6855 /* Calculation of intermediate values */
6856 b1 = f00;
6857 b2 = f01 - f00;
6858 b3 = f10 - f00;
6859 b4 = f00 - f01 - f10 + f11;
6860
6861 /* Calculation of fractional part in X */
6862 xdiff = X - xIndex;
6863
6864 /* Calculation of fractional part in Y */
6865 ydiff = Y - yIndex;
6866
6867 /* Calculation of bi-linear interpolated output */
6868 out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
6869
6870 /* return to application */
6871 return (out);
6872 }
6873
6874
6875 /**
6876 *
6877 * @brief Q31 bilinear interpolation.
6878 * @param[in,out] S points to an instance of the interpolation structure.
6879 * @param[in] X interpolation coordinate in 12.20 format.
6880 * @param[in] Y interpolation coordinate in 12.20 format.
6881 * @return out interpolated value.
6882 */
6883 CMSIS_INLINE __STATIC_INLINE q31_t arm_bilinear_interp_q31(
6884 arm_bilinear_interp_instance_q31 * S,
6885 q31_t X,
6886 q31_t Y)
6887 {
6888 q31_t out; /* Temporary output */
6889 q31_t acc = 0; /* output */
6890 q31_t xfract, yfract; /* X, Y fractional parts */
6891 q31_t x1, x2, y1, y2; /* Nearest output values */
6892 int32_t rI, cI; /* Row and column indices */
6893 q31_t *pYData = S->pData; /* pointer to output table values */
6894 uint32_t nCols = S->numCols; /* num of rows */
6895
6896 /* Input is in 12.20 format */
6897 /* 12 bits for the table index */
6898 /* Index value calculation */
6899 rI = ((X & (q31_t)0xFFF00000) >> 20);
6900
6901 /* Input is in 12.20 format */
6902 /* 12 bits for the table index */
6903 /* Index value calculation */
6904 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6905
6906 /* Care taken for table outside boundary */
6907 /* Returns zero output when values are outside table boundary */
6908 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6909 {
6910 return (0);
6911 }
6912
6913 /* 20 bits for the fractional part */
6914 /* shift left xfract by 11 to keep 1.31 format */
6915 xfract = (X & 0x000FFFFF) << 11u;
6916
6917 /* Read two nearest output values from the index */
6918 x1 = pYData[(rI) + (int32_t)nCols * (cI) ];
6919 x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1];
6920
6921 /* 20 bits for the fractional part */
6922 /* shift left yfract by 11 to keep 1.31 format */
6923 yfract = (Y & 0x000FFFFF) << 11u;
6924
6925 /* Read two nearest output values from the index */
6926 y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ];
6927 y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1];
6928
6929 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
6930 out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
6931 acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
6932
6933 /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
6934 out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
6935 acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
6936
6937 /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
6938 out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
6939 acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
6940
6941 /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
6942 out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
6943 acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
6944
6945 /* Convert acc to 1.31(q31) format */
6946 return ((q31_t)(acc << 2));
6947 }
6948
6949
6950 /**
6951 * @brief Q15 bilinear interpolation.
6952 * @param[in,out] S points to an instance of the interpolation structure.
6953 * @param[in] X interpolation coordinate in 12.20 format.
6954 * @param[in] Y interpolation coordinate in 12.20 format.
6955 * @return out interpolated value.
6956 */
6957 CMSIS_INLINE __STATIC_INLINE q15_t arm_bilinear_interp_q15(
6958 arm_bilinear_interp_instance_q15 * S,
6959 q31_t X,
6960 q31_t Y)
6961 {
6962 q63_t acc = 0; /* output */
6963 q31_t out; /* Temporary output */
6964 q15_t x1, x2, y1, y2; /* Nearest output values */
6965 q31_t xfract, yfract; /* X, Y fractional parts */
6966 int32_t rI, cI; /* Row and column indices */
6967 q15_t *pYData = S->pData; /* pointer to output table values */
6968 uint32_t nCols = S->numCols; /* num of rows */
6969
6970 /* Input is in 12.20 format */
6971 /* 12 bits for the table index */
6972 /* Index value calculation */
6973 rI = ((X & (q31_t)0xFFF00000) >> 20);
6974
6975 /* Input is in 12.20 format */
6976 /* 12 bits for the table index */
6977 /* Index value calculation */
6978 cI = ((Y & (q31_t)0xFFF00000) >> 20);
6979
6980 /* Care taken for table outside boundary */
6981 /* Returns zero output when values are outside table boundary */
6982 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
6983 {
6984 return (0);
6985 }
6986
6987 /* 20 bits for the fractional part */
6988 /* xfract should be in 12.20 format */
6989 xfract = (X & 0x000FFFFF);
6990
6991 /* Read two nearest output values from the index */
6992 x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
6993 x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
6994
6995 /* 20 bits for the fractional part */
6996 /* yfract should be in 12.20 format */
6997 yfract = (Y & 0x000FFFFF);
6998
6999 /* Read two nearest output values from the index */
7000 y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
7001 y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
7002
7003 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
7004
7005 /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
7006 /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
7007 out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
7008 acc = ((q63_t) out * (0xFFFFF - yfract));
7009
7010 /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
7011 out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
7012 acc += ((q63_t) out * (xfract));
7013
7014 /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
7015 out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
7016 acc += ((q63_t) out * (yfract));
7017
7018 /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
7019 out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);
7020 acc += ((q63_t) out * (yfract));
7021
7022 /* acc is in 13.51 format and down shift acc by 36 times */
7023 /* Convert out to 1.15 format */
7024 return ((q15_t)(acc >> 36));
7025 }
7026
7027
7028 /**
7029 * @brief Q7 bilinear interpolation.
7030 * @param[in,out] S points to an instance of the interpolation structure.
7031 * @param[in] X interpolation coordinate in 12.20 format.
7032 * @param[in] Y interpolation coordinate in 12.20 format.
7033 * @return out interpolated value.
7034 */
7035 CMSIS_INLINE __STATIC_INLINE q7_t arm_bilinear_interp_q7(
7036 arm_bilinear_interp_instance_q7 * S,
7037 q31_t X,
7038 q31_t Y)
7039 {
7040 q63_t acc = 0; /* output */
7041 q31_t out; /* Temporary output */
7042 q31_t xfract, yfract; /* X, Y fractional parts */
7043 q7_t x1, x2, y1, y2; /* Nearest output values */
7044 int32_t rI, cI; /* Row and column indices */
7045 q7_t *pYData = S->pData; /* pointer to output table values */
7046 uint32_t nCols = S->numCols; /* num of rows */
7047
7048 /* Input is in 12.20 format */
7049 /* 12 bits for the table index */
7050 /* Index value calculation */
7051 rI = ((X & (q31_t)0xFFF00000) >> 20);
7052
7053 /* Input is in 12.20 format */
7054 /* 12 bits for the table index */
7055 /* Index value calculation */
7056 cI = ((Y & (q31_t)0xFFF00000) >> 20);
7057
7058 /* Care taken for table outside boundary */
7059 /* Returns zero output when values are outside table boundary */
7060 if (rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
7061 {
7062 return (0);
7063 }
7064
7065 /* 20 bits for the fractional part */
7066 /* xfract should be in 12.20 format */
7067 xfract = (X & (q31_t)0x000FFFFF);
7068
7069 /* Read two nearest output values from the index */
7070 x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ];
7071 x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1];
7072
7073 /* 20 bits for the fractional part */
7074 /* yfract should be in 12.20 format */
7075 yfract = (Y & (q31_t)0x000FFFFF);
7076
7077 /* Read two nearest output values from the index */
7078 y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ];
7079 y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1];
7080
7081 /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
7082 out = ((x1 * (0xFFFFF - xfract)));
7083 acc = (((q63_t) out * (0xFFFFF - yfract)));
7084
7085 /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
7086 out = ((x2 * (0xFFFFF - yfract)));
7087 acc += (((q63_t) out * (xfract)));
7088
7089 /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
7090 out = ((y1 * (0xFFFFF - xfract)));
7091 acc += (((q63_t) out * (yfract)));
7092
7093 /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
7094 out = ((y2 * (yfract)));
7095 acc += (((q63_t) out * (xfract)));
7096
7097 /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
7098 return ((q7_t)(acc >> 40));
7099 }
7100
7101 /**
7102 * @} end of BilinearInterpolate group
7103 */
7104
7105
7106/* SMMLAR */
7107#define multAcc_32x32_keep32_R(a, x, y) \
7108 a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
7109
7110/* SMMLSR */
7111#define multSub_32x32_keep32_R(a, x, y) \
7112 a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
7113
7114/* SMMULR */
7115#define mult_32x32_keep32_R(a, x, y) \
7116 a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
7117
7118/* SMMLA */
7119#define multAcc_32x32_keep32(a, x, y) \
7120 a += (q31_t) (((q63_t) x * y) >> 32)
7121
7122/* SMMLS */
7123#define multSub_32x32_keep32(a, x, y) \
7124 a -= (q31_t) (((q63_t) x * y) >> 32)
7125
7126/* SMMUL */
7127#define mult_32x32_keep32(a, x, y) \
7128 a = (q31_t) (((q63_t) x * y ) >> 32)
7129
7130
7131#if defined ( __CC_ARM )
7132 /* Enter low optimization region - place directly above function definition */
7133 #if defined( ARM_MATH_CM4 ) || defined( ARM_MATH_CM7)
7134 #define LOW_OPTIMIZATION_ENTER \
7135 _Pragma ("push") \
7136 _Pragma ("O1")
7137 #else
7138 #define LOW_OPTIMIZATION_ENTER
7139 #endif
7140
7141 /* Exit low optimization region - place directly after end of function definition */
7142 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7143 #define LOW_OPTIMIZATION_EXIT \
7144 _Pragma ("pop")
7145 #else
7146 #define LOW_OPTIMIZATION_EXIT
7147 #endif
7148
7149 /* Enter low optimization region - place directly above function definition */
7150 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7151
7152 /* Exit low optimization region - place directly after end of function definition */
7153 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7154
7155#elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 )
7156 #define LOW_OPTIMIZATION_ENTER
7157 #define LOW_OPTIMIZATION_EXIT
7158 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7159 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7160
7161#elif defined ( __GNUC__ )
7162 #define LOW_OPTIMIZATION_ENTER \
7163 __attribute__(( optimize("-O1") ))
7164 #define LOW_OPTIMIZATION_EXIT
7165 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7166 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7167
7168#elif defined ( __ICCARM__ )
7169 /* Enter low optimization region - place directly above function definition */
7170 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7171 #define LOW_OPTIMIZATION_ENTER \
7172 _Pragma ("optimize=low")
7173 #else
7174 #define LOW_OPTIMIZATION_ENTER
7175 #endif
7176
7177 /* Exit low optimization region - place directly after end of function definition */
7178 #define LOW_OPTIMIZATION_EXIT
7179
7180 /* Enter low optimization region - place directly above function definition */
7181 #if defined ( ARM_MATH_CM4 ) || defined ( ARM_MATH_CM7 )
7182 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
7183 _Pragma ("optimize=low")
7184 #else
7185 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7186 #endif
7187
7188 /* Exit low optimization region - place directly after end of function definition */
7189 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7190
7191#elif defined ( __TI_ARM__ )
7192 #define LOW_OPTIMIZATION_ENTER
7193 #define LOW_OPTIMIZATION_EXIT
7194 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7195 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7196
7197#elif defined ( __CSMC__ )
7198 #define LOW_OPTIMIZATION_ENTER
7199 #define LOW_OPTIMIZATION_EXIT
7200 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7201 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7202
7203#elif defined ( __TASKING__ )
7204 #define LOW_OPTIMIZATION_ENTER
7205 #define LOW_OPTIMIZATION_EXIT
7206 #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
7207 #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
7208
7209#endif
7210
7211
7212#ifdef __cplusplus
7213}
7214#endif
7215
7216
7217#if defined ( __GNUC__ )
7218#pragma GCC diagnostic pop
7219#endif
7220
7221#endif /* _ARM_MATH_H */
7222
7223/**
7224 *
7225 * End of file.
7226 */