aboutsummaryrefslogtreecommitdiffstats
path: root/gr-iio/include/gnuradio/iio/device_source.h
diff options
context:
space:
mode:
authorAdam Horden <adam.horden@horden.engineering>2021-02-22 22:22:40 +0000
committermormj <34754695+mormj@users.noreply.github.com>2021-06-04 06:21:34 -0400
commit6d3965f79d671afbb0b688620f3b4b218e02a352 (patch)
tree83a38f0c1795616509f4f7896da4f82e0ebce3e5 /gr-iio/include/gnuradio/iio/device_source.h
parentgr-blocks: Add missing pybind11 binding for Phase Shift block. (diff)
downloadgnuradio-6d3965f79d671afbb0b688620f3b4b218e02a352.tar.xz
gnuradio-6d3965f79d671afbb0b688620f3b4b218e02a352.zip
feature: gr-iio
Co-authored-by: Edward Kigwana <ekigwana@scires.com> Co-authored-by: Travis Collins <travis.collins@analog.com> Signed-off-by: Adam Horden <adam.horden@horden.engineering>
Diffstat (limited to 'gr-iio/include/gnuradio/iio/device_source.h')
-rw-r--r--gr-iio/include/gnuradio/iio/device_source.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/gr-iio/include/gnuradio/iio/device_source.h b/gr-iio/include/gnuradio/iio/device_source.h
new file mode 100644
index 000000000..4223858e7
--- /dev/null
+++ b/gr-iio/include/gnuradio/iio/device_source.h
@@ -0,0 +1,77 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2014 Analog Devices Inc.
+ * Author: Paul Cercueil <paul.cercueil@analog.com>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ */
+
+
+#ifndef INCLUDED_IIO_DEVICE_SOURCE_H
+#define INCLUDED_IIO_DEVICE_SOURCE_H
+
+#include <gnuradio/iio/api.h>
+#include <gnuradio/sync_block.h>
+
+#define DEFAULT_BUFFER_SIZE 0x8000
+
+extern "C" {
+struct iio_context;
+};
+
+namespace gr {
+namespace iio {
+
+/*!
+ * \brief Generic source for IIO drivers with buffered output channels
+ * \ingroup iio
+ *
+ * \details
+ * This block allows for streaming data from any IIO driver which has output
+ * scan elements or buffered channels.
+ */
+class IIO_API device_source : virtual public gr::sync_block
+{
+public:
+ typedef std::shared_ptr<device_source> sptr;
+
+ /*!
+ * \brief Return a shared_ptr to a new instance of iio::device.
+ *
+ * \param uri String of the context uri
+ * \param device String of device name
+ * \param channels Vector of strings of channels names
+ * \param device_phy String of phy device name where attribute updates are
+ * applied
+ * \param params Vector of strings of attributes to set in form:
+ * "<attribute name>=<value to set>,<attribute name>=<value to set>"
+ * \param buffer_size Integer number of samples to be put into each IIO
+ * buffered passed to hardware.
+ * \param decimation Integer number of sample to remove from received
+ * data buffers between successive samples
+ */
+ static sptr make(const std::string& uri,
+ const std::string& device,
+ const std::vector<std::string>& channels,
+ const std::string& device_phy,
+ const std::vector<std::string>& params,
+ unsigned int buffer_size = DEFAULT_BUFFER_SIZE,
+ unsigned int decimation = 0);
+
+ static sptr make_from(struct iio_context* ctx,
+ const std::string& device,
+ const std::vector<std::string>& channels,
+ const std::string& device_phy,
+ const std::vector<std::string>& params,
+ unsigned int buffer_size = DEFAULT_BUFFER_SIZE,
+ unsigned int decimation = 0);
+
+ virtual void set_buffer_size(unsigned int buffer_size) = 0;
+ virtual void set_timeout_ms(unsigned long timeout) = 0;
+};
+
+} // namespace iio
+} // namespace gr
+
+#endif /* INCLUDED_IIO_DEVICE_SOURCE_H */