From f73a3688069b69327f6837871e0b524125c67038 Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Fri, 11 Jun 2010 18:22:01 -0700 Subject: Fixed USRP2 aux_dac numbering convention --- host/lib/ic_reg_maps/CMakeLists.txt | 4 +-- host/lib/ic_reg_maps/gen_ad5623_regs.py | 48 +++++++++++++++++++++++++++++++++ host/lib/ic_reg_maps/gen_ad5624_regs.py | 48 --------------------------------- host/lib/usrp/dboard/db_rfx.cpp | 2 +- host/lib/usrp/usrp2/dboard_iface.cpp | 24 +++++++++-------- 5 files changed, 64 insertions(+), 62 deletions(-) create mode 100755 host/lib/ic_reg_maps/gen_ad5623_regs.py delete mode 100755 host/lib/ic_reg_maps/gen_ad5624_regs.py (limited to 'host') diff --git a/host/lib/ic_reg_maps/CMakeLists.txt b/host/lib/ic_reg_maps/CMakeLists.txt index 63378eb89..ba1bbc9f0 100644 --- a/host/lib/ic_reg_maps/CMakeLists.txt +++ b/host/lib/ic_reg_maps/CMakeLists.txt @@ -40,8 +40,8 @@ LIBUHD_PYTHON_GEN_SOURCE( ) LIBUHD_PYTHON_GEN_SOURCE( - ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad5624_regs.py - ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad5624_regs.hpp + ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad5623_regs.py + ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad5623_regs.hpp ) LIBUHD_PYTHON_GEN_SOURCE( diff --git a/host/lib/ic_reg_maps/gen_ad5623_regs.py b/host/lib/ic_reg_maps/gen_ad5623_regs.py new file mode 100755 index 000000000..e653921ba --- /dev/null +++ b/host/lib/ic_reg_maps/gen_ad5623_regs.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +######################################################################## +# Template for raw text data describing registers +# name addr[bit range inclusive] default optional enums +######################################################################## +REGS_TMPL="""\ +data 0[4:15] 0 +addr 0[16:18] 0 DAC_A=0, DAC_B=1, ALL=7 +cmd 0[19:21] 0 wr_input_n, up_dac_n, wr_input_n_up_all, wr_up_dac_chan_n, power_down, reset, load_ldac +""" + +######################################################################## +# Template for methods in the body of the struct +######################################################################## +BODY_TMPL="""\ +boost::uint32_t get_reg(void){ + boost::uint32_t reg = 0; + #for $reg in filter(lambda r: r.get_addr() == 0, $regs) + reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); + #end for + return reg; +} +""" + +if __name__ == '__main__': + import common; common.generate( + name='ad5623_regs', + regs_tmpl=REGS_TMPL, + body_tmpl=BODY_TMPL, + file=__file__, + ) diff --git a/host/lib/ic_reg_maps/gen_ad5624_regs.py b/host/lib/ic_reg_maps/gen_ad5624_regs.py deleted file mode 100755 index 24401b878..000000000 --- a/host/lib/ic_reg_maps/gen_ad5624_regs.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2010 Ettus Research LLC -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# - -######################################################################## -# Template for raw text data describing registers -# name addr[bit range inclusive] default optional enums -######################################################################## -REGS_TMPL="""\ -data 0[4:15] 0 -addr 0[16:18] 0 DAC_A=0, DAC_B=1, DAC_C=2, DAC_D=3, ALL=7 -cmd 0[19:21] 0 wr_input_n, up_dac_n, wr_input_n_up_all, wr_up_dac_chan_n, power_down, reset, load_ldac -""" - -######################################################################## -# Template for methods in the body of the struct -######################################################################## -BODY_TMPL="""\ -boost::uint32_t get_reg(void){ - boost::uint32_t reg = 0; - #for $reg in filter(lambda r: r.get_addr() == 0, $regs) - reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); - #end for - return reg; -} -""" - -if __name__ == '__main__': - import common; common.generate( - name='ad5624_regs', - regs_tmpl=REGS_TMPL, - body_tmpl=BODY_TMPL, - file=__file__, - ) diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 17fc00d24..2585dfa8d 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -257,7 +257,7 @@ void rfx_xcvr::set_rx_gain(float gain, const std::string &name){ _rx_gains[name] = gain; //write the new voltage to the aux dac - this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, 1, dac_volts); + this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, 0, dac_volts); } else UHD_THROW_INVALID_CODE_PATH(); } diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 9f7c7f9e6..244f502a4 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -25,7 +25,7 @@ #include //htonl and ntohl #include #include "ad7922_regs.hpp" //aux adc -#include "ad5624_regs.hpp" //aux dac +#include "ad5623_regs.hpp" //aux dac using namespace uhd; using namespace uhd::usrp; @@ -72,7 +72,7 @@ private: boost::uint32_t _ddr_shadow; boost::uint32_t _gpio_shadow; - uhd::dict _dac_regs; + uhd::dict _dac_regs; void _write_aux_dac(unit_t); }; @@ -99,12 +99,12 @@ usrp2_dboard_iface::usrp2_dboard_iface( _gpio_shadow = 0; //reset the aux dacs - _dac_regs[UNIT_RX] = ad5624_regs_t(); - _dac_regs[UNIT_TX] = ad5624_regs_t(); + _dac_regs[UNIT_RX] = ad5623_regs_t(); + _dac_regs[UNIT_TX] = ad5623_regs_t(); BOOST_FOREACH(unit_t unit, _dac_regs.keys()){ _dac_regs[unit].data = 1; - _dac_regs[unit].addr = ad5624_regs_t::ADDR_ALL; - _dac_regs[unit].cmd = ad5624_regs_t::CMD_RESET; + _dac_regs[unit].addr = ad5623_regs_t::ADDR_ALL; + _dac_regs[unit].cmd = ad5623_regs_t::CMD_RESET; this->_write_aux_dac(unit); } } @@ -242,12 +242,14 @@ void usrp2_dboard_iface::_write_aux_dac(unit_t unit){ void usrp2_dboard_iface::write_aux_dac(unit_t unit, int which, float value){ _dac_regs[unit].data = boost::math::iround(4095*value/3.3); - _dac_regs[unit].cmd = ad5624_regs_t::CMD_WR_UP_DAC_CHAN_N; + _dac_regs[unit].cmd = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N; + //standardize on USRP1 interface, A=0, B=1, C=2, D=3 + //FIXME josh reccommends the use of a nested dictionary switch(which){ - case 0: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_A; break; - case 1: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_B; break; - case 2: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_C; break; - case 3: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_D; break; + case 0: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_B : ad5623_regs_t::ADDR_DAC_A; break; + case 1: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_A : ad5623_regs_t::ADDR_DAC_B; break; + case 2: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_A : ad5623_regs_t::ADDR_DAC_B; break; + case 3: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_B : ad5623_regs_t::ADDR_DAC_A; break; default: throw std::runtime_error("not a possible aux dac, must be 0, 1, 2, or 3"); } this->_write_aux_dac(unit); -- cgit v1.2.3