From 483e427f88e40dd9d505d9a61eb21b6440eb0276 Mon Sep 17 00:00:00 2001 From: AlexandraTrifan Date: Fri, 26 Jun 2020 10:40:15 +0300 Subject: [PATCH] M2kCalibration: Don't try to load the old vertical offset for firmware which does not contain the calibbias attribute. Signed-off-by: AlexandraTrifan --- src/analog/m2kanalogin_impl.cpp | 5 +++++ src/analog/m2kanalogin_impl.hpp | 1 + src/m2kcalibration_impl.cpp | 9 +++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/analog/m2kanalogin_impl.cpp b/src/analog/m2kanalogin_impl.cpp index c91b7d42..24937280 100644 --- a/src/analog/m2kanalogin_impl.cpp +++ b/src/analog/m2kanalogin_impl.cpp @@ -323,6 +323,11 @@ void M2kAnalogInImpl::deinitialize() } } +bool M2kAnalogInImpl::hasCalibbias() +{ + return m_calibbias_available; +} + const double* M2kAnalogInImpl::getSamplesInterleaved(unsigned int nb_samples) { return this->getSamplesInterleaved(nb_samples, true); diff --git a/src/analog/m2kanalogin_impl.hpp b/src/analog/m2kanalogin_impl.hpp index 9405b64d..9e070158 100644 --- a/src/analog/m2kanalogin_impl.hpp +++ b/src/analog/m2kanalogin_impl.hpp @@ -126,6 +126,7 @@ class M2kAnalogInImpl : public M2kAnalogIn double getMaximumSamplerate() override; void deinitialize(); + bool hasCalibbias(); private: std::shared_ptr m_ad5625_dev; std::shared_ptr m_m2k_fabric; diff --git a/src/m2kcalibration_impl.cpp b/src/m2kcalibration_impl.cpp index 21805ee1..07ff8da5 100644 --- a/src/m2kcalibration_impl.cpp +++ b/src/m2kcalibration_impl.cpp @@ -214,8 +214,13 @@ bool M2kCalibrationImpl::calibrateADCoffset() setCalibrationMode(ADC_GND); // Set DAC channels to middle scale - m_adc_ch0_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast(0)); - m_adc_ch1_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast(1)); + if (m_m2k_adc->hasCalibbias()) { + m_adc_ch0_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast(0)); + m_adc_ch1_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast(1)); + } else { + m_adc_ch0_vert_offset = 0; + m_adc_ch1_vert_offset = 0; + } m_m2k_adc->setAdcCalibOffset(static_cast(0), 2048); m_m2k_adc->setVerticalOffset(static_cast(0), 0);