From d7304cc724de43b0d61d5b9d61a528d58898f004 Mon Sep 17 00:00:00 2001 From: eklai Date: Thu, 23 Jan 2020 18:47:28 -0800 Subject: x300: add front-panel GPIO source control Adds a ZPU register to control the FP GPIO source. These are 2bits per GPIO pin, totalling 24 bits. 0 corresponds to RF-A, 1 corresponds to RF-B. The following Python code will control the upper 6 bits of the front-panel GPIO from the B-side radio on an X300: >>> import uhd >>> U = uhd.usrp.MultiUSRP("type=x300") >>> U.get_gpio_src_banks() ['FP0'] >>> U.get_gpio_src("FP0") ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA'] >>> U.set_gpio_src("FP0", ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB']) >>> U.get_gpio_src("FP0") ['RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFA', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB', 'RFB'] >>> # Make all GPIOs outputs: >>> U.set_gpio_attr("FP0A", "DDR", 0xFFF) >>> U.set_gpio_attr("FP0B", "DDR", 0xFFF) >>> # Control all GPIOs from software (not ATR): >>> U.set_gpio_attr("FP0A", "CTRL", 0x000) >>> U.set_gpio_attr("FP0B", "CTRL", 0x000) >>> # Bottom 3 pins go high from radio A >>> U.set_gpio_attr("FP0A", "OUT", 0x007) >>> # Top 3 pins go high from radio B >>> U.set_gpio_attr("FP0B", "OUT", 0xE00) Amends the gpio.cpp example to allow switching the source. Co-authored-by: Brent Stapleton --- host/lib/usrp/x300/x300_mb_controller.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'host/lib/usrp/x300/x300_mb_controller.hpp') diff --git a/host/lib/usrp/x300/x300_mb_controller.hpp b/host/lib/usrp/x300/x300_mb_controller.hpp index 53f166a0e..92844f1b9 100644 --- a/host/lib/usrp/x300/x300_mb_controller.hpp +++ b/host/lib/usrp/x300/x300_mb_controller.hpp @@ -120,6 +120,10 @@ public: bool synchronize(std::vector& mb_controllers, const uhd::time_spec_t& time_spec = uhd::time_spec_t(0.0), const bool quiet = false); + std::vector get_gpio_banks() const; + std::vector get_gpio_srcs(const std::string&) const; + std::vector get_gpio_src(const std::string&); + void set_gpio_src(const std::string&, const std::vector&); private: //! Return a string X300::MB_CTRL#N -- cgit v1.2.3