mirror of
https://github.com/greatscottgadgets/hackrf.git
synced 2026-03-14 03:08:56 +01:00
Move tuning config search to radio_set_frequency()
This commit is contained in:
@@ -246,19 +246,33 @@ radio_error_t radio_set_frequency(
|
||||
return RADIO_ERR_INVALID_CONFIG;
|
||||
}
|
||||
#else
|
||||
const tune_config_t* tune_config;
|
||||
switch (config->mode) {
|
||||
case TRANSCEIVER_MODE_RX:
|
||||
ok = tuning_set_frequency(max2831_tune_config_rx, frequency.hz);
|
||||
tune_config = max2831_tune_config_rx;
|
||||
break;
|
||||
case TRANSCEIVER_MODE_RX_SWEEP:
|
||||
ok = tuning_set_frequency(max2831_tune_config_rx_sweep, frequency.hz);
|
||||
tune_config = max2831_tune_config_rx_sweep;
|
||||
break;
|
||||
case TRANSCEIVER_MODE_TX:
|
||||
ok = tuning_set_frequency(max2831_tune_config_tx, frequency.hz);
|
||||
tune_config = max2831_tune_config_tx;
|
||||
break;
|
||||
default:
|
||||
return RADIO_ERR_INVALID_CONFIG;
|
||||
}
|
||||
bool found = false;
|
||||
for (; (tune_config->rf_range_end_mhz != 0) || (tune_config->if_mhz != 0);
|
||||
tune_config++) {
|
||||
if (tune_config->rf_range_end_mhz > (frequency.hz / FREQ_ONE_MHZ)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return RADIO_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
ok = tuning_set_frequency(tune_config, frequency.hz);
|
||||
#endif
|
||||
if (!ok) {
|
||||
return RADIO_ERR_INVALID_PARAM;
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include "operacake.h"
|
||||
#include "platform_detect.h"
|
||||
|
||||
#define FREQ_ONE_MHZ (1000ULL * 1000)
|
||||
|
||||
#ifndef PRALINE
|
||||
|
||||
#define MIN_LP_FREQ_MHZ (0)
|
||||
@@ -147,7 +145,6 @@ bool set_freq(const uint64_t freq)
|
||||
|
||||
bool tuning_set_frequency(const tune_config_t* cfg, const uint64_t freq)
|
||||
{
|
||||
bool found;
|
||||
uint64_t mixer_freq_hz;
|
||||
uint64_t real_mixer_freq_hz;
|
||||
|
||||
@@ -157,18 +154,6 @@ bool tuning_set_frequency(const tune_config_t* cfg, const uint64_t freq)
|
||||
|
||||
const uint16_t freq_mhz = freq / FREQ_ONE_MHZ;
|
||||
|
||||
found = false;
|
||||
for (; cfg->rf_range_end_mhz != 0; cfg++) {
|
||||
if (cfg->rf_range_end_mhz > freq_mhz) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
|
||||
max2831_mode_t prior_max2831_mode = max2831_mode(&max283x);
|
||||
max2831_set_mode(&max283x, MAX2831_MODE_STANDBY);
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define FREQ_ONE_MHZ (1000ULL * 1000)
|
||||
|
||||
bool set_freq(const uint64_t freq);
|
||||
bool set_freq_explicit(
|
||||
const uint64_t if_freq_hz,
|
||||
|
||||
Reference in New Issue
Block a user