Skip to content

Commit 3696e12

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 8388364 commit 3696e12

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,25 @@ M2K_TRIGGER_CONDITION_DIGITAL M2kHardwareTriggerImpl::getDigitalOutCondition() c
595595
throw_exception(EXC_INVALID_FIRMWARE_VERSION,"v0.26");
596596
return NO_TRIGGER_DIGITAL;
597597
}
598+
599+
void M2kHardwareTriggerImpl::setAnalogOutSource(M2K_TRIGGER_OUT_SOURCE src)
600+
{
601+
throw_exception(EXC_INVALID_FIRMWARE_VERSION,"v0.26");
602+
}
603+
604+
M2K_TRIGGER_OUT_SOURCE M2kHardwareTriggerImpl::getAnalogOutSource() const
605+
{
606+
throw_exception(EXC_INVALID_FIRMWARE_VERSION,"v0.26");
607+
return SRC_OUT_NONE;
608+
}
609+
610+
void M2kHardwareTriggerImpl::setAnalogOutCondition(M2K_TRIGGER_CONDITION_DIGITAL cond)
611+
{
612+
throw_exception(EXC_INVALID_FIRMWARE_VERSION,"v0.26");
613+
}
614+
615+
M2K_TRIGGER_CONDITION_DIGITAL M2kHardwareTriggerImpl::getAnalogOutCondition() const
616+
{
617+
throw_exception(EXC_INVALID_FIRMWARE_VERSION,"v0.26");
618+
return NO_TRIGGER_DIGITAL;
619+
}

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_exception(EXC_INVALID_PARAMETER, "No digital TX trigger available");
5658
}
59+
if (!m_analog_trigger_device) {
60+
throw_exception(EXC_INVALID_PARAMETER, "No analog TX trigger available");
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_exception(EXC_INVALID_PARAMETER, "Analog TX trigger is not available");
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_exception(EXC_INVALID_PARAMETER, "Analog TX trigger is not available");
73+
}
74+
6375
if (init) {
6476
reset();
6577
}
@@ -70,6 +82,9 @@ void libm2k::M2kHardwareTriggerV026Impl::reset()
7082
M2kHardwareTriggerV024Impl::reset();
7183
setDigitalOutSource(SRC_OUT_NONE);
7284
setDigitalOutCondition(NO_TRIGGER_DIGITAL);
85+
setAnalogOutSource(SRC_OUT_NONE);
86+
setAnalogOutCondition(NO_TRIGGER_DIGITAL);
87+
}
7388

7489
void libm2k::M2kHardwareTriggerV026Impl::setDigitalOutSource(libm2k::M2K_TRIGGER_OUT_SOURCE src)
7590
{
@@ -90,6 +105,25 @@ libm2k::M2K_TRIGGER_CONDITION_DIGITAL libm2k::M2kHardwareTriggerV026Impl::getDig
90105
{
91106
return getTriggerOutCondition(m_digital_trigger_device);
92107
}
108+
109+
void libm2k::M2kHardwareTriggerV026Impl::setAnalogOutSource(libm2k::M2K_TRIGGER_OUT_SOURCE src)
110+
{
111+
setTriggerOutSource(src, m_analog_trigger_device);
112+
}
113+
114+
libm2k::M2K_TRIGGER_OUT_SOURCE libm2k::M2kHardwareTriggerV026Impl::getAnalogOutSource() const
115+
{
116+
return getTriggerOutSource(m_analog_trigger_device);
117+
}
118+
119+
void libm2k::M2kHardwareTriggerV026Impl::setAnalogOutCondition(libm2k::M2K_TRIGGER_CONDITION_DIGITAL cond)
120+
{
121+
setTriggerOutCondition(cond, m_analog_trigger_device);
122+
}
123+
124+
libm2k::M2K_TRIGGER_CONDITION_DIGITAL libm2k::M2kHardwareTriggerV026Impl::getAnalogOutCondition() const
125+
{
126+
return getTriggerOutCondition(m_analog_trigger_device);
93127
}
94128

95129
void libm2k::M2kHardwareTriggerV026Impl::setTriggerOutSource(libm2k::M2K_TRIGGER_OUT_SOURCE src,

src/m2khardwaretrigger_v0.26_impl.hpp

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

4646
M2K_TRIGGER_CONDITION_DIGITAL getDigitalOutCondition() const override;
4747

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

5462
std::shared_ptr<libm2k::utils::DeviceOut> m_digital_trigger_device;
63+
std::shared_ptr<libm2k::utils::DeviceOut> m_analog_trigger_device;
5564

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

0 commit comments

Comments
 (0)