diff options
author | Martin Anderseck <martin.anderseck@ni.com> | 2021-12-15 16:27:23 +0100 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-01-13 14:35:55 -0600 |
commit | ee8e4f2c9b1bae8085dff6199c2bade0914748f7 (patch) | |
tree | cf3ad50af9318a1556e4425b9389e760833fbc38 /host/include | |
parent | 6bb7d61251abd303049dfd0f47bd0266656797fb (diff) | |
download | uhd-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/include')
-rw-r--r-- | host/include/uhd/features/discoverable_feature.hpp | 1 | ||||
-rwxr-xr-x | host/include/uhd/features/spi_getter_iface.hpp | 60 |
2 files changed, 61 insertions, 0 deletions
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 <uhd/features/discoverable_feature.hpp> +#include <uhd/types/serial.hpp> +#include <memory> + +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<spi_getter_iface>; + + 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<uhd::features::spi_slave_config_t>& spi_slave_config) const = 0; +}; + +}} // namespace uhd::features |