Added RFNOC based LO frequency offset

This commit is contained in:
Xavier Arteaga 2021-04-19 11:05:02 +02:00 committed by Andre Puschmann
parent ac375f07d9
commit 0999b271ba
1 changed files with 23 additions and 0 deletions

View File

@ -24,6 +24,7 @@ private:
uhd::stream_args_t stream_args = {};
double lo_freq_tx_hz = 0.0;
double lo_freq_rx_hz = 0.0;
double lo_freq_offset_hz = 0.0;
uhd_error usrp_make_internal(const uhd::device_addr_t& dev_addr) override
{
@ -161,6 +162,20 @@ public:
dev_addr.pop("lo_freq_rx_hz");
}
// LO Frequency offset automatic
if (dev_addr.has_key("lo_freq_offset_hz")) {
lo_freq_offset_hz = dev_addr.cast("lo_freq_offset_hz", lo_freq_offset_hz);
dev_addr.pop("lo_freq_offset_hz");
if (std::isnormal(lo_freq_tx_hz)) {
Warning("'lo_freq_offset_hz' overrides 'lo_freq_tx_hz' (" << lo_freq_tx_hz / 1e6 << " MHz)");
}
if (std::isnormal(lo_freq_rx_hz)) {
Warning("'lo_freq_offset_hz' overrides 'lo_freq_rx_hz' (" << lo_freq_rx_hz / 1e6 << " MHz)");
}
}
// Make USRP
uhd_error err = usrp_multi_make(dev_addr);
if (err != UHD_ERROR_NONE) {
@ -339,6 +354,10 @@ public:
// Create Tune request
uhd::tune_request_t tune_request(target_freq);
if (std::isnormal(lo_freq_offset_hz)) {
lo_freq_tx_hz = target_freq + lo_freq_offset_hz;
}
// If the LO frequency is defined, force a LO frequency and use the
if (std::isnormal(lo_freq_tx_hz)) {
tune_request.rf_freq = lo_freq_tx_hz;
@ -356,6 +375,10 @@ public:
// Create Tune request
uhd::tune_request_t tune_request(target_freq);
if (std::isnormal(lo_freq_offset_hz)) {
lo_freq_rx_hz = target_freq + lo_freq_offset_hz;
}
// If the LO frequency is defined, force a LO frequency and use the
if (std::isnormal(lo_freq_rx_hz)) {
tune_request.rf_freq = lo_freq_rx_hz;