ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_fird_f32_ansi.c File Reference
#include "dsps_fir.h"
Include dependency graph for dsps_fird_f32_ansi.c:

Go to the source code of this file.

Functions

int dsps_fird_f32_ansi (fir_f32_t *fir, const float *input, float *output, int len)
 32 bit floating point Decimation FIR filter

Function Documentation

◆ dsps_fird_f32_ansi()

int dsps_fird_f32_ansi ( fir_f32_t * fir,
const float * input,
float * output,
int len )

32 bit floating point Decimation FIR filter

Function implements FIR filter with decimation The extension (_ansi) uses ANSI C and could be compiled and run on any platform. The extension (_ae32) is optimized for ESP32 chip.

Parameters
firpointer to fir filter structure, that must be initialized before
inputinput array
outputarray with the result of FIR filter
lenlength of result array
Returns
: function returns the number of samples stored in the output array depends on the previous state value could be [0..len/decimation]

Definition at line 17 of file dsps_fird_f32_ansi.c.

18{
19 int result = 0;
20 for (int i = 0; i < len ; i++) {
21 for (int k = 0 ; k < fir->decim ; k++) {
22 fir->delay[fir->pos++] = *input++;
23 if (fir->pos >= fir->N) {
24 fir->pos = 0;
25 }
26 }
27 float acc = 0;
28 int coeff_pos = 0;
29 for (int n = fir->pos; n < fir->N ; n++) {
30 acc += fir->coeffs[coeff_pos++] * fir->delay[n];
31 }
32 for (int n = 0; n < fir->pos ; n++) {
33 acc += fir->coeffs[coeff_pos++] * fir->delay[n];
34 }
35 output[result++] = acc;
36 }
37 return result;
38}
float * coeffs
Definition dsps_fir.h:30
int pos
Definition dsps_fir.h:33
float * delay
Definition dsps_fir.h:31
int decim
Definition dsps_fir.h:34
#define N
Definition test_mmult.c:13
const int n
Definition test_mmult.c:17
const int k
Definition test_mmult.c:18

References fir_f32_s::coeffs, fir_f32_s::decim, fir_f32_s::delay, k, fir_f32_s::N, N, n, and fir_f32_s::pos.