Revision f73a3688

b/host/lib/ic_reg_maps/CMakeLists.txt
40 40
)
41 41

  
42 42
LIBUHD_PYTHON_GEN_SOURCE(
43
    ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad5624_regs.py
44
    ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad5624_regs.hpp
43
    ${CMAKE_SOURCE_DIR}/lib/ic_reg_maps/gen_ad5623_regs.py
44
    ${CMAKE_BINARY_DIR}/lib/ic_reg_maps/ad5623_regs.hpp
45 45
)
46 46

  
47 47
LIBUHD_PYTHON_GEN_SOURCE(
b/host/lib/ic_reg_maps/gen_ad5623_regs.py
1
#!/usr/bin/env python
2
#
3
# Copyright 2010 Ettus Research LLC
4
#
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation, either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
#
18

  
19
########################################################################
20
# Template for raw text data describing registers
21
# name addr[bit range inclusive] default optional enums
22
########################################################################
23
REGS_TMPL="""\
24
data             0[4:15]           0
25
addr             0[16:18]          0       DAC_A=0, DAC_B=1, ALL=7
26
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
27
"""
28

  
29
########################################################################
30
# Template for methods in the body of the struct
31
########################################################################
32
BODY_TMPL="""\
33
boost::uint32_t get_reg(void){
34
    boost::uint32_t reg = 0;
35
    #for $reg in filter(lambda r: r.get_addr() == 0, $regs)
36
    reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift();
37
    #end for
38
    return reg;
39
}
40
"""
41

  
42
if __name__ == '__main__':
43
    import common; common.generate(
44
        name='ad5623_regs',
45
        regs_tmpl=REGS_TMPL,
46
        body_tmpl=BODY_TMPL,
47
        file=__file__,
48
    )
/dev/null
1
#!/usr/bin/env python
2
#
3
# Copyright 2010 Ettus Research LLC
4
#
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation, either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
#
18

  
19
########################################################################
20
# Template for raw text data describing registers
21
# name addr[bit range inclusive] default optional enums
22
########################################################################
23
REGS_TMPL="""\
24
data             0[4:15]           0
25
addr             0[16:18]          0       DAC_A=0, DAC_B=1, DAC_C=2, DAC_D=3, ALL=7
26
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
27
"""
28

  
29
########################################################################
30
# Template for methods in the body of the struct
31
########################################################################
32
BODY_TMPL="""\
33
boost::uint32_t get_reg(void){
34
    boost::uint32_t reg = 0;
35
    #for $reg in filter(lambda r: r.get_addr() == 0, $regs)
36
    reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift();
37
    #end for
38
    return reg;
39
}
40
"""
41

  
42
if __name__ == '__main__':
43
    import common; common.generate(
44
        name='ad5624_regs',
45
        regs_tmpl=REGS_TMPL,
46
        body_tmpl=BODY_TMPL,
47
        file=__file__,
48
    )
b/host/lib/usrp/dboard/db_rfx.cpp
257 257
        _rx_gains[name] = gain;
258 258

  
259 259
        //write the new voltage to the aux dac
260
        this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, 1, dac_volts);
260
        this->get_iface()->write_aux_dac(dboard_iface::UNIT_RX, 0, dac_volts);
261 261
    }
262 262
    else UHD_THROW_INVALID_CODE_PATH();
263 263
}
b/host/lib/usrp/usrp2/dboard_iface.cpp
25 25
#include <boost/asio.hpp> //htonl and ntohl
26 26
#include <boost/math/special_functions/round.hpp>
27 27
#include "ad7922_regs.hpp" //aux adc
28
#include "ad5624_regs.hpp" //aux dac
28
#include "ad5623_regs.hpp" //aux dac
29 29

  
30 30
using namespace uhd;
31 31
using namespace uhd::usrp;
......
72 72
    boost::uint32_t _ddr_shadow;
73 73
    boost::uint32_t _gpio_shadow;
74 74

  
75
    uhd::dict<unit_t, ad5624_regs_t> _dac_regs;
75
    uhd::dict<unit_t, ad5623_regs_t> _dac_regs;
76 76
    void _write_aux_dac(unit_t);
77 77
};
78 78

  
......
99 99
    _gpio_shadow = 0;
100 100

  
101 101
    //reset the aux dacs
102
    _dac_regs[UNIT_RX] = ad5624_regs_t();
103
    _dac_regs[UNIT_TX] = ad5624_regs_t();
102
    _dac_regs[UNIT_RX] = ad5623_regs_t();
103
    _dac_regs[UNIT_TX] = ad5623_regs_t();
104 104
    BOOST_FOREACH(unit_t unit, _dac_regs.keys()){
105 105
        _dac_regs[unit].data = 1;
106
        _dac_regs[unit].addr = ad5624_regs_t::ADDR_ALL;
107
        _dac_regs[unit].cmd  = ad5624_regs_t::CMD_RESET;
106
        _dac_regs[unit].addr = ad5623_regs_t::ADDR_ALL;
107
        _dac_regs[unit].cmd  = ad5623_regs_t::CMD_RESET;
108 108
        this->_write_aux_dac(unit);
109 109
    }
110 110
}
......
242 242

  
243 243
void usrp2_dboard_iface::write_aux_dac(unit_t unit, int which, float value){
244 244
    _dac_regs[unit].data = boost::math::iround(4095*value/3.3);
245
    _dac_regs[unit].cmd = ad5624_regs_t::CMD_WR_UP_DAC_CHAN_N;
245
    _dac_regs[unit].cmd = ad5623_regs_t::CMD_WR_UP_DAC_CHAN_N;
246
    //standardize on USRP1 interface, A=0, B=1, C=2, D=3
247
    //FIXME josh reccommends the use of a nested dictionary
246 248
    switch(which){
247
    case 0: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_A; break;
248
    case 1: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_B; break;
249
    case 2: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_C; break;
250
    case 3: _dac_regs[unit].addr = ad5624_regs_t::ADDR_DAC_D; break;
249
    case 0: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_B : ad5623_regs_t::ADDR_DAC_A; break;
250
    case 1: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_A : ad5623_regs_t::ADDR_DAC_B; break;
251
    case 2: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_A : ad5623_regs_t::ADDR_DAC_B; break;
252
    case 3: _dac_regs[unit].addr = unit == dboard_iface::UNIT_RX ? ad5623_regs_t::ADDR_DAC_B : ad5623_regs_t::ADDR_DAC_A; break;
251 253
    default: throw std::runtime_error("not a possible aux dac, must be 0, 1, 2, or 3");
252 254
    }
253 255
    this->_write_aux_dac(unit);

Also available in: Unified diff