Implement a fast band-pass filter for better SNR

This commit is contained in:
Jan Hamal Dvořák 2024-07-17 20:04:24 +02:00
parent 0e1fc91279
commit bc96b5a9ee

View file

@ -385,7 +385,7 @@ static void rf_rx_stop(void)
static void rf_rx(void) static void rf_rx(void)
{ {
const uint32_t base = (uint32_t)rx_cos; const uint32_t base = (uint32_t)rx_cos;
int prev = 0; int prev1 = 0, prev2 = 0, prev3 = 0, prev4 = 0;
int pos = 0; int pos = 0;
while (true) { while (true) {
@ -430,32 +430,34 @@ static void rf_rx(void)
int sI = 0, sQ = 0; int sI = 0, sQ = 0;
int pos, neg; int pos, neg;
#define next_sample ((-(pos - neg) + prev2 * 2 - prev4))
// +I // +I
pos = *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++; neg = *cos_ptr++;
sI += pos - neg - prev; sI += next_sample;
prev = pos - neg; prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
// +Q // +Q
pos = *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++; neg = *cos_ptr++;
sQ += pos - neg - prev; sQ += next_sample;
prev = pos - neg; prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
// -I // -I
pos = *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++; neg = *cos_ptr++;
sI -= pos - neg - prev; sI -= next_sample;
prev = pos - neg; prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
// -Q // -Q
pos = *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++; neg = *cos_ptr++;
sQ -= pos - neg - prev; sQ -= next_sample;
prev = pos - neg; prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
int64_t I = sI; int64_t I = sI / 4;
int64_t Q = sQ; int64_t Q = sQ / 4;
I *= gain; I *= gain;
I -= (max_amplitude * 181) / 256; I -= (max_amplitude * 181) / 256;