aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-14 18:47:22 -0700
committerJosh Blum <josh@joshknows.com>2010-06-14 18:47:22 -0700
commit73ea268536e83b8961bea4a0f825ac68f3da2f2b (patch)
treee1c56b3dc9493184368877ee355b3b6cafd5095e /host/lib/usrp/usrp2
parentf73a3688069b69327f6837871e0b524125c67038 (diff)
downloaduhd-73ea268536e83b8961bea4a0f825ac68f3da2f2b.tar.gz
uhd-73ea268536e83b8961bea4a0f825ac68f3da2f2b.tar.bz2
uhd-73ea268536e83b8961bea4a0f825ac68f3da2f2b.zip
usrp2: dboard iface: switched to nested dictionary for dac regs
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r--host/lib/usrp/usrp2/dboard_iface.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp
index 244f502a4..114f83f41 100644
--- a/host/lib/usrp/usrp2/dboard_iface.cpp
+++ b/host/lib/usrp/usrp2/dboard_iface.cpp
@@ -244,14 +244,23 @@ 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 = 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 = 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");
- }
+ static const uhd::dict<
+ unit_t, uhd::dict<int, ad5623_regs_t::addr_t>
+ > unit_to_which_to_addr = map_list_of
+ (UNIT_RX, map_list_of
+ (0, ad5623_regs_t::ADDR_DAC_B)
+ (1, ad5623_regs_t::ADDR_DAC_A)
+ (2, ad5623_regs_t::ADDR_DAC_A)
+ (3, ad5623_regs_t::ADDR_DAC_B)
+ )
+ (UNIT_TX, map_list_of
+ (0, ad5623_regs_t::ADDR_DAC_A)
+ (1, ad5623_regs_t::ADDR_DAC_B)
+ (2, ad5623_regs_t::ADDR_DAC_B)
+ (3, ad5623_regs_t::ADDR_DAC_A)
+ )
+ ;
+ _dac_regs[unit].addr = unit_to_which_to_addr[unit][which];
this->_write_aux_dac(unit);
}