| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /*
- * Filter Coefficients (C Source) generated by the Filter Design and Analysis Tool
- * Generated by MATLAB(R) 9.9 and Signal Processing Toolbox 8.5.
- * Generated on: 06-Oct-2022 12:50:19
- */
- /*
- * 离散时间 FIR 滤波器(实数)
- * ----------------
- * 滤波器结构 : 直接型 FIR
- * 滤波器长度 : 16
- * 稳定 : 是
- * 线性相位 : 是 (Type 2)
- */
- /* General type conversion for MATLAB generated C-code */
- //#include "tmwtypes.h"
- /*
- * Expected path to tmwtypes.h
- * D:\Program Files\R2020b\extern\include\tmwtypes.h
- */
- /*
- * Warning - Filter coefficients were truncated to fit specified data type.
- * The resulting response may not match generated theoretical response.
- * Use the Filter Design & Analysis Tool to design accurate
- * single-precision filter coefficients.
- */
- #include "math/fir.h"
- static const float Fir_Ceofs[16] = {
- 0.007895005867, 0.01734124683, 0.03257999197, 0.05209516734, 0.07380001992,
- 0.09460353851, 0.1110314056, 0.1201113388, 0.1201113388, 0.1110314056,
- 0.09460353851, 0.07380001992, 0.05209516734, 0.03257999197, 0.01734124683,
- 0.007895005867
- };
- void Fir_init(Fir_t *fir) {
- for (int i = 0; i < FIR_Ceof_Len; i++) {
- fir->X[0] = 0.0f;
- }
- fir->k = 0;
- }
- float Fir_Filter(Fir_t *fir, float in) {
- float out = 0;
- fir->X[fir->k] = in;
- for (int i = 1; i <= FIR_Ceof_Len; i++) {
- out += Fir_Ceofs[i-1] * fir->X[(i+fir->k) % FIR_Ceof_Len];
- }
- fir->k = (fir->k + 1) % FIR_Ceof_Len;
- return out;
- }
|