Implement a fast band-pass filter for better SNR
This commit is contained in:
parent
0e1fc91279
commit
bc96b5a9ee
24
src/main.c
24
src/main.c
|
@ -385,7 +385,7 @@ static void rf_rx_stop(void)
|
|||
static void rf_rx(void)
|
||||
{
|
||||
const uint32_t base = (uint32_t)rx_cos;
|
||||
int prev = 0;
|
||||
int prev1 = 0, prev2 = 0, prev3 = 0, prev4 = 0;
|
||||
int pos = 0;
|
||||
|
||||
while (true) {
|
||||
|
@ -430,32 +430,34 @@ static void rf_rx(void)
|
|||
int sI = 0, sQ = 0;
|
||||
int pos, neg;
|
||||
|
||||
#define next_sample ((-(pos - neg) + prev2 * 2 - prev4))
|
||||
|
||||
// +I
|
||||
pos = *cos_ptr++;
|
||||
neg = *cos_ptr++;
|
||||
sI += pos - neg - prev;
|
||||
prev = pos - neg;
|
||||
sI += next_sample;
|
||||
prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
|
||||
|
||||
// +Q
|
||||
pos = *cos_ptr++;
|
||||
neg = *cos_ptr++;
|
||||
sQ += pos - neg - prev;
|
||||
prev = pos - neg;
|
||||
sQ += next_sample;
|
||||
prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
|
||||
|
||||
// -I
|
||||
pos = *cos_ptr++;
|
||||
neg = *cos_ptr++;
|
||||
sI -= pos - neg - prev;
|
||||
prev = pos - neg;
|
||||
sI -= next_sample;
|
||||
prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
|
||||
|
||||
// -Q
|
||||
pos = *cos_ptr++;
|
||||
neg = *cos_ptr++;
|
||||
sQ -= pos - neg - prev;
|
||||
prev = pos - neg;
|
||||
sQ -= next_sample;
|
||||
prev4 = prev3, prev3 = prev2, prev2 = prev1, prev1 = pos - neg;
|
||||
|
||||
int64_t I = sI;
|
||||
int64_t Q = sQ;
|
||||
int64_t I = sI / 4;
|
||||
int64_t Q = sQ / 4;
|
||||
|
||||
I *= gain;
|
||||
I -= (max_amplitude * 181) / 256;
|
||||
|
|
Loading…
Reference in a new issue