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. --- .../include/uhdlib/usrp/cores/gpio_port_mapper.hpp | 26 ++++++++++++ .../include/uhdlib/usrp/cores/spi_core_4000.hpp | 46 ++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 host/lib/include/uhdlib/usrp/cores/gpio_port_mapper.hpp create mode 100644 host/lib/include/uhdlib/usrp/cores/spi_core_4000.hpp (limited to 'host/lib/include/uhdlib/usrp') 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 +#include +#include +#include +#include +#include +#include + +namespace uhd { namespace cores { +class spi_core_4000 : uhd::noncopyable, public uhd::spi_iface +{ +public: + using sptr = std::shared_ptr; + using mapper_sptr = std::shared_ptr; + using poke32_fn_t = std::function; + using peek32_fn_t = std::function; + + 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& spi_slave_configs) = 0; +}; + +}} // namespace uhd::cores + -- cgit v1.2.3