Reduce jitter and use HPF to improve SNR

This commit is contained in:
Jan Hamal Dvořák 2024-07-16 18:56:30 +02:00
parent 38b7ec34f6
commit 574c474c6e

View file

@ -48,7 +48,7 @@ static uint32_t lo_cos[LO_WORDS] __attribute__((__aligned__(1 << LO_BITS_DEPTH))
#define RX_BITS_DEPTH 13 #define RX_BITS_DEPTH 13
#define RX_WORDS (1 << (RX_BITS_DEPTH - 2)) #define RX_WORDS (1 << (RX_BITS_DEPTH - 2))
static_assert(RX_STRIDE * 4 < RX_WORDS, "RX_STRIDE * 4 < RX_WORDS"); static_assert(RX_STRIDE * 4 <= RX_WORDS, "RX_STRIDE * 4 <= RX_WORDS");
static uint32_t rx_cos[RX_WORDS] __attribute__((__aligned__(1 << RX_BITS_DEPTH))); static uint32_t rx_cos[RX_WORDS] __attribute__((__aligned__(1 << RX_BITS_DEPTH)));
@ -142,7 +142,7 @@ static void init_fb()
const uint16_t insn[] = { const uint16_t insn[] = {
pio_encode_mov_not(pio_pins, pio_pins) | pio_encode_sideset(1, 1) | pio_encode_mov_not(pio_pins, pio_pins) | pio_encode_sideset(1, 1) |
pio_encode_delay(0), pio_encode_delay(0),
pio_encode_nop() | pio_encode_sideset(1, 0), pio_encode_nop() | pio_encode_sideset(1, 0) | pio_encode_delay(0),
}; };
pio_program_t prog = { pio_program_t prog = {
@ -217,11 +217,11 @@ static void init_ad()
* Should wrap here. * Should wrap here.
* Jump to this portion must be inserted from the outside. * Jump to this portion must be inserted from the outside.
*/ */
pio_encode_in(pio_y, 32),
pio_encode_in(pio_x, 32), pio_encode_in(pio_x, 32),
pio_encode_in(pio_y, 32),
pio_encode_set(pio_x, 0), pio_encode_set(pio_x, 0),
pio_encode_set(pio_y, 0), pio_encode_set(pio_y, 0),
pio_encode_jmp(1), pio_encode_out(pio_pc, 2),
}; };
pio_program_t prog = { pio_program_t prog = {
@ -421,6 +421,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 pos = 0; int pos = 0;
while (true) { while (true) {
@ -463,20 +464,31 @@ static void rf_rx(void)
for (int i = 0; i < IQ_SAMPLES; i++) { for (int i = 0; i < IQ_SAMPLES; i++) {
int sI = 0, sQ = 0; int sI = 0, sQ = 0;
int pos, neg;
/* Convert to I/Q signal. */ // +I
pos = *cos_ptr++;
neg = *cos_ptr++;
sI += pos - neg - prev;
prev = pos - neg;
sI += *cos_ptr++; // +Q
sI -= *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++;
sQ += pos - neg - prev;
prev = pos - neg;
sQ += *cos_ptr++; // -I
sQ -= *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++;
sI -= pos - neg - prev;
prev = pos - neg;
sI -= *cos_ptr++; // -Q
sI += *cos_ptr++; pos = *cos_ptr++;
neg = *cos_ptr++;
sQ -= *cos_ptr++; sQ -= pos - neg - prev;
sQ += *cos_ptr++; prev = pos - neg;
int64_t I = sI; int64_t I = sI;
int64_t Q = sQ; int64_t Q = sQ;