Decimate automatically in RX and RX sweep modes

This commit is contained in:
Michael Ossmann
2025-12-30 20:35:25 -05:00
parent df6543073b
commit 10e8b0d934
3 changed files with 38 additions and 0 deletions

View File

@@ -376,6 +376,9 @@ radio_t radio = {
.clock[RADIO_CLOCK_CLKIN] = {.enable = false},
.clock[RADIO_CLOCK_CLKOUT] = {.enable = false},
.trigger_enable = false,
#ifdef PRALINE
.resampling_n = 0,
#endif
},
.clock_source = CLOCK_SOURCE_HACKRF,
},

View File

@@ -52,7 +52,36 @@ radio_error_t radio_set_sample_rate(
return RADIO_OK;
}
#ifdef PRALINE
#define MAX_AFE_RATE 40000000
#define MAX_N 5
uint8_t n = 0; // resampling ratio is 2**n
if ((config->mode == TRANSCEIVER_MODE_RX) ||
(config->mode == TRANSCEIVER_MODE_RX_SWEEP)) {
n = 1;
uint32_t afe_rate_x2 = 2 * sample_rate.hz;
while ((afe_rate_x2 <= MAX_AFE_RATE) && (n < MAX_N)) {
afe_rate_x2 <<= 1;
n++;
}
fpga_set_rx_decimation_ratio(&fpga, n);
}
config->resampling_n = n;
bool ok = sample_rate_frac_set(sample_rate.num << n, sample_rate.div);
if (ok) {
config->sample_rate[element] = sample_rate;
radio_channel_t* channel = &radio->channel[chan_id];
radio_frequency_t frequency =
radio_get_frequency(radio, channel->id, RADIO_FREQUENCY_RF);
ok = radio_set_frequency(
radio,
channel->id,
RADIO_FREQUENCY_RF,
frequency);
}
#else
bool ok = sample_rate_frac_set(sample_rate.num, sample_rate.div);
#endif
if (!ok) {
return RADIO_ERR_INVALID_PARAM;
}

View File

@@ -156,6 +156,12 @@ typedef struct {
// currently active transceiver mode
transceiver_mode_t mode;
#ifdef PRALINE
// resampling ratio is 2**n
uint8_t resampling_n;
#endif
} radio_config_t;
typedef struct radio_channel_t {