aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-04-26 17:03:14 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-04-26 17:03:14 +0200
commitb17001011204a47432a1deb970cd15466c16f0bf (patch)
treef934f4ee04c6ddfd5bdea7683e384ebfe08d06ea /src
parentfd05ca739d94b23609e85e074fb659b5e279d358 (diff)
downloaddabmod-b17001011204a47432a1deb970cd15466c16f0bf.tar.gz
dabmod-b17001011204a47432a1deb970cd15466c16f0bf.tar.bz2
dabmod-b17001011204a47432a1deb970cd15466c16f0bf.zip
Properly set TX frequency
Diffstat (limited to 'src')
-rw-r--r--src/output/Dexter.cpp25
-rw-r--r--src/output/Dexter.h1
2 files changed, 18 insertions, 8 deletions
diff --git a/src/output/Dexter.cpp b/src/output/Dexter.cpp
index 2d053aa..4cb9cd8 100644
--- a/src/output/Dexter.cpp
+++ b/src/output/Dexter.cpp
@@ -87,6 +87,11 @@ Dexter::Dexter(SDRDeviceConfig& config) :
throw std::runtime_error("Dexter: Unable to find dexter_dsp_tx iio device");
}
+ m_ad9957 = iio_context_find_device(m_ctx, "ad9957");
+ if (not m_ad9957) {
+ throw std::runtime_error("Dexter: Unable to find ad9957 iio device");
+ }
+
m_ad9957_tx0 = iio_context_find_device(m_ctx, "ad9957_tx0");
if (not m_ad9957_tx0) {
throw std::runtime_error("Dexter: Unable to find ad9957_tx0 iio device");
@@ -281,8 +286,8 @@ void Dexter::tune(double lo_offset, double frequency)
long long freq = frequency;
int r = 0;
- if ((r = iio_device_attr_write_longlong(m_ad9957_tx0, "center_frequency", freq)) != 0) {
- etiLog.level(warn) << "Failed to set ad9957_tx0.center_frequency = " << freq << " : " << get_iio_error(r);
+ if ((r = iio_device_attr_write_longlong(m_ad9957, "center_frequency", freq)) != 0) {
+ etiLog.level(warn) << "Failed to set ad9957.center_frequency = " << freq << " : " << get_iio_error(r);
}
long long lo_offs = lo_offset;
@@ -294,17 +299,21 @@ void Dexter::tune(double lo_offset, double frequency)
double Dexter::get_tx_freq(void) const
{
- long long frequency = 0;
+ long long lo_offset = 0;
int r = 0;
- if ((r = iio_device_attr_read_longlong(m_dexter_dsp_tx, "frequency0", &frequency)) != 0) {
- etiLog.level(warn) << "Failed to read dexter_dsp_tx.frequency0 = " <<
- frequency << " : " << get_iio_error(r);
+ if ((r = iio_device_attr_read_longlong(m_dexter_dsp_tx, "frequency0", &lo_offset)) != 0) {
+ etiLog.level(warn) << "Failed to read dexter_dsp_tx.frequency0: " << get_iio_error(r);
return 0;
}
- else {
- return frequency + 204800000;
+
+ long long frequency = 0;
+ if ((r = iio_device_attr_read_longlong(m_ad9957, "center_frequency", &frequency)) != 0) {
+ etiLog.level(warn) << "Failed to read ad9957.center_frequency: " << get_iio_error(r);
+ return 0;
}
+
+ return frequency + lo_offset;
}
void Dexter::set_txgain(double txgain)
diff --git a/src/output/Dexter.h b/src/output/Dexter.h
index 7925de7..3d47f87 100644
--- a/src/output/Dexter.h
+++ b/src/output/Dexter.h
@@ -93,6 +93,7 @@ class Dexter : public Output::SDRDevice
struct iio_context* m_ctx = nullptr;
struct iio_device* m_dexter_dsp_tx = nullptr;
+ struct iio_device* m_ad9957 = nullptr;
struct iio_device* m_ad9957_tx0 = nullptr;
struct iio_channel* m_tx_channel = nullptr;
struct iio_buffer *m_buffer = nullptr;