ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_firmr_init_f32.c File Reference
#include "dsps_fir.h"
#include "dsp_common.h"
#include <malloc.h>
#include "dsp_tests.h"
Include dependency graph for dsps_firmr_init_f32.c:

Go to the source code of this file.

Functions

esp_err_t dsps_firmr_init_f32 (fir_f32_t *fir, float *coeffs, float *delay, int length, int interp, int decim, int start_pos)
 initialize structure for multi-rate FIR filter Function initialize structure for 32 bit floating point multi-rate FIR filter The implementation use ANSI C and could be compiled and run on any platform

Function Documentation

◆ dsps_firmr_init_f32()

esp_err_t dsps_firmr_init_f32 ( fir_f32_t * fir,
float * coeffs,
float * delay,
int length,
int interp,
int decim,
int start_pos )

initialize structure for multi-rate FIR filter Function initialize structure for 32 bit floating point multi-rate FIR filter The implementation use ANSI C and could be compiled and run on any platform

Parameters
firpointer to fir filter structure, that must be preallocated
coeffsarray with FIR filter coefficients. Must be length N
delayarray for FIR filter delay line. Must be length N
lengthFIR filter length. Length of coeffs and delay arrays.
interpinterpolation factor.
decimdecimation factor.
start_posinitial value of decimation counter. Must be [0..decim)
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 12 of file dsps_firmr_init_f32.c.

13{
14 fir->coeffs = coeffs;
15 fir->delay = delay;
16 fir->N = length;
17 fir->pos = 0;
18 fir->decim = decim;
19 fir->use_delay = 0;
20 fir->interp = interp;
21 fir->interp_pos = 0;
22 fir->start_pos = start_pos;
23 fir->delay_size = length / interp;
24
25 if (delay == NULL) {
26#ifdef CONFIG_IDF_TARGET_ESP32S3
27 fir->delay = (float *)memalign(16, (fir->delay_size + 4) * sizeof(float));
28#else
29 fir->delay = (float *)malloc((fir->delay_size + 4) * sizeof(float));
30#endif // CONFIG_IDF_TARGET_ESP32S3
31 fir->use_delay = 1;
32 } else {
33 fir->use_delay = 0;
34 }
35
36 if (decim == 0) {
38 }
39 if (interp == 0) {
41 }
42 if (length % interp != 0) {
44 }
45 if (start_pos < 0 || start_pos >= decim) {
47 }
48
49#ifdef CONFIG_IDF_TARGET_ESP32S3
50 // The delay array should be aligned to 16
51 if (((uint32_t)delay) & 0x0f) {
53 }
54#endif // CONFIG_IDF_TARGET_ESP32S3
55
56 for (int i = 0 ; i < fir->delay_size; i++) {
57 fir->delay[i] = 0;
58 }
59 return ESP_OK;
60}
#define ESP_ERR_DSP_INVALID_PARAM
#define ESP_ERR_DSP_INVALID_LENGTH
#define ESP_ERR_DSP_ARRAY_NOT_ALIGNED
#define memalign(align_, size_)
Definition dsp_tests.h:35
#define ESP_OK
Definition esp_err.h:23
int interp
Definition dsps_fir.h:42
int interp_pos
Definition dsps_fir.h:43
float * coeffs
Definition dsps_fir.h:30
int pos
Definition dsps_fir.h:33
float * delay
Definition dsps_fir.h:31
int start_pos
Definition dsps_fir.h:44
int16_t use_delay
Definition dsps_fir.h:35
int delay_size
Interpolation parameters.
Definition dsps_fir.h:41
int decim
Definition dsps_fir.h:34
float delay[256]
Definition test_fir.c:15
float coeffs[256]
Definition test_fir.c:14

References coeffs, fir_f32_s::coeffs, fir_f32_s::decim, delay, fir_f32_s::delay, fir_f32_s::delay_size, ESP_ERR_DSP_ARRAY_NOT_ALIGNED, ESP_ERR_DSP_INVALID_LENGTH, ESP_ERR_DSP_INVALID_PARAM, ESP_OK, fir_f32_s::interp, fir_f32_s::interp_pos, memalign, fir_f32_s::N, fir_f32_s::pos, fir_f32_s::start_pos, and fir_f32_s::use_delay.

Referenced by dsps_resampler_mr_init().

Here is the caller graph for this function: