Skip to content

Commit

Permalink
M2kCalibration: Don't try to load the old vertical offset for firmware
Browse files Browse the repository at this point in the history
which does not contain the calibbias attribute.

Signed-off-by: AlexandraTrifan <[email protected]>
  • Loading branch information
AlexandraTrifan committed Jun 26, 2020
1 parent b56278f commit 483e427
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/analog/m2kanalogin_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/analog/m2kanalogin_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class M2kAnalogInImpl : public M2kAnalogIn
double getMaximumSamplerate() override;

void deinitialize();
bool hasCalibbias();
private:
std::shared_ptr<libm2k::utils::DeviceGeneric> m_ad5625_dev;
std::shared_ptr<libm2k::utils::DeviceGeneric> m_m2k_fabric;
Expand Down
9 changes: 7 additions & 2 deletions src/m2kcalibration_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ANALOG_IN_CHANNEL>(0));
m_adc_ch1_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast<ANALOG_IN_CHANNEL>(1));
if (m_m2k_adc->hasCalibbias()) {
m_adc_ch0_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast<ANALOG_IN_CHANNEL>(0));
m_adc_ch1_vert_offset = m_m2k_adc->getRawVerticalOffset(static_cast<ANALOG_IN_CHANNEL>(1));
} else {
m_adc_ch0_vert_offset = 0;
m_adc_ch1_vert_offset = 0;
}

m_m2k_adc->setAdcCalibOffset(static_cast<ANALOG_IN_CHANNEL>(0), 2048);
m_m2k_adc->setVerticalOffset(static_cast<ANALOG_IN_CHANNEL>(0), 0);
Expand Down

0 comments on commit 483e427

Please sign in to comment.