Lower decimation for higher rates

This is to accomodate 300 ksps for best image rejection.
This commit is contained in:
Jan Hamal Dvořák 2024-08-06 10:18:56 +02:00
parent 36ca06f31b
commit d78365cddf

View file

@ -38,10 +38,10 @@
#define IQ_SAMPLES 32 #define IQ_SAMPLES 32
#define IQ_BLOCK_LEN (2 * IQ_SAMPLES) #define IQ_BLOCK_LEN (2 * IQ_SAMPLES)
#define IQ_QUEUE_LEN 4 #define IQ_QUEUE_LEN 8
#define ADC_RATE (2 * MHZ) #define ADC_RATE (2 * MHZ)
#define DECIMATE 8 #define DECIMATE 4
/* /*
* NOTE: Must have 256 phases with 256 bytes each. * NOTE: Must have 256 phases with 256 bytes each.
@ -263,47 +263,18 @@ inline static struct IQ next_sample()
{ {
int I = 0, Q = 0; int I = 0, Q = 0;
int x07 = nextQ(); I += nextQ();
I += 36 * x07; Q += nextQ();
Q += 36 * x07; I -= nextQ();
Q -= nextQ();
int x06 = nextQ();
I += 0 * x06;
Q += 51 * x06;
int x05 = nextQ();
I += -36 * x05;
Q += 36 * x05;
int x04 = nextQ();
I += -51 * x04;
Q += 0 * x04;
int x03 = nextQ();
I += -36 * x03;
Q += -36 * x03;
int x02 = nextQ();
I += 0 * x02;
Q += -51 * x02;
int x01 = nextQ();
I += 36 * x01;
Q += -36 * x01;
int x00 = nextQ();
I += 51 * x00;
Q += 0 * x00;
I *= gain; I *= gain;
I >>= 8; I += 32614; // 127.4 * 256
I += 127.4 * 256; I >>= 9; // one extra division by 2 because we add 2 samples
I >>= 8;
Q *= gain; Q *= gain;
Q >>= 8; Q += 32614;
Q += 127.4 * 256; Q >>= 9;
Q >>= 8;
return (struct IQ){ I, Q }; return (struct IQ){ I, Q };
} }