From ee8e4f2c9b1bae8085dff6199c2bade0914748f7 Mon Sep 17 00:00:00 2001 From: Martin Anderseck Date: Wed, 15 Dec 2021 16:27:23 +0100 Subject: SPI: Implement SPI engine for x410 Add SPI Core host implementation for x410 and a discoverable feature to make it accessible. --- host/include/uhd/features/discoverable_feature.hpp | 1 + host/include/uhd/features/spi_getter_iface.hpp | 60 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 host/include/uhd/features/spi_getter_iface.hpp (limited to 'host/include') diff --git a/host/include/uhd/features/discoverable_feature.hpp b/host/include/uhd/features/discoverable_feature.hpp index e56c3f6e3..be01a36c7 100644 --- a/host/include/uhd/features/discoverable_feature.hpp +++ b/host/include/uhd/features/discoverable_feature.hpp @@ -36,6 +36,7 @@ public: REF_CLK_CALIBRATION, TRIG_IO_MODE, GPIO_POWER, + SPI_GETTER_IFACE }; virtual ~discoverable_feature() = default; diff --git a/host/include/uhd/features/spi_getter_iface.hpp b/host/include/uhd/features/spi_getter_iface.hpp new file mode 100755 index 000000000..1909de095 --- /dev/null +++ b/host/include/uhd/features/spi_getter_iface.hpp @@ -0,0 +1,60 @@ +// +// Copyright 2021 Ettus Research, a National Instruments Brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#pragma once + +#include +#include +#include + +namespace uhd { namespace features { + +/*! + * The SPI slave configuration struct: + * Used to configure the GPIO lines for SPI transactions + */ +struct spi_slave_config_t +{ + //! Indicates which GPIO line to use for this the CS signal. + uint8_t slave_ss; + + //! Indicates which GPIO line to use for this the MISO signal. + uint8_t slave_miso; + + //! Indicates which GPIO line to use for this the MOSI signal. + uint8_t slave_mosi; + + //! Indicates which GPIO line to use for this the SCLK signal. + uint8_t slave_clk; +}; + +/*! Interface to provide access to SPI Interface. + */ +class spi_getter_iface : public discoverable_feature +{ +public: + using sptr = std::shared_ptr; + + static discoverable_feature::feature_id_t get_feature_id() + { + return discoverable_feature::SPI_GETTER_IFACE; + } + + std::string get_feature_name() const + { + return "SPI Getter Interface"; + } + + virtual ~spi_getter_iface() = default; + + /*! Return the SPI interface to read and write on. + * \return SPI interface + */ + virtual uhd::spi_iface::sptr get_spi_ref( + const std::vector& spi_slave_config) const = 0; +}; + +}} // namespace uhd::features -- cgit v1.2.3