From f721787d8183ee3fa980fb8131e813b23f1bc5c9 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 24 Oct 2017 15:54:29 -0700 Subject: mg: Add controls for frontpanel- and internal GPIOs - FP-GPIOs are currently unconnected, we just create the object (pending FPGA changes) - One ATR/GPIO controller per radio - Internal GPIOs (controlling DSA and AD9371 gain bits) are set to MODE_GPIO, they don't toggle on ATR state change --- .../dboard/magnesium/magnesium_radio_ctrl_impl.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp') diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp index 54f2f64cc..2c0f82aa8 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp @@ -48,6 +48,8 @@ namespace { const size_t MAGNESIUM_NUM_TX_CHANS = 1; const size_t MAGNESIUM_NUM_RX_CHANS = 1; + const size_t FPGPIO_MASTER_RADIO = 0; + /*! Return a valid 'which' string for use with AD9371 API calls * * These strings take the form of "RX1", "TX2", ... @@ -299,6 +301,36 @@ void magnesium_radio_ctrl_impl::_init_peripherals() } else { UHD_LOG_TRACE("MAGNESIUM", "Not a master radio, no LOs."); } + + _gpio.clear(); // Following the as-if rule, this can get optimized out + for (size_t radio_idx = 0; radio_idx < _get_num_radios(); radio_idx++) { + UHD_LOG_TRACE("MAGNESIUM", + "Initializing GPIOs for channel " << radio_idx); + _gpio.emplace_back( + gpio_atr::gpio_atr_3000::make( + _get_ctrl(radio_idx), + regs::sr_addr(regs::ATR) + ) + ); + // DSA and AD9371 gain bits do *not* toggle on ATR modes. If we ever + // connect anything else to this core, we might need to set_atr_mode() + // to MODE_ATR on those bits. For now, all bits simply do what they're + // told, and don't toggle on RX/TX state changes. + _gpio.back()->set_atr_mode( + usrp::gpio_atr::MODE_GPIO, // Disable ATR mode + usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL + ); + _gpio.back()->set_gpio_ddr( + usrp::gpio_atr::DDR_OUTPUT, // Make all GPIOs outputs + usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL + ); + } + + if (get_block_id().get_block_count() == FPGPIO_MASTER_RADIO) { + UHD_LOG_TRACE(unique_id(), "Initializing front-panel GPIO control...") + _fp_gpio = gpio_atr::gpio_atr_3000::make( + _get_ctrl(0), regs::sr_addr(regs::FP_GPIO), regs::RB_FP_GPIO); + } } void magnesium_radio_ctrl_impl::_init_defaults() -- cgit v1.2.3