diff options
Diffstat (limited to 'host/lib/usrp/x400/x400_radio_control.hpp')
-rw-r--r-- | host/lib/usrp/x400/x400_radio_control.hpp | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/host/lib/usrp/x400/x400_radio_control.hpp b/host/lib/usrp/x400/x400_radio_control.hpp index 8848926c7..cd45291bc 100644 --- a/host/lib/usrp/x400/x400_radio_control.hpp +++ b/host/lib/usrp/x400/x400_radio_control.hpp @@ -7,24 +7,28 @@ #pragma once #include "adc_self_calibration.hpp" +#include "x400_gpio_control.hpp" +#include <uhd/features/spi_getter_iface.hpp> #include <uhd/rfnoc/noc_block_base.hpp> #include <uhd/types/device_addr.hpp> #include <uhd/types/direction.hpp> #include <uhd/types/ranges.hpp> #include <uhdlib/features/fpga_load_notification_iface.hpp> #include <uhdlib/rfnoc/radio_control_impl.hpp> +#include <uhdlib/rfnoc/reg_iface_adapter.hpp> #include <uhdlib/rfnoc/rf_control/dboard_iface.hpp> #include <uhdlib/usrp/common/mpmd_mb_controller.hpp> #include <uhdlib/usrp/common/rpc.hpp> #include <uhdlib/usrp/common/x400_rfdc_control.hpp> +#include <uhdlib/usrp/cores/gpio_atr_3000.hpp> +#include <uhdlib/usrp/cores/spi_core_4000.hpp> #include <uhdlib/utils/rpc.hpp> #include <stddef.h> #include <memory> #include <mutex> #include <string> #include <vector> -#include <uhdlib/usrp/cores/gpio_atr_3000.hpp> -#include "x400_gpio_control.hpp" + namespace uhd { namespace rfnoc { @@ -34,6 +38,22 @@ namespace x400_regs { // other things in the RFDC. constexpr uint32_t RFDC_CTRL_BASE = radio_control_impl::regmap::PERIPH_BASE + 0x8000; +constexpr uint32_t DIO_REGMAP_OFFSET = 0x2000; +constexpr uint32_t DIO_WINDOW_OFFSET = 0xC000; + +// SPI control registers +constexpr uint32_t SPI_SLAVE_CFG = + DIO_REGMAP_OFFSET + DIO_WINDOW_OFFSET + radio_control_impl::regmap::PERIPH_BASE; + +//! Base address for SPI_TRANSACTION_CONFIG Register +constexpr uint32_t SPI_TRANSACTION_CFG_REG = SPI_SLAVE_CFG + 0x0010; + +//! Base address for SPI_TRANSACTION_GO Register +constexpr uint32_t SPI_TRANSACTION_GO_REG = SPI_SLAVE_CFG + 0x0014; + +//! Base address for SPI_STATUS Register +constexpr uint32_t SPI_STATUS_REG = SPI_SLAVE_CFG + 0x0018; + } // namespace x400_regs class x400_radio_control_impl : public radio_control_impl @@ -116,8 +136,7 @@ public: const std::string& name, const size_t chan) override; void set_rx_lo_export_enabled( bool enabled, const std::string& name, const size_t chan) override; - bool get_rx_lo_export_enabled( - const std::string& name, const size_t chan) override; + bool get_rx_lo_export_enabled(const std::string& name, const size_t chan) override; double set_rx_lo_freq( double freq, const std::string& name, const size_t chan) override; double get_rx_lo_freq(const std::string& name, const size_t chan) override; @@ -179,6 +198,8 @@ private: uhd::features::adc_self_calibration_iface::sptr _adc_self_calibration; + uhd::features::spi_getter_iface::sptr _spi_getter_iface; + x400::gpio_control::sptr _gpios; class fpga_onload : public uhd::features::fpga_load_notification_iface @@ -203,6 +224,26 @@ private: }; fpga_onload::sptr _fpga_onload; + + class x400_spi_getter : public uhd::features::spi_getter_iface + { + public: + using sptr = std::shared_ptr<spi_getter_iface>; + + x400_spi_getter(uhd::cores::spi_core_4000::sptr _spi) : _spicore(_spi) {} + + uhd::spi_iface::sptr get_spi_ref( + const std::vector<uhd::features::spi_slave_config_t>& spi_slave_config) + const override + { + _spicore->set_spi_slave_config(spi_slave_config); + return _spicore; + } + + private: + uhd::cores::spi_core_4000::sptr _spicore; + }; }; + }} // namespace uhd::rfnoc |