Loading...
Searching...
No Matches
m2kdigital.hpp
/*
* Copyright (c) 2019 Analog Devices Inc.
*
* This file is part of libm2k
* (see http://www.github.com/analogdevicesinc/libm2k).
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef M2KDIGITAL_HPP
#define M2KDIGITAL_HPP
#include <libm2k/m2kglobal.hpp>
#include <libm2k/digital/enums.hpp>
#include <libm2k/analog/enums.hpp>
#include <libm2k/m2khardwaretrigger.hpp>
#include <string>
#include <vector>
namespace libm2k {
namespace digital {
class LIBM2K_API M2kDigital
{
public:
virtual ~M2kDigital() {}
virtual void reset() = 0;
virtual void setDirection(unsigned short mask) = 0;
virtual void setDirection(unsigned int index, DIO_DIRECTION dir) = 0;
virtual void setDirection(unsigned int index, bool dir) = 0;
virtual void setDirection(DIO_CHANNEL index, bool dir) = 0;
virtual void setDirection(DIO_CHANNEL index, DIO_DIRECTION dir) = 0;
virtual DIO_DIRECTION getDirection(DIO_CHANNEL index) = 0;
virtual void setValueRaw(DIO_CHANNEL index, DIO_LEVEL level) = 0;
virtual void push(std::vector<unsigned short> const &data) = 0;
virtual void push(unsigned short *data, unsigned int nb_samples) = 0;
virtual void setValueRaw(unsigned int index, DIO_LEVEL level) = 0;
virtual void setValueRaw(DIO_CHANNEL index, bool level) = 0;
virtual DIO_LEVEL getValueRaw(DIO_CHANNEL index) = 0;
virtual DIO_LEVEL getValueRaw(unsigned int index) = 0;
virtual void stopBufferOut() = 0;
virtual void startAcquisition(unsigned int nb_samples) = 0;
virtual void stopAcquisition() = 0;
virtual void cancelAcquisition() = 0;
virtual void cancelBufferOut() = 0;
virtual std::vector<unsigned short> getSamples(unsigned int nb_samples) = 0;
virtual const unsigned short *getSamplesP(unsigned int nb_samples) = 0;
/* Enable/disable TX channels only*/
virtual void enableChannel(unsigned int index, bool enable) = 0;
virtual void enableChannel(DIO_CHANNEL index, bool enable) = 0;
virtual void enableAllOut(bool enable) = 0;
virtual bool anyChannelEnabled(DIO_DIRECTION dir) = 0;
virtual void setOutputMode(DIO_CHANNEL chn, DIO_MODE mode) = 0;
virtual void setOutputMode(unsigned int chn, DIO_MODE mode) = 0;
virtual DIO_MODE getOutputMode(DIO_CHANNEL chn) = 0;
virtual DIO_MODE getOutputMode(unsigned int chn) = 0;
virtual double setSampleRateIn(double samplerate) = 0;
virtual double setSampleRateOut(double samplerate) = 0;
virtual double getSampleRateIn() = 0;
virtual double getSampleRateOut() = 0;
virtual bool getCyclic() = 0;
virtual void setCyclic(bool cyclic) = 0;
virtual libm2k::M2kHardwareTrigger* getTrigger() = 0;
virtual void setKernelBuffersCountIn(unsigned int count) = 0;
virtual void setKernelBuffersCountOut(unsigned int count) = 0;
virtual struct IIO_OBJECTS getIioObjects() = 0;
virtual unsigned int getNbChannelsIn() = 0;
virtual unsigned int getNbChannelsOut() = 0;
virtual void getSamples(std::vector<unsigned short> &data, unsigned int nb_samples) = 0;
virtual void setRateMux() = 0;
virtual void resetRateMux() = 0;
virtual void setExternalClocksource(bool external) = 0;
virtual bool isClocksourceExternal() = 0;
};
}
}
#endif //M2KDIGITAL_HPP
enums.hpp
Analogical enumerations.
libm2k::M2kHardwareTrigger
Controls the hardware trigger for ADALM2000.
Definition m2khardwaretrigger.hpp:42
libm2k::digital::M2kDigital
Controls the digital input and output segment.
Definition m2kdigital.hpp:45
enums.hpp
Digital enumerations.
libm2k::digital::DIO_MODE
DIO_MODE
Output mode for a digital channel.
Definition digital/enums.hpp:94
libm2k::digital::DIO_LEVEL
DIO_LEVEL
Logic voltage levels.
Definition digital/enums.hpp:56
libm2k::digital::DIO_CHANNEL
DIO_CHANNEL
Indexes of the channels.
Definition digital/enums.hpp:69
libm2k::digital::DIO_DIRECTION
DIO_DIRECTION
Direction of a digital channel.
Definition digital/enums.hpp:43
libm2k::digital::M2kDigital::getCyclic
virtual bool getCyclic()=0
Retrieve the value of the cyclic mode.
libm2k::digital::M2kDigital::cancelAcquisition
virtual void cancelAcquisition()=0
Cancel all rx-buffer operations.
libm2k::digital::M2kDigital::anyChannelEnabled
virtual bool anyChannelEnabled(DIO_DIRECTION dir)=0
Check if there is at least one channel enabled.
libm2k::digital::M2kDigital::getNbChannelsOut
virtual unsigned int getNbChannelsOut()=0
Retrieve the number of digital output channels.
libm2k::digital::M2kDigital::getOutputMode
virtual DIO_MODE getOutputMode(DIO_CHANNEL chn)=0
Retrieve the output mode for the given digital channel.
libm2k::digital::M2kDigital::setDirection
virtual void setDirection(DIO_CHANNEL index, DIO_DIRECTION dir)=0
Set the direction of the given digital channel.
libm2k::digital::M2kDigital::getSampleRateOut
virtual double getSampleRateOut()=0
Retrieve the sample rate of all digital output channels.
libm2k::digital::M2kDigital::setDirection
virtual void setDirection(DIO_CHANNEL index, bool dir)=0
Set the direction of the given digital channel.
libm2k::digital::M2kDigital::setRateMux
virtual void setRateMux()=0
Force the digital interface to use the analogical rate.
libm2k::digital::M2kDigital::enableChannel
virtual void enableChannel(unsigned int index, bool enable)=0
Enable or disable the given digital channel.
libm2k::digital::M2kDigital::setDirection
virtual void setDirection(unsigned int index, bool dir)=0
Set the direction of the given digital channel.
libm2k::digital::M2kDigital::push
virtual void push(std::vector< unsigned short > const &data)=0
Send the samples to all digital channels.
libm2k::digital::M2kDigital::getDirection
virtual DIO_DIRECTION getDirection(DIO_CHANNEL index)=0
Retrieve the direction of the given digital channel.
libm2k::digital::M2kDigital::getSamples
virtual std::vector< unsigned short > getSamples(unsigned int nb_samples)=0
Retrieve a specific number of samples.
libm2k::digital::M2kDigital::getValueRaw
virtual DIO_LEVEL getValueRaw(unsigned int index)=0
Retrieve the raw value of the given digital channel.
libm2k::digital::M2kDigital::startAcquisition
virtual void startAcquisition(unsigned int nb_samples)=0
Create the buffer for all channels and start the acquisition.
libm2k::digital::M2kDigital::setValueRaw
virtual void setValueRaw(DIO_CHANNEL index, DIO_LEVEL level)=0
Set the raw value of a given digital channel.
libm2k::digital::M2kDigital::getSamplesP
virtual const unsigned short * getSamplesP(unsigned int nb_samples)=0
Retrieve a specific number of samples.
libm2k::digital::M2kDigital::cancelBufferOut
virtual void cancelBufferOut()=0
Cancel all tx-buffer operations.
libm2k::digital::M2kDigital::setCyclic
virtual void setCyclic(bool cyclic)=0
Enable or disable the cyclic mode for all digital channels.
libm2k::digital::M2kDigital::setKernelBuffersCountOut
virtual void setKernelBuffersCountOut(unsigned int count)=0
Set the kernel buffers for output to a specific value.
libm2k::digital::M2kDigital::setOutputMode
virtual void setOutputMode(unsigned int chn, DIO_MODE mode)=0
Set the output mode for the given digital channel.
libm2k::digital::M2kDigital::setDirection
virtual void setDirection(unsigned short mask)=0
Set the direction for all digital channels.
libm2k::digital::M2kDigital::stopAcquisition
virtual void stopAcquisition()=0
Destroy the buffer and stop the acquisition.
libm2k::digital::M2kDigital::setSampleRateIn
virtual double setSampleRateIn(double samplerate)=0
Set the sample rate for all digital input channels.
libm2k::digital::M2kDigital::setValueRaw
virtual void setValueRaw(unsigned int index, DIO_LEVEL level)=0
Set the raw value of a given digital channel.
libm2k::digital::M2kDigital::getTrigger
virtual libm2k::M2kHardwareTrigger * getTrigger()=0
Get the hardware trigger handler.
libm2k::digital::M2kDigital::setDirection
virtual void setDirection(unsigned int index, DIO_DIRECTION dir)=0
Set the direction of the given digital channel.
libm2k::digital::M2kDigital::isClocksourceExternal
virtual bool isClocksourceExternal()=0
Get the current clocksource.
libm2k::digital::M2kDigital::getSampleRateIn
virtual double getSampleRateIn()=0
Retrieve the sample rate of all digital input channels.
libm2k::digital::M2kDigital::stopBufferOut
virtual void stopBufferOut()=0
Stop all digital channels from sending the signals.
libm2k::digital::M2kDigital::getOutputMode
virtual DIO_MODE getOutputMode(unsigned int chn)=0
Retrieve the output mode for the given digital channel.
libm2k::digital::M2kDigital::setValueRaw
virtual void setValueRaw(DIO_CHANNEL index, bool level)=0
Set the raw value of a given digital channel.
libm2k::digital::M2kDigital::setKernelBuffersCountIn
virtual void setKernelBuffersCountIn(unsigned int count)=0
Set the kernel buffers for input to a specific value.
libm2k::digital::M2kDigital::getSamples
virtual void getSamples(std::vector< unsigned short > &data, unsigned int nb_samples)=0
Retrieve a specific number of samples.
libm2k::digital::M2kDigital::setSampleRateOut
virtual double setSampleRateOut(double samplerate)=0
Set the sample rate for all digital output channels.
libm2k::digital::M2kDigital::setOutputMode
virtual void setOutputMode(DIO_CHANNEL chn, DIO_MODE mode)=0
Set the output mode for the given digital channel.
libm2k::digital::M2kDigital::enableAllOut
virtual void enableAllOut(bool enable)=0
Enable or disable all output channels.
libm2k::digital::M2kDigital::getValueRaw
virtual DIO_LEVEL getValueRaw(DIO_CHANNEL index)=0
Retrieve the raw value of the given digital channel.
libm2k::digital::M2kDigital::resetRateMux
virtual void resetRateMux()=0
Reset the digital rate to default.
libm2k::digital::M2kDigital::enableChannel
virtual void enableChannel(DIO_CHANNEL index, bool enable)=0
Enable or disable the given digital channel.
libm2k::digital::M2kDigital::getNbChannelsIn
virtual unsigned int getNbChannelsIn()=0
Retrieve the number of digital input channels.
libm2k::digital::M2kDigital::push
virtual void push(unsigned short *data, unsigned int nb_samples)=0
Send the samples to all digital channels.
libm2k::digital::M2kDigital::setExternalClocksource
virtual void setExternalClocksource(bool external)=0
Set the clocksource.