From 62d467f3fc024f6a43abca9c3a2b194b5d3829bf Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Thu, 14 Oct 2021 13:15:48 -0500 Subject: host: gpio: Create gpio_atr_offsets to store GPIO registers Refactors register addresses into a gpio_atr_offsets structure which contains the various register addresses. This allows creating other devices with different GPIO register layouts with greater ease, and eliminates the use of macros (yay!) --- host/lib/usrp/x300/x300_radio_control.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'host/lib/usrp/x300/x300_radio_control.cpp') diff --git a/host/lib/usrp/x300/x300_radio_control.cpp b/host/lib/usrp/x300/x300_radio_control.cpp index 949650906..ab56adb07 100644 --- a/host/lib/usrp/x300/x300_radio_control.cpp +++ b/host/lib/usrp/x300/x300_radio_control.cpp @@ -151,9 +151,10 @@ public: // FP-GPIO (the gpio_atr_3000 ctor will initialize default values) RFNOC_LOG_TRACE("Creating FP-GPIO interface..."); _fp_gpio = gpio_atr::gpio_atr_3000::make(_wb_iface, - x300_regs::SR_FP_GPIO, - x300_regs::RB_FP_GPIO, - x300_regs::PERIPH_REG_OFFSET); + gpio_atr::gpio_atr_offsets::make_default( + x300_regs::SR_FP_GPIO, + x300_regs::RB_FP_GPIO, + x300_regs::PERIPH_REG_OFFSET)); // Create the GPIO banks and attributes, and populate them with some default // values // TODO: Do we need this section? Since the _fp_gpio handles state now, we @@ -173,8 +174,9 @@ public: // LEDs are technically valid for both RX and TX, but let's put them // here - _leds = gpio_atr::gpio_atr_3000::make_write_only( - _wb_iface, x300_regs::SR_LEDS, x300_regs::PERIPH_REG_OFFSET); + _leds = gpio_atr::gpio_atr_3000::make(_wb_iface, + gpio_atr::gpio_atr_offsets::make_write_only( + x300_regs::SR_LEDS, x300_regs::PERIPH_REG_OFFSET)); _leds->set_atr_mode( usrp::gpio_atr::MODE_ATR, usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL); // We always want to initialize at least one frontend core for both TX and RX @@ -1520,9 +1522,10 @@ private: // create a new dboard interface x300_dboard_iface_config_t db_config; db_config.gpio = gpio_atr::db_gpio_atr_3000::make(_wb_iface, - x300_regs::SR_DB_GPIO, - x300_regs::RB_DB_GPIO, - x300_regs::PERIPH_REG_OFFSET); + gpio_atr::gpio_atr_offsets::make_default( + x300_regs::SR_DB_GPIO, + x300_regs::RB_DB_GPIO, + x300_regs::PERIPH_REG_OFFSET)); db_config.spi = _spi; db_config.rx_spi_slaveno = DB_RX_SEN; db_config.tx_spi_slaveno = DB_TX_SEN; -- cgit v1.2.3