mirror of
https://github.com/greatscottgadgets/hackrf.git
synced 2026-03-15 03:38:56 +01:00
Decimate automatically in RX and RX sweep modes
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user