Improve band-pass filter

This commit is contained in:
Jan Hamal Dvořák 2024-08-07 00:19:29 +02:00
parent a61748c6b5
commit f10f8d5ceb

View file

@ -23,7 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#define VREG_VOLTAGE VREG_VOLTAGE_1_20 #define VREG_VOLTAGE VREG_VOLTAGE_1_20
#define CLK_SYS_HZ (300 * MHZ) #define CLK_SYS_HZ (288 * MHZ)
#define INIT_SAMPLE_RATE 200000 #define INIT_SAMPLE_RATE 200000
#define INIT_FREQ 94600000 #define INIT_FREQ 94600000
@ -267,18 +267,17 @@ struct IQ {
inline static int nextQ(void) inline static int nextQ(void)
{ {
static int x1; static int x4, x3, x2, x1;
static int y1;
int x0 = gain * adc_fifo_get_blocking(); int x0 = gain * adc_fifo_get_blocking();
int y0 = x0 + x1; int x = x2 + x2 - x4 - x0;
x4 = x3;
x3 = x2;
x2 = x1;
x1 = x0; x1 = x0;
int y = y0 - y1; return x;
y1 = y0;
return y;
} }
inline static struct IQ next_sample() inline static struct IQ next_sample()