Skip to content

Commit 4ccbbab

Browse files
Teo PerisanuTeo Perisanu
authored andcommitted
M2kHardwareTrigger: Add trigger out for analogical interface.
Both DACs share the same trigger mechanism - only one DAC should be used in order to configure the triggering system. Implement the functionalities based on the generic definitions. Signed-off-by: Teo Perisanu <[email protected]>
1 parent 8f0011c commit 4ccbbab

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

include/libm2k/m2khardwaretrigger.hpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,48 @@ class LIBM2K_API M2kHardwareTrigger
446446
* @return the trigger condition
447447
*/
448448
virtual M2K_TRIGGER_CONDITION_DIGITAL getDigitalOutCondition() const = 0;
449+
450+
451+
/**
452+
* @brief Select which interface triggers the AnalogOut.
453+
* @param src: of type M2K_TRIGGER_OUT_SOURCE:\n
454+
* SRC_OUT_NONE - no trigger events
455+
* SRC_OUT_TRIGGER_IN - trigger events on the TI(trigger in) pin trigger the DigitalOut interface;\n
456+
* SRC_OUT_TRIGGER_OUT - trigger events on the TO(trigger out) pin trigger the DigitalOut interface;\n
457+
* SRC_OUT_ANALOG_IN - trigger events on the AnalogIn interface trigger the DigitalOut interface;\n
458+
* SRC_OUT_DIGITAL_IN - trigger events on the DigitalIn interface trigger the DigitalOut interface;\n
459+
* @note Only available from firmware v0.26.
460+
*/
461+
virtual void setAnalogOutSource(M2K_TRIGGER_OUT_SOURCE src) = 0;
462+
463+
464+
/**
465+
* @brief Retrieve the source of the AnalogOut interface trigger event.
466+
* @return M2K_TRIGGER_OUT_SOURCE :\n
467+
* SRC_OUT_NONE;\n
468+
* SRC_OUT_TRIGGER_IN;\n
469+
* SRC_OUT_TRIGGER_OUT;\n
470+
* SRC_OUT_ANALOG_IN;\n
471+
* SRC_OUT_DIGITAL_IN;\n
472+
* @note Only available from firmware v0.26.
473+
*/
474+
virtual M2K_TRIGGER_OUT_SOURCE getAnalogOutSource() const = 0;
475+
476+
477+
/**
478+
* @brief Set the trigger condition for the TI/TO in order to trigger the AnalogOut interface
479+
* @param cond the specific trigger condition
480+
*
481+
* @note to have any effect the digital out source must be set to TI or TO
482+
*/
483+
virtual void setAnalogOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond) = 0;
484+
485+
486+
/**
487+
* @brief Get the trigger condition of the TI/TO pins that triggers the AnalogOut interface
488+
* @return the trigger condition
489+
*/
490+
virtual M2K_TRIGGER_CONDITION_DIGITAL getAnalogOutCondition() const = 0;
449491
};
450492
}
451493

src/m2khardwaretrigger_impl.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,27 @@ M2K_TRIGGER_CONDITION_DIGITAL M2kHardwareTriggerImpl::getDigitalOutCondition() c
594594
THROW_M2K_EXCEPTION("Invalid firmware version. Minimum required version: v0.26", libm2k::EXC_INVALID_FIRMWARE_VERSION);
595595
return NO_TRIGGER_DIGITAL;
596596
}
597+
598+
void M2kHardwareTriggerImpl::setAnalogOutSource(M2K_TRIGGER_OUT_SOURCE src)
599+
{
600+
UNUSED(src);
601+
THROW_M2K_EXCEPTION("Invalid firmware version. Minimum required version: v0.26", libm2k::EXC_INVALID_FIRMWARE_VERSION);
602+
}
603+
604+
M2K_TRIGGER_OUT_SOURCE M2kHardwareTriggerImpl::getAnalogOutSource() const
605+
{
606+
THROW_M2K_EXCEPTION("Invalid firmware version. Minimum required version: v0.26", libm2k::EXC_INVALID_FIRMWARE_VERSION);
607+
return SRC_OUT_NONE;
608+
}
609+
610+
void M2kHardwareTriggerImpl::setAnalogOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond)
611+
{
612+
UNUSED(cond);
613+
THROW_M2K_EXCEPTION("Invalid firmware version. Minimum required version: v0.26", libm2k::EXC_INVALID_FIRMWARE_VERSION);
614+
}
615+
616+
M2K_TRIGGER_CONDITION_DIGITAL M2kHardwareTriggerImpl::getAnalogOutCondition() const
617+
{
618+
THROW_M2K_EXCEPTION("Invalid firmware version. Minimum required version: v0.26", libm2k::EXC_INVALID_FIRMWARE_VERSION);
619+
return NO_TRIGGER_DIGITAL;
620+
}

src/m2khardwaretrigger_impl.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ class M2kHardwareTriggerImpl : public M2kHardwareTrigger
111111
M2K_TRIGGER_OUT_SOURCE getDigitalOutSource() const override;
112112
void setDigitalOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond) override;
113113
M2K_TRIGGER_CONDITION_DIGITAL getDigitalOutCondition() const override;
114+
void setAnalogOutSource(M2K_TRIGGER_OUT_SOURCE src) override;
115+
M2K_TRIGGER_OUT_SOURCE getAnalogOutSource() const override;
116+
void setAnalogOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond) override;
117+
M2K_TRIGGER_CONDITION_DIGITAL getAnalogOutCondition() const override;
118+
114119
protected:
115120
struct iio_device *m_trigger_device;
116121
std::vector<Channel *> m_analog_channels;

src/m2khardwaretrigger_v0.26_impl.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,27 @@ libm2k::M2kHardwareTriggerV026Impl::M2kHardwareTriggerV026Impl(struct iio_contex
5151
bool hasTriggerSource;
5252
bool hasTriggerCondition;
5353
m_digital_trigger_device = make_shared<libm2k::utils::DeviceOut>(ctx, "m2k-logic-analyzer-tx");
54+
// both dac a and dac b share the same trigger
55+
m_analog_trigger_device = make_shared<libm2k::utils::DeviceOut>(ctx, "m2k-dac-a");
5456
if (!m_digital_trigger_device) {
5557
THROW_M2K_EXCEPTION("No digital TX trigger available", libm2k::EXC_RUNTIME_ERROR);
5658
}
59+
if (!m_analog_trigger_device) {
60+
THROW_M2K_EXCEPTION("No analog TX trigger available", libm2k::EXC_RUNTIME_ERROR);
61+
}
62+
5763
hasTriggerSource = m_digital_trigger_device->hasGlobalAttribute(m_source_attr);
5864
hasTriggerCondition = m_digital_trigger_device->hasGlobalAttribute(m_condition_attr);
5965
if (!hasTriggerSource || !hasTriggerCondition) {
6066
THROW_M2K_EXCEPTION("Analog TX trigger is not available", libm2k::EXC_RUNTIME_ERROR);
6167
}
6268

69+
hasTriggerSource = m_analog_trigger_device->hasGlobalAttribute(m_source_attr);
70+
hasTriggerCondition = m_analog_trigger_device->hasGlobalAttribute(m_condition_attr);
71+
if (!hasTriggerSource || !hasTriggerCondition) {
72+
THROW_M2K_EXCEPTION("Analog TX trigger is not available", libm2k::EXC_RUNTIME_ERROR);
73+
}
74+
6375
if (init) {
6476
reset();
6577
}
@@ -69,6 +81,8 @@ void libm2k::M2kHardwareTriggerV026Impl::reset() {
6981
M2kHardwareTriggerV024Impl::reset();
7082
setDigitalOutSource(SRC_OUT_NONE);
7183
setDigitalOutCondition(NO_TRIGGER_DIGITAL);
84+
setAnalogOutSource(SRC_OUT_NONE);
85+
setAnalogOutCondition(NO_TRIGGER_DIGITAL);
7286
}
7387

7488
void libm2k::M2kHardwareTriggerV026Impl::setDigitalOutSource(libm2k::M2K_TRIGGER_OUT_SOURCE src)
@@ -91,6 +105,26 @@ libm2k::M2K_TRIGGER_CONDITION_DIGITAL libm2k::M2kHardwareTriggerV026Impl::getDig
91105
return getTriggerOutCondition(m_digital_trigger_device);
92106
}
93107

108+
void libm2k::M2kHardwareTriggerV026Impl::setAnalogOutSource(libm2k::M2K_TRIGGER_OUT_SOURCE src)
109+
{
110+
setTriggerOutSource(src, m_analog_trigger_device);
111+
}
112+
113+
libm2k::M2K_TRIGGER_OUT_SOURCE libm2k::M2kHardwareTriggerV026Impl::getAnalogOutSource() const
114+
{
115+
return getTriggerOutSource(m_analog_trigger_device);
116+
}
117+
118+
void libm2k::M2kHardwareTriggerV026Impl::setAnalogOutCondition(libm2k::M2K_TRIGGER_CONDITION_DIGITAL cond)
119+
{
120+
setTriggerOutCondition(cond, m_analog_trigger_device);
121+
}
122+
123+
libm2k::M2K_TRIGGER_CONDITION_DIGITAL libm2k::M2kHardwareTriggerV026Impl::getAnalogOutCondition() const
124+
{
125+
return getTriggerOutCondition(m_analog_trigger_device);
126+
}
127+
94128
void libm2k::M2kHardwareTriggerV026Impl::setTriggerOutSource(libm2k::M2K_TRIGGER_OUT_SOURCE src,
95129
const std::shared_ptr<libm2k::utils::DeviceOut>& device)
96130
{

src/m2khardwaretrigger_v0.26_impl.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,22 @@ class M2kHardwareTriggerV026Impl : public M2kHardwareTriggerV024Impl {
4444

4545
M2K_TRIGGER_CONDITION_DIGITAL getDigitalOutCondition() const override;
4646

47+
void setAnalogOutSource(M2K_TRIGGER_OUT_SOURCE src) override;
48+
49+
M2K_TRIGGER_OUT_SOURCE getAnalogOutSource() const override;
50+
51+
void setAnalogOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond) override;
52+
53+
M2K_TRIGGER_CONDITION_DIGITAL getAnalogOutCondition() const override;
54+
4755
protected:
4856
void setTriggerOutSource(M2K_TRIGGER_OUT_SOURCE src, const std::shared_ptr<libm2k::utils::DeviceOut>& device);
4957
M2K_TRIGGER_OUT_SOURCE getTriggerOutSource(const std::shared_ptr<libm2k::utils::DeviceOut>& device) const;
5058
void setTriggerOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond, const std::shared_ptr<libm2k::utils::DeviceOut>& device);
5159
M2K_TRIGGER_CONDITION_DIGITAL getTriggerOutCondition(const std::shared_ptr<libm2k::utils::DeviceOut>& device) const;
5260

5361
std::shared_ptr<libm2k::utils::DeviceOut> m_digital_trigger_device;
62+
std::shared_ptr<libm2k::utils::DeviceOut> m_analog_trigger_device;
5463

5564
static std::vector<std::string> m_trigger_source;
5665
static std::vector<std::string> m_trigger_cond;

0 commit comments

Comments
 (0)