libm2k
Loading...
Searching...
No Matches
m2kdigital.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 M2KDIGITAL_HPP
23#define M2KDIGITAL_HPP
24
25#include <libm2k/m2kglobal.hpp>
28#include <libm2k/m2khardwaretrigger.hpp>
29#include <string>
30#include <vector>
31
32namespace libm2k {
33
34namespace digital {
35
36
44class LIBM2K_API M2kDigital
45{
46public:
47 virtual ~M2kDigital() {}
48
49
53 virtual void reset() = 0;
54
55
61 virtual void setDirection(unsigned short mask) = 0;
62
63
69 virtual void setDirection(unsigned int index, DIO_DIRECTION dir) = 0;
70
71
78 virtual void setDirection(unsigned int index, bool dir) = 0;
79
80
87 virtual void setDirection(DIO_CHANNEL index, bool dir) = 0;
88
89
95 virtual void setDirection(DIO_CHANNEL index, DIO_DIRECTION dir) = 0;
96
97
105
106
114 virtual void setValueRaw(DIO_CHANNEL index, DIO_LEVEL level) = 0;
115
116
124 virtual void push(std::vector<unsigned short> const &data) = 0;
125
126
135 virtual void push(unsigned short *data, unsigned int nb_samples) = 0;
136
137
145 virtual void setValueRaw(unsigned int index, DIO_LEVEL level) = 0;
146
147
155 virtual void setValueRaw(DIO_CHANNEL index, bool level) = 0;
156
157
165
166
173 virtual DIO_LEVEL getValueRaw(unsigned int index) = 0;
174
175
179 virtual void stopBufferOut() = 0;
180
185 virtual void startAcquisition(unsigned int nb_samples) = 0;
186
187
191 virtual void stopAcquisition() = 0;
192
193
198 virtual void cancelAcquisition() = 0;
199
204 virtual void cancelBufferOut() = 0;
205
206
215 virtual std::vector<unsigned short> getSamples(unsigned int nb_samples) = 0;
216
224 virtual const unsigned short *getSamplesP(unsigned int nb_samples) = 0;
225
226 /* Enable/disable TX channels only*/
227
228
237 virtual void enableChannel(unsigned int index, bool enable) = 0;
238
239
248 virtual void enableChannel(DIO_CHANNEL index, bool enable) = 0;
249
250
258 virtual void enableAllOut(bool enable) = 0;
259
260
268 virtual bool anyChannelEnabled(DIO_DIRECTION dir) = 0;
269
270
277 virtual void setOutputMode(DIO_CHANNEL chn, DIO_MODE mode) = 0;
278
279
286 virtual void setOutputMode(unsigned int chn, DIO_MODE mode) = 0;
287
288
296
297
304 virtual DIO_MODE getOutputMode(unsigned int chn) = 0;
305
306
313 virtual double setSampleRateIn(double samplerate) = 0;
314
315
322 virtual double setSampleRateOut(double samplerate) = 0;
323
324
329 virtual double getSampleRateIn() = 0;
330
331
337 virtual double getSampleRateOut() = 0;
338
339
345 virtual bool getCyclic() = 0;
346
347
353 virtual void setCyclic(bool cyclic) = 0;
354
355
361
362
367 virtual void setKernelBuffersCountIn(unsigned int count) = 0;
368
369
374 virtual void setKernelBuffersCountOut(unsigned int count) = 0;
375
376
382 virtual struct IIO_OBJECTS getIioObjects() = 0;
383
384
390 virtual unsigned int getNbChannelsIn() = 0;
391
392
398 virtual unsigned int getNbChannelsOut() = 0;
399
400
408 virtual void getSamples(std::vector<unsigned short> &data, unsigned int nb_samples) = 0;
409
410
416 virtual void setRateMux() = 0;
417
418
424 virtual void resetRateMux() = 0;
425
433 virtual void setExternalClocksource(bool external) = 0;
434
442 virtual bool isClocksourceExternal() = 0;
443};
444}
445}
446#endif //M2KDIGITAL_HPP
Analogical enumerations.
Controls the hardware trigger for ADALM2000.
Definition m2khardwaretrigger.hpp:42
Controls the digital input and output segment.
Definition m2kdigital.hpp:45
Digital enumerations.
DIO_MODE
Output mode for a digital channel.
Definition digital/enums.hpp:94
DIO_LEVEL
Logic voltage levels.
Definition digital/enums.hpp:56
DIO_CHANNEL
Indexes of the channels.
Definition digital/enums.hpp:69
DIO_DIRECTION
Direction of a digital channel.
Definition digital/enums.hpp:43
virtual bool getCyclic()=0
Retrieve the value of the cyclic mode.
virtual void cancelAcquisition()=0
Cancel all rx-buffer operations.
virtual bool anyChannelEnabled(DIO_DIRECTION dir)=0
Check if there is at least one channel enabled.
virtual unsigned int getNbChannelsOut()=0
Retrieve the number of digital output channels.
virtual DIO_MODE getOutputMode(DIO_CHANNEL chn)=0
Retrieve the output mode for the given digital channel.
virtual void setDirection(DIO_CHANNEL index, DIO_DIRECTION dir)=0
Set the direction of the given digital channel.
virtual double getSampleRateOut()=0
Retrieve the sample rate of all digital output channels.
virtual void setDirection(DIO_CHANNEL index, bool dir)=0
Set the direction of the given digital channel.
virtual void setRateMux()=0
Force the digital interface to use the analogical rate.
virtual void enableChannel(unsigned int index, bool enable)=0
Enable or disable the given digital channel.
virtual void setDirection(unsigned int index, bool dir)=0
Set the direction of the given digital channel.
virtual void push(std::vector< unsigned short > const &data)=0
Send the samples to all digital channels.
virtual DIO_DIRECTION getDirection(DIO_CHANNEL index)=0
Retrieve the direction of the given digital channel.
virtual std::vector< unsigned short > getSamples(unsigned int nb_samples)=0
Retrieve a specific number of samples.
virtual DIO_LEVEL getValueRaw(unsigned int index)=0
Retrieve the raw value of the given digital channel.
virtual void startAcquisition(unsigned int nb_samples)=0
Create the buffer for all channels and start the acquisition.
virtual void setValueRaw(DIO_CHANNEL index, DIO_LEVEL level)=0
Set the raw value of a given digital channel.
virtual const unsigned short * getSamplesP(unsigned int nb_samples)=0
Retrieve a specific number of samples.
virtual void cancelBufferOut()=0
Cancel all tx-buffer operations.
virtual void setCyclic(bool cyclic)=0
Enable or disable the cyclic mode for all digital channels.
virtual void setKernelBuffersCountOut(unsigned int count)=0
Set the kernel buffers for output to a specific value.
virtual void setOutputMode(unsigned int chn, DIO_MODE mode)=0
Set the output mode for the given digital channel.
virtual void setDirection(unsigned short mask)=0
Set the direction for all digital channels.
virtual void stopAcquisition()=0
Destroy the buffer and stop the acquisition.
virtual double setSampleRateIn(double samplerate)=0
Set the sample rate for all digital input channels.
virtual void setValueRaw(unsigned int index, DIO_LEVEL level)=0
Set the raw value of a given digital channel.
virtual libm2k::M2kHardwareTrigger * getTrigger()=0
Get the hardware trigger handler.
virtual void setDirection(unsigned int index, DIO_DIRECTION dir)=0
Set the direction of the given digital channel.
virtual bool isClocksourceExternal()=0
Get the current clocksource.
virtual double getSampleRateIn()=0
Retrieve the sample rate of all digital input channels.
virtual void stopBufferOut()=0
Stop all digital channels from sending the signals.
virtual DIO_MODE getOutputMode(unsigned int chn)=0
Retrieve the output mode for the given digital channel.
virtual void setValueRaw(DIO_CHANNEL index, bool level)=0
Set the raw value of a given digital channel.
virtual void setKernelBuffersCountIn(unsigned int count)=0
Set the kernel buffers for input to a specific value.
virtual void getSamples(std::vector< unsigned short > &data, unsigned int nb_samples)=0
Retrieve a specific number of samples.
virtual double setSampleRateOut(double samplerate)=0
Set the sample rate for all digital output channels.
virtual void setOutputMode(DIO_CHANNEL chn, DIO_MODE mode)=0
Set the output mode for the given digital channel.
virtual void enableAllOut(bool enable)=0
Enable or disable all output channels.
virtual DIO_LEVEL getValueRaw(DIO_CHANNEL index)=0
Retrieve the raw value of the given digital channel.
virtual void resetRateMux()=0
Reset the digital rate to default.
virtual void enableChannel(DIO_CHANNEL index, bool enable)=0
Enable or disable the given digital channel.
virtual unsigned int getNbChannelsIn()=0
Retrieve the number of digital input channels.
virtual void push(unsigned short *data, unsigned int nb_samples)=0
Send the samples to all digital channels.
virtual void setExternalClocksource(bool external)=0
Set the clocksource.