libm2k
Loading...
Searching...
No Matches
m2kanalogout.hpp
1/*
2 * Copyright (c) 2019 Analog Devices Inc.
3 *
4 * This file is part of libm2k
5 * (see http://www.github.com/analogdevicesinc/libm2k).
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 2.1 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef M2KANALOGOUT_HPP
23#define M2KANALOGOUT_HPP
24
25#include <libm2k/m2kglobal.hpp>
26#include <libm2k/enums.hpp>
27#include <libm2k/m2khardwaretrigger.hpp>
28#include <vector>
29#include <memory>
30#include <map>
31
32extern "C" {
33 struct iio_context;
34}
35
36namespace libm2k {
37
42namespace analog {
43
44
52class LIBM2K_API M2kAnalogOut
53{
54public:
58 virtual ~M2kAnalogOut() {}
59
60
64 virtual void reset() = 0;
65
66
67
72 virtual std::vector<int> getOversamplingRatio() = 0;
73
74
81 virtual int getOversamplingRatio(unsigned int chn) = 0;
82
89 virtual std::vector<int> setOversamplingRatio(std::vector<int> oversampling_ratio) = 0;
90
91
98 virtual int setOversamplingRatio(unsigned int chn, int oversampling_ratio) = 0;
99
104 virtual std::vector<double> getSampleRate() = 0;
105
106
113 virtual double getSampleRate(unsigned int chn) = 0;
114
115
121 virtual std::vector<double> getAvailableSampleRates(unsigned int chn) = 0;
122
123
130 virtual std::vector<double> setSampleRate(std::vector<double> samplerates) = 0;
131
132
140 virtual double setSampleRate(unsigned int chn, double samplerate) = 0;
141
142
146 virtual void setSyncedDma(bool en, int chn = -1) = 0;
147
151 virtual bool getSyncedDma(int chn = -1) = 0;
152
156 virtual void setSyncedStartDma(bool en, int chn = -1) = 0;
157
161 virtual bool getSyncedStartDma(int chn = -1) = 0;
162
170 virtual void setCyclic(bool en) = 0;
171
172
181 virtual void setCyclic(unsigned int chn, bool en) = 0;
182
183
190 virtual bool getCyclic(unsigned int chn) = 0;
191
192
201 virtual double getScalingFactor(unsigned int chn) = 0;
202
203
210 virtual double getFilterCompensation(double samplerate) = 0;
211
212
227 virtual void pushBytes(unsigned int chnIdx, double *data, unsigned int nb_samples) = 0;
228
229
244 virtual void pushRawBytes(unsigned int chnIdx, short *data, unsigned int nb_samples) = 0;
245
246
260 virtual void pushInterleaved(double *data, unsigned int nb_channels, unsigned int nb_samples) = 0;
261
262
276 virtual void pushRawInterleaved(short *data, unsigned int nb_channels, unsigned int nb_samples) = 0;
277
278
292 virtual void push(unsigned int chnIdx, std::vector<double> const &data) = 0;
293
294
308 virtual void pushRaw(unsigned int chnIdx, std::vector<short> const &data) = 0;
309
310
323 virtual void push(std::vector<std::vector<double>> const &data) = 0;
324
325
338 virtual void pushRaw(std::vector<std::vector<short>> const &data) = 0;
339
340
347 virtual void stop() = 0;
348
349
358 virtual void stop(unsigned int chn) = 0;
359
360
365 virtual void cancelBuffer() = 0;
366
367
373 virtual void cancelBuffer(unsigned int chn) = 0;
374
383 virtual void enableChannel(unsigned int chnIdx, bool enable) = 0;
384
385
394 virtual bool isChannelEnabled(unsigned int chnIdx) = 0;
395
396
409 virtual bool isPushDone(unsigned int chnIdx) const = 0;
410
411
417 virtual void setKernelBuffersCount(unsigned int chnIdx, unsigned int count) = 0;
418
424 virtual unsigned int getKernelBuffersCount(unsigned int chnIdx) const = 0;
425
426
433 virtual short convertVoltsToRaw(unsigned int channel, double voltage) = 0;
434
435
442 virtual double convertRawToVolts(unsigned int channel, short raw) = 0;
443
444
450 virtual struct IIO_OBJECTS getIioObjects() = 0;
451
452
457 virtual unsigned int getNbChannels() = 0;
458
459
465 virtual std::string getChannelName(unsigned int channel) = 0;
466
472 virtual double getMaximumSamplerate(unsigned int chn_idx) = 0;
473
474
484 virtual unsigned short setVoltage(unsigned int chn_idx, double volts) = 0;
485
495 virtual unsigned short setVoltageRaw(unsigned int chn_idx, unsigned short raw) = 0;
496
497
504
505
519 virtual void setBufferRearmOnTrigger(bool enable) = 0;
520
521
529 virtual bool getBufferRearmOnTrigger() const = 0;
530};
531}
532}
533
534
535#endif //M2KANALOGOUT_HPP
Controls the hardware trigger for ADALM2000.
Definition m2khardwaretrigger.hpp:42
Controls the analogical output compound.
Definition m2kanalogout.hpp:53
Generic M2K enumerations.
virtual void stop(unsigned int chn)=0
Stop the given channels from sending the signals.
virtual bool isPushDone(unsigned int chnIdx) const =0
Check if the generation of the signal (only for non-cyclic buffer) is done.
virtual void enableChannel(unsigned int chnIdx, bool enable)=0
Enable or disable the given digital channel.
virtual void setKernelBuffersCount(unsigned int chnIdx, unsigned int count)=0
Set the kernel buffers to a specific value.
virtual void pushRawInterleaved(short *data, unsigned int nb_channels, unsigned int nb_samples)=0
Send samples to all the channels.
virtual bool getBufferRearmOnTrigger() const =0
Retrieve the value of the attribute that controls buffer rearm on trigger.
virtual std::vector< double > getSampleRate()=0
Retrieve the sample rate of both DACs.
virtual unsigned int getKernelBuffersCount(unsigned int chnIdx) const =0
Get the number of kernel buffers.
virtual int setOversamplingRatio(unsigned int chn, int oversampling_ratio)=0
Set the oversampling ratio for the given channel.
virtual double getFilterCompensation(double samplerate)=0
Retrieve the filter compensation for the given sample rate.
virtual std::vector< double > getAvailableSampleRates(unsigned int chn)=0
getAvailableSampleRates
virtual bool isChannelEnabled(unsigned int chnIdx)=0
Check if the given channel is enabled.
virtual void cancelBuffer(unsigned int chn)=0
Cancel all buffer operations of the given channel.
virtual std::vector< int > setOversamplingRatio(std::vector< int > oversampling_ratio)=0
Set the value of the oversampling ratio for each channel.
virtual void pushBytes(unsigned int chnIdx, double *data, unsigned int nb_samples)=0
Send the samples to the given channel.
virtual void setCyclic(bool en)=0
Enable or disable the cyclic mode for all digital channels.
virtual std::vector< double > setSampleRate(std::vector< double > samplerates)=0
Set the sample rate for both channels.
virtual void pushRawBytes(unsigned int chnIdx, short *data, unsigned int nb_samples)=0
Send the samples to the given channel.
virtual void push(unsigned int chnIdx, std::vector< double > const &data)=0
Send the samples to the given channel.
virtual double setSampleRate(unsigned int chn, double samplerate)=0
Set the sample rate for the given channel.
virtual double getMaximumSamplerate(unsigned int chn_idx)=0
Get the maximum samplerate for the DAC.
virtual void setCyclic(unsigned int chn, bool en)=0
Enable or disable the cyclic mode for all digital channels.
virtual void stop()=0
Stop all channels from sending the signals.
virtual libm2k::M2kHardwareTrigger * getTrigger()=0
Get the hardware trigger handler.
virtual double getSampleRate(unsigned int chn)=0
Retrieve the sample rate for the given channel.
virtual void setBufferRearmOnTrigger(bool enable)=0
Allows sequential output of multiple buffers with each trigger event.
virtual void pushRaw(unsigned int chnIdx, std::vector< short > const &data)=0
Send the samples to the given channel.
virtual void push(std::vector< std::vector< double > > const &data)=0
Send samples to channels.
virtual std::vector< int > getOversamplingRatio()=0
Retrieve the global oversampling ratio.
virtual void pushRaw(std::vector< std::vector< short > > const &data)=0
Send samples to channels.
virtual void cancelBuffer()=0
Cancel all buffer operations of enabled channels.
virtual unsigned short setVoltageRaw(unsigned int chn_idx, unsigned short raw)=0
Sets the raw output of the DAC channel.
virtual short convertVoltsToRaw(unsigned int channel, double voltage)=0
Convert the volts value of a sample into raw.
virtual double getScalingFactor(unsigned int chn)=0
Retrieve the scaling factor for the given channel.
virtual bool getCyclic(unsigned int chn)=0
Retrieve the value of the cyclic mode.
virtual void pushInterleaved(double *data, unsigned int nb_channels, unsigned int nb_samples)=0
Send samples to all the channels.
virtual int getOversamplingRatio(unsigned int chn)=0
Retrieve the oversampling ratio for the given channel.
virtual double convertRawToVolts(unsigned int channel, short raw)=0
Convert the raw value of a sample into volts.
virtual unsigned int getNbChannels()=0
Retrieve the number of analogical channels.
virtual std::string getChannelName(unsigned int channel)=0
Get the channel name for each DAC channel.
virtual unsigned short setVoltage(unsigned int chn_idx, double volts)=0
Sets the voltage output of the DAC channel.