aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include
diff options
context:
space:
mode:
authorMartin Anderseck <martin.anderseck@ni.com>2021-12-15 16:27:23 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2022-01-13 14:35:55 -0600
commitee8e4f2c9b1bae8085dff6199c2bade0914748f7 (patch)
treecf3ad50af9318a1556e4425b9389e760833fbc38 /host/lib/include
parent6bb7d61251abd303049dfd0f47bd0266656797fb (diff)
downloaduhd-ee8e4f2c9b1bae8085dff6199c2bade0914748f7.tar.gz
uhd-ee8e4f2c9b1bae8085dff6199c2bade0914748f7.tar.bz2
uhd-ee8e4f2c9b1bae8085dff6199c2bade0914748f7.zip
SPI: Implement SPI engine for x410
Add SPI Core host implementation for x410 and a discoverable feature to make it accessible.
Diffstat (limited to 'host/lib/include')
-rw-r--r--host/lib/include/uhdlib/usrp/cores/gpio_port_mapper.hpp26
-rw-r--r--host/lib/include/uhdlib/usrp/cores/spi_core_4000.hpp46
2 files changed, 72 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/usrp/cores/gpio_port_mapper.hpp b/host/lib/include/uhdlib/usrp/cores/gpio_port_mapper.hpp
new file mode 100644
index 000000000..e8280e45f
--- /dev/null
+++ b/host/lib/include/uhdlib/usrp/cores/gpio_port_mapper.hpp
@@ -0,0 +1,26 @@
+//
+// Copyright 2021 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#pragma once
+
+namespace uhd { namespace mapper {
+
+class gpio_port_mapper
+{
+public:
+ /*! Converts from user-facing GPIO port numbering to internal representation working
+ * on int value. To be used in SPI core.
+ */
+ virtual uint32_t map_value(const uint32_t& value) = 0;
+
+ /*! Converts internal GPIO port representation into user-facing port numbering working
+ * on int value. To be used in SPI core.
+ */
+ virtual uint32_t unmap_value(const uint32_t& value) = 0;
+};
+
+}} // namespace uhd::mapper
+
diff --git a/host/lib/include/uhdlib/usrp/cores/spi_core_4000.hpp b/host/lib/include/uhdlib/usrp/cores/spi_core_4000.hpp
new file mode 100644
index 000000000..4577b14cf
--- /dev/null
+++ b/host/lib/include/uhdlib/usrp/cores/spi_core_4000.hpp
@@ -0,0 +1,46 @@
+//
+// Copyright 2021 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#pragma once
+
+#include <uhd/config.hpp>
+#include <uhd/types/serial.hpp>
+#include <uhd/types/wb_iface.hpp>
+#include <uhd/utils/noncopyable.hpp>
+#include <uhdlib/usrp/cores/gpio_port_mapper.hpp>
+#include <functional>
+#include <memory>
+
+namespace uhd { namespace cores {
+class spi_core_4000 : uhd::noncopyable, public uhd::spi_iface
+{
+public:
+ using sptr = std::shared_ptr<spi_core_4000>;
+ using mapper_sptr = std::shared_ptr<uhd::mapper::gpio_port_mapper>;
+ using poke32_fn_t = std::function<void(uint32_t, uint32_t)>;
+ using peek32_fn_t = std::function<uint32_t(uint32_t)>;
+
+ virtual ~spi_core_4000(void) = default;
+
+ //! makes a new spi core from iface and slave base
+ static sptr make(uhd::wb_iface::sptr iface, const size_t base, const size_t readback);
+
+ //! makes a new spi core from register iface and slave
+ static sptr make(poke32_fn_t&& poke32_fn,
+ peek32_fn_t&& peek_fn,
+ const size_t spi_slave_cfg,
+ const size_t spi_transaction_cfg,
+ const size_t spi_transaction_go,
+ const size_t spi_status,
+ const mapper_sptr port_mapper);
+
+ //! Configures the SPI transaction. The vector index refers to the slave number.
+ virtual void set_spi_slave_config(
+ const std::vector<uhd::features::spi_slave_config_t>& spi_slave_configs) = 0;
+};
+
+}} // namespace uhd::cores
+