Transceivert52M: Add option for baseband frequency offset
Allow command line setting of the DSP frequency in UHD. All channels will be tuned with the same offset. Dual-channel tuning with the B210, which uses a single LO, will override the command line offset value and set the DSP frequency automatically. Signed-off-by: Thomas Tsou <tom@tsou.cc>
This commit is contained in:
parent
3ebc772dc2
commit
8e17df7374
|
@ -257,7 +257,7 @@ private:
|
||||||
*/
|
*/
|
||||||
class uhd_device : public RadioDevice {
|
class uhd_device : public RadioDevice {
|
||||||
public:
|
public:
|
||||||
uhd_device(size_t sps, size_t chans, bool diversity);
|
uhd_device(size_t sps, size_t chans, bool diversity, double offset);
|
||||||
~uhd_device();
|
~uhd_device();
|
||||||
|
|
||||||
int open(const std::string &args, bool extref);
|
int open(const std::string &args, bool extref);
|
||||||
|
@ -324,6 +324,7 @@ private:
|
||||||
|
|
||||||
double tx_gain_min, tx_gain_max;
|
double tx_gain_min, tx_gain_max;
|
||||||
double rx_gain_min, rx_gain_max;
|
double rx_gain_min, rx_gain_max;
|
||||||
|
double offset;
|
||||||
|
|
||||||
std::vector<double> tx_gains, rx_gains;
|
std::vector<double> tx_gains, rx_gains;
|
||||||
std::vector<double> tx_freqs, rx_freqs;
|
std::vector<double> tx_freqs, rx_freqs;
|
||||||
|
@ -390,7 +391,7 @@ void uhd_msg_handler(uhd::msg::type_t type, const std::string &msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uhd_device::uhd_device(size_t sps, size_t chans, bool diversity)
|
uhd_device::uhd_device(size_t sps, size_t chans, bool diversity, double offset)
|
||||||
: tx_gain_min(0.0), tx_gain_max(0.0),
|
: tx_gain_min(0.0), tx_gain_max(0.0),
|
||||||
rx_gain_min(0.0), rx_gain_max(0.0),
|
rx_gain_min(0.0), rx_gain_max(0.0),
|
||||||
tx_spp(0), rx_spp(0),
|
tx_spp(0), rx_spp(0),
|
||||||
|
@ -399,6 +400,7 @@ uhd_device::uhd_device(size_t sps, size_t chans, bool diversity)
|
||||||
{
|
{
|
||||||
this->sps = sps;
|
this->sps = sps;
|
||||||
this->chans = chans;
|
this->chans = chans;
|
||||||
|
this->offset = offset;
|
||||||
this->diversity = diversity;
|
this->diversity = diversity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -980,11 +982,12 @@ uhd::tune_request_t uhd_device::select_freq(double freq, size_t chan, bool tx)
|
||||||
std::vector<double> freqs;
|
std::vector<double> freqs;
|
||||||
uhd::tune_request_t treq(freq);
|
uhd::tune_request_t treq(freq);
|
||||||
|
|
||||||
if (chans == 1)
|
if ((chans == 1) || ((chans == 2) && dev_type == UMTRX)) {
|
||||||
return treq;
|
if (offset == 0.0)
|
||||||
else if ((dev_type == UMTRX) && (chans == 2))
|
return treq;
|
||||||
return treq;
|
|
||||||
else if ((dev_type != B210) || (chans > 2) || (chan > 1)) {
|
return uhd::tune_request_t(freq, offset);
|
||||||
|
} else if ((dev_type != B210) || (chans > 2) || (chan > 1)) {
|
||||||
LOG(ALERT) << chans << " channels unsupported";
|
LOG(ALERT) << chans << " channels unsupported";
|
||||||
return treq;
|
return treq;
|
||||||
}
|
}
|
||||||
|
@ -1029,6 +1032,9 @@ bool uhd_device::set_freq(double freq, size_t chan, bool tx)
|
||||||
}
|
}
|
||||||
LOG(INFO) << "\n" << tres.to_pp_string() << std::endl;
|
LOG(INFO) << "\n" << tres.to_pp_string() << std::endl;
|
||||||
|
|
||||||
|
if ((chans == 1) || ((chans == 2) && dev_type == UMTRX))
|
||||||
|
return true;
|
||||||
|
|
||||||
/* Manual RF policy means we intentionally tuned with a baseband
|
/* Manual RF policy means we intentionally tuned with a baseband
|
||||||
* offset for dual-channel purposes. Now retune the other channel
|
* offset for dual-channel purposes. Now retune the other channel
|
||||||
* with the opposite corresponding frequency offset
|
* with the opposite corresponding frequency offset
|
||||||
|
@ -1324,7 +1330,8 @@ std::string smpl_buf::str_code(ssize_t code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioDevice *RadioDevice::make(size_t sps, size_t chans, bool diversity)
|
RadioDevice *RadioDevice::make(size_t sps, size_t chans,
|
||||||
|
bool diversity, double offset)
|
||||||
{
|
{
|
||||||
return new uhd_device(sps, chans, diversity);
|
return new uhd_device(sps, chans, diversity, offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ struct trx_config {
|
||||||
bool extref;
|
bool extref;
|
||||||
bool filler;
|
bool filler;
|
||||||
bool diversity;
|
bool diversity;
|
||||||
|
double offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigurationTable gConfig;
|
ConfigurationTable gConfig;
|
||||||
|
@ -178,6 +179,7 @@ bool trx_setup_config(struct trx_config *config)
|
||||||
ost << " External Reference...... " << refstr << std::endl;
|
ost << " External Reference...... " << refstr << std::endl;
|
||||||
ost << " C0 Filler Table......... " << fillstr << std::endl;
|
ost << " C0 Filler Table......... " << fillstr << std::endl;
|
||||||
ost << " Diversity............... " << divstr << std::endl;
|
ost << " Diversity............... " << divstr << std::endl;
|
||||||
|
ost << " Tuning offset........... " << config->offset << std::endl;
|
||||||
std::cout << ost << std::endl;
|
std::cout << ost << std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -283,7 +285,8 @@ static void print_help()
|
||||||
" -x Enable external 10 MHz reference\n"
|
" -x Enable external 10 MHz reference\n"
|
||||||
" -s Samples-per-symbol (1 or 4)\n"
|
" -s Samples-per-symbol (1 or 4)\n"
|
||||||
" -c Number of ARFCN channels (default=1)\n"
|
" -c Number of ARFCN channels (default=1)\n"
|
||||||
" -f Enable C0 filler table\n",
|
" -f Enable C0 filler table\n"
|
||||||
|
" -o Set baseband frequency offset (default=auto)\n",
|
||||||
"EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG");
|
"EMERG, ALERT, CRT, ERR, WARNING, NOTICE, INFO, DEBUG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +300,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
|
||||||
config->extref = false;
|
config->extref = false;
|
||||||
config->filler = false;
|
config->filler = false;
|
||||||
config->diversity = false;
|
config->diversity = false;
|
||||||
|
config->offset = 0.0;
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfs:")) != -1) {
|
while ((option = getopt(argc, argv, "ha:l:i:p:c:dxfo:s:")) != -1) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'h':
|
case 'h':
|
||||||
print_help();
|
print_help();
|
||||||
|
@ -328,6 +332,9 @@ static void handle_options(int argc, char **argv, struct trx_config *config)
|
||||||
case 'f':
|
case 'f':
|
||||||
config->filler = true;
|
config->filler = true;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
config->offset = atof(optarg);
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
config->sps = atoi(optarg);
|
config->sps = atoi(optarg);
|
||||||
if ((config->sps != 1) && (config->sps != 4)) {
|
if ((config->sps != 1) && (config->sps != 4)) {
|
||||||
|
@ -366,7 +373,8 @@ int main(int argc, char *argv[])
|
||||||
srandom(time(NULL));
|
srandom(time(NULL));
|
||||||
|
|
||||||
/* Create the low level device object */
|
/* Create the low level device object */
|
||||||
usrp = RadioDevice::make(config.sps, config.chans, config.diversity);
|
usrp = RadioDevice::make(config.sps, config.chans,
|
||||||
|
config.diversity, config.offset);
|
||||||
type = usrp->open(config.dev_args, config.extref);
|
type = usrp->open(config.dev_args, config.extref);
|
||||||
if (type < 0) {
|
if (type < 0) {
|
||||||
LOG(ALERT) << "Failed to create radio device" << std::endl;
|
LOG(ALERT) << "Failed to create radio device" << std::endl;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class RadioDevice {
|
||||||
enum RadioInterfaceType { NORMAL, RESAMP_64M, RESAMP_100M, DIVERSITY };
|
enum RadioInterfaceType { NORMAL, RESAMP_64M, RESAMP_100M, DIVERSITY };
|
||||||
|
|
||||||
static RadioDevice *make(size_t sps, size_t chans = 1,
|
static RadioDevice *make(size_t sps, size_t chans = 1,
|
||||||
bool diversity = false);
|
bool diversity = false, double offset = 0.0);
|
||||||
|
|
||||||
/** Initialize the USRP */
|
/** Initialize the USRP */
|
||||||
virtual int open(const std::string &args = "", bool extref = false)=0;
|
virtual int open(const std::string &args = "", bool extref = false)=0;
|
||||||
|
|
Loading…
Reference in New Issue