ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_fird_init_f32.c
Go to the documentation of this file.
1// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "dsps_fir.h"
16
17
18esp_err_t dsps_fird_init_f32(fir_f32_t *fir, float *coeffs, float *delay, int N, int decim)
19{
20 fir->coeffs = coeffs;
21 fir->delay = delay;
22 fir->N = N;
23 fir->pos = 0;
24 fir->decim = decim;
25
26#ifdef CONFIG_IDF_TARGET_ESP32S3
27 // The amount of coefficients should be divided to 4,
28 // if not, add zero coefficients to round length to 0
29 if (fir->N % 4 != 0) {
31 }
32 // The coeffs array should be aligned to 16
33 if (((uint32_t)coeffs) & 0x0f) {
35 }
36 // The delay array should be aligned to 16
37 if (((uint32_t)delay) & 0x0f) {
39 }
40#endif // CONFIG_IDF_TARGET_ESP32S3
41
42 for (int i = 0 ; i < N; i++) {
43 fir->delay[i] = 0;
44 }
45 return ESP_OK;
46}
#define ESP_ERR_DSP_INVALID_LENGTH
#define ESP_ERR_DSP_ARRAY_NOT_ALIGNED
struct fir_f32_s fir_f32_t
Data struct of f32 fir filter.
esp_err_t dsps_fird_init_f32(fir_f32_t *fir, float *coeffs, float *delay, int N, int decim)
initialize structure for 32 bit Decimation FIR filter Function initialize structure for 32 bit floati...
int esp_err_t
Definition esp_err.h:21
#define ESP_OK
Definition esp_err.h:23
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
float delay[256]
Definition test_fir.c:15
float coeffs[256]
Definition test_fir.c:14
#define N
Definition test_mmult.c:13