From 154e4492485eb2e56bf5fc1372670540e2f44090 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 16 Apr 2010 22:32:34 -0700 Subject: moved come common register generation code into common.py --- host/lib/ic_reg_maps/.gitignore | 1 + host/lib/ic_reg_maps/common.py | 67 ++++++++++++++++++++++++++++++++ host/lib/ic_reg_maps/gen_ad9510_regs.py | 48 +---------------------- host/lib/ic_reg_maps/gen_ad9777_regs.py | 48 +---------------------- host/lib/ic_reg_maps/gen_adf4360_regs.py | 48 +---------------------- 5 files changed, 71 insertions(+), 141 deletions(-) create mode 100644 host/lib/ic_reg_maps/.gitignore create mode 100644 host/lib/ic_reg_maps/common.py mode change 100644 => 100755 host/lib/ic_reg_maps/gen_ad9777_regs.py (limited to 'host/lib/ic_reg_maps') diff --git a/host/lib/ic_reg_maps/.gitignore b/host/lib/ic_reg_maps/.gitignore new file mode 100644 index 000000000..a74b07aee --- /dev/null +++ b/host/lib/ic_reg_maps/.gitignore @@ -0,0 +1 @@ +/*.pyc diff --git a/host/lib/ic_reg_maps/common.py b/host/lib/ic_reg_maps/common.py new file mode 100644 index 000000000..b7fa27bbe --- /dev/null +++ b/host/lib/ic_reg_maps/common.py @@ -0,0 +1,67 @@ +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 asversion 3, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +import re +import os +import math +from Cheetah.Template import Template + +def parse_tmpl(_tmpl_text, **kwargs): + return str(Template(_tmpl_text, kwargs)) + +def safe_makedirs(path): + not os.path.isdir(path) and os.makedirs(path) + +class reg: + def __init__(self, reg_des): + x = re.match('^(\w*)\s*(\w*)\[(.*)\]\s*(\w*)\s*(.*)$', reg_des) + name, addr, bit_range, default, enums = x.groups() + + #store variables + self._name = name + self._addr = int(addr, 16) + if ':' in bit_range: self._addr_spec = sorted(map(int, bit_range.split(':'))) + else: self._addr_spec = int(bit_range), int(bit_range) + self._default = int(default, 16) + + #extract enum + self._enums = list() + if enums: + enum_val = 0 + for enum_str in map(str.strip, enums.split(',')): + if '=' in enum_str: + enum_name, enum_val = enum_str.split('=') + enum_val = int(enum_val) + else: enum_name = enum_str + self._enums.append((enum_name, enum_val)) + enum_val += 1 + + def get_addr(self): return self._addr + def get_enums(self): return self._enums + def get_name(self): return self._name + def get_default(self): + for key, val in self.get_enums(): + if val == self._default: return str.upper('%s_%s'%(self.get_name(), key)) + return self._default + def get_stdint_type(self):\ + return 'uint%d_t'%max(2**math.ceil(math.log(self.get_bit_width(), 2)), 8) + def get_shift(self): return self._addr_spec[0] + def get_mask(self): return hex(int('1'*self.get_bit_width(), 2)) + def get_bit_width(self): return self._addr_spec[1] - self._addr_spec[0] + 1 diff --git a/host/lib/ic_reg_maps/gen_ad9510_regs.py b/host/lib/ic_reg_maps/gen_ad9510_regs.py index 90230b8f9..32a8a04c6 100755 --- a/host/lib/ic_reg_maps/gen_ad9510_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9510_regs.py @@ -19,14 +19,9 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import re import os import sys -from Cheetah.Template import Template -def parse_tmpl(_tmpl_text, **kwargs): - return str(Template(_tmpl_text, kwargs)) -def safe_makedirs(path): - not os.path.isdir(path) and os.makedirs(path) +from common import * ######################################################################## # Template for raw text data describing registers @@ -177,47 +172,6 @@ struct ad9510_regs_t{ \#endif /* INCLUDED_AD9510_REGS_HPP */ """ -class reg: - def __init__(self, reg_des): - x = re.match('^(\w*)\s*(\w*)\[(.*)\]\s*(\w*)\s*(.*)$', reg_des) - name, addr, bit_range, default, enums = x.groups() - - #store variables - self._name = name - self._addr = int(addr, 16) - if ':' in bit_range: self._addr_spec = map(int, bit_range.split(':')) - else: self._addr_spec = int(bit_range), int(bit_range) - self._default = int(default, 16) - - #extract enum - self._enums = list() - if enums: - enum_val = 0 - for enum_str in map(str.strip, enums.split(',')): - if '=' in enum_str: - enum_name, enum_val = enum_str.split('=') - enum_val = int(enum_val) - else: enum_name = enum_str - self._enums.append((enum_name, enum_val)) - enum_val += 1 - - def get_addr(self): return self._addr - def get_enums(self): return self._enums - def get_name(self): return self._name - def get_default(self): - for key, val in self.get_enums(): - if val == self._default: return str.upper('%s_%s'%(self.get_name(), key)) - return self._default - def get_stdint_type(self): - if self.get_bit_width() <= 8: return 'uint8_t' - if self.get_bit_width() <= 16: return 'uint16_t' - if self.get_bit_width() <= 32: return 'uint32_t' - if self.get_bit_width() <= 64: return 'uint64_t' - raise Exception, 'too damn big' - def get_shift(self): return self._addr_spec[0] - def get_mask(self): return hex(int('1'*self.get_bit_width(), 2)) - def get_bit_width(self): return self._addr_spec[1] - self._addr_spec[0] + 1 - if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) safe_makedirs(os.path.dirname(sys.argv[1])) diff --git a/host/lib/ic_reg_maps/gen_ad9777_regs.py b/host/lib/ic_reg_maps/gen_ad9777_regs.py old mode 100644 new mode 100755 index 6077b61b6..e4369291a --- a/host/lib/ic_reg_maps/gen_ad9777_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9777_regs.py @@ -19,14 +19,9 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import re import os import sys -from Cheetah.Template import Template -def parse_tmpl(_tmpl_text, **kwargs): - return str(Template(_tmpl_text, kwargs)) -def safe_makedirs(path): - not os.path.isdir(path) and os.makedirs(path) +from common import * ######################################################################## # Template for raw text data describing registers @@ -155,47 +150,6 @@ struct ad9777_regs_t{ \#endif /* INCLUDED_AD9777_REGS_HPP */ """ -class reg: - def __init__(self, reg_des): - x = re.match('^(\w*)\s*(\w*)\[(.*)\]\s*(\w*)\s*(.*)$', reg_des) - name, addr, bit_range, default, enums = x.groups() - - #store variables - self._name = name - self._addr = int(addr, 16) - if ':' in bit_range: self._addr_spec = sorted(map(int, bit_range.split(':'))) - else: self._addr_spec = int(bit_range), int(bit_range) - self._default = int(default, 16) - - #extract enum - self._enums = list() - if enums: - enum_val = 0 - for enum_str in map(str.strip, enums.split(',')): - if '=' in enum_str: - enum_name, enum_val = enum_str.split('=') - enum_val = int(enum_val) - else: enum_name = enum_str - self._enums.append((enum_name, enum_val)) - enum_val += 1 - - def get_addr(self): return self._addr - def get_enums(self): return self._enums - def get_name(self): return self._name - def get_default(self): - for key, val in self.get_enums(): - if val == self._default: return str.upper('%s_%s'%(self.get_name(), key)) - return self._default - def get_stdint_type(self): - if self.get_bit_width() <= 8: return 'uint8_t' - if self.get_bit_width() <= 16: return 'uint16_t' - if self.get_bit_width() <= 32: return 'uint32_t' - if self.get_bit_width() <= 64: return 'uint64_t' - raise Exception, 'too damn big' - def get_shift(self): return self._addr_spec[0] - def get_mask(self): return hex(int('1'*self.get_bit_width(), 2)) - def get_bit_width(self): return self._addr_spec[1] - self._addr_spec[0] + 1 - if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) safe_makedirs(os.path.dirname(sys.argv[1])) diff --git a/host/lib/ic_reg_maps/gen_adf4360_regs.py b/host/lib/ic_reg_maps/gen_adf4360_regs.py index bcad1ffd3..f82e8c7c5 100755 --- a/host/lib/ic_reg_maps/gen_adf4360_regs.py +++ b/host/lib/ic_reg_maps/gen_adf4360_regs.py @@ -19,14 +19,9 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import re import os import sys -from Cheetah.Template import Template -def parse_tmpl(_tmpl_text, **kwargs): - return str(Template(_tmpl_text, kwargs)) -def safe_makedirs(path): - not os.path.isdir(path) and os.makedirs(path) +from common import * ######################################################################## # Template for raw text data describing registers @@ -126,47 +121,6 @@ struct adf4360_regs_t{ \#endif /* INCLUDED_ADF4360_REGS_HPP */ """ -class reg: - def __init__(self, reg_des): - x = re.match('^(\w*)\s*(\w*)\[(.*)\]\s*(\w*)\s*(.*)$', reg_des) - name, addr, bit_range, default, enums = x.groups() - - #store variables - self._name = name - self._addr = int(addr) - if ':' in bit_range: self._addr_spec = map(int, bit_range.split(':')) - else: self._addr_spec = int(bit_range), int(bit_range) - self._default = int(default) - - #extract enum - self._enums = list() - if enums: - enum_val = 0 - for enum_str in map(str.strip, enums.split(',')): - if '=' in enum_str: - enum_name, enum_val = enum_str.split('=') - enum_val = int(enum_val) - else: enum_name = enum_str - self._enums.append((enum_name, enum_val)) - enum_val += 1 - - def get_addr(self): return self._addr - def get_enums(self): return self._enums - def get_name(self): return self._name - def get_default(self): - for key, val in self.get_enums(): - if val == self._default: return str.upper('%s_%s'%(self.get_name(), key)) - return self._default - def get_stdint_type(self): - if self.get_bit_width() <= 8: return 'uint8_t' - if self.get_bit_width() <= 16: return 'uint16_t' - if self.get_bit_width() <= 32: return 'uint32_t' - if self.get_bit_width() <= 64: return 'uint64_t' - raise Exception, 'too damn big' - def get_shift(self): return self._addr_spec[0] - def get_mask(self): return hex(int('1'*self.get_bit_width(), 2)) - def get_bit_width(self): return self._addr_spec[1] - self._addr_spec[0] + 1 - if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) safe_makedirs(os.path.dirname(sys.argv[1])) -- cgit v1.2.3 From b3116c8ccf188c2abd7c709e0f1a436c513de1f1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 19 Apr 2010 18:24:03 -0700 Subject: added support for aux dac and adc control in host --- host/lib/CMakeLists.txt | 9 +++ host/lib/ic_reg_maps/gen_ad5624_regs.py | 87 +++++++++++++++++++++++++++++ host/lib/ic_reg_maps/gen_ad7922_regs.py | 93 +++++++++++++++++++++++++++++++ host/lib/usrp/usrp2/dboard_iface.cpp | 98 ++++++++++++++++++++++----------- 4 files changed, 256 insertions(+), 31 deletions(-) create mode 100755 host/lib/ic_reg_maps/gen_ad5624_regs.py create mode 100755 host/lib/ic_reg_maps/gen_ad7922_regs.py (limited to 'host/lib/ic_reg_maps') diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 3a9ac1b08..7b8149802 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -96,6 +96,15 @@ UHD_PYTHON_GEN_SOURCE_FILE( ${CMAKE_CURRENT_BINARY_DIR}/ic_reg_maps/ad9777_regs.hpp ) +UHD_PYTHON_GEN_SOURCE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/ic_reg_maps/gen_ad5624_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ic_reg_maps/ad5624_regs.hpp +) + +UHD_PYTHON_GEN_SOURCE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/ic_reg_maps/gen_ad7922_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ic_reg_maps/ad7922_regs.hpp +) ######################################################################## # Add usrp2 sources diff --git a/host/lib/ic_reg_maps/gen_ad5624_regs.py b/host/lib/ic_reg_maps/gen_ad5624_regs.py new file mode 100755 index 000000000..378a6912f --- /dev/null +++ b/host/lib/ic_reg_maps/gen_ad5624_regs.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 asversion 3, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +import os +import sys +from common import * + +######################################################################## +# Template for raw text data describing registers +# name addr[bit range inclusive] default optional enums +######################################################################## +REGS_DATA_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 +""" + +######################################################################## +# Header and Source templates below +######################################################################## +HEADER_TEXT=""" +#import time + +/*********************************************************************** + * This file was generated by $file on $time.strftime("%c") + **********************************************************************/ + +\#ifndef INCLUDED_AD5624_REGS_HPP +\#define INCLUDED_AD5624_REGS_HPP + +\#include + +struct ad5624_regs_t{ +#for $reg in $regs + #if $reg.get_enums() + enum $(reg.get_name())_t{ + #for $i, $enum in enumerate($reg.get_enums()) + #set $end_comma = ',' if $i < len($reg.get_enums())-1 else '' + $(reg.get_name().upper())_$(enum[0].upper()) = $enum[1]$end_comma + #end for + } $reg.get_name(); + #else + boost::$reg.get_stdint_type() $reg.get_name(); + #end if +#end for + + ad5624_regs_t(void){ +#for $reg in $regs + $reg.get_name() = $reg.get_default(); +#end for + } + + 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; + } + +}; + +\#endif /* INCLUDED_AD5624_REGS_HPP */ +""" + +if __name__ == '__main__': + regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) + safe_makedirs(os.path.dirname(sys.argv[1])) + open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/ic_reg_maps/gen_ad7922_regs.py b/host/lib/ic_reg_maps/gen_ad7922_regs.py new file mode 100755 index 000000000..e1e67d617 --- /dev/null +++ b/host/lib/ic_reg_maps/gen_ad7922_regs.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 asversion 3, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +import os +import sys +from common import * + +######################################################################## +# Template for raw text data describing registers +# name addr[bit range inclusive] default optional enums +######################################################################## +REGS_DATA_TMPL="""\ +result 0[0:11] 0 +mod 0[12] 0 +chn 0[13] 0 +""" + +######################################################################## +# Header and Source templates below +######################################################################## +HEADER_TEXT=""" +#import time + +/*********************************************************************** + * This file was generated by $file on $time.strftime("%c") + **********************************************************************/ + +\#ifndef INCLUDED_AD7922_REGS_HPP +\#define INCLUDED_AD7922_REGS_HPP + +\#include + +struct ad7922_regs_t{ +#for $reg in $regs + #if $reg.get_enums() + enum $(reg.get_name())_t{ + #for $i, $enum in enumerate($reg.get_enums()) + #set $end_comma = ',' if $i < len($reg.get_enums())-1 else '' + $(reg.get_name().upper())_$(enum[0].upper()) = $enum[1]$end_comma + #end for + } $reg.get_name(); + #else + boost::$reg.get_stdint_type() $reg.get_name(); + #end if +#end for + + ad7922_regs_t(void){ +#for $reg in $regs + $reg.get_name() = $reg.get_default(); +#end for + } + + boost::uint16_t get_reg(void){ + boost::uint16_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; + } + + void set_reg(boost::uint16_t reg){ + #for $reg in filter(lambda r: r.get_addr() == 0, $regs) + $reg.get_name() = (reg >> $reg.get_shift()) & $reg.get_mask(); + #end for + } + +}; + +\#endif /* INCLUDED_AD7922_REGS_HPP */ +""" + +if __name__ == '__main__': + regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) + safe_makedirs(os.path.dirname(sys.argv[1])) + open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/usrp/usrp2/dboard_iface.cpp b/host/lib/usrp/usrp2/dboard_iface.cpp index 5ccb6fa47..591e958cb 100644 --- a/host/lib/usrp/usrp2/dboard_iface.cpp +++ b/host/lib/usrp/usrp2/dboard_iface.cpp @@ -25,6 +25,8 @@ #include //htonl and ntohl #include #include +#include "ad7922_regs.hpp" //aux adc +#include "ad5624_regs.hpp" //aux dac using namespace uhd; using namespace uhd::usrp; @@ -66,6 +68,9 @@ private: usrp2_iface::sptr _iface; clock_control::sptr _clk_ctrl; boost::uint32_t _ddr_shadow; + + uhd::dict _dac_regs; + void _write_aux_dac(unit_t); }; /*********************************************************************** @@ -93,6 +98,16 @@ usrp2_dboard_iface::usrp2_dboard_iface(usrp2_iface::sptr iface, clock_control::s } _iface->poke32(FR_GPIO_TX_SEL, new_sels); _iface->poke32(FR_GPIO_RX_SEL, new_sels); + + //reset the aux dacs + _dac_regs[UNIT_RX] = ad5624_regs_t(); + _dac_regs[UNIT_TX] = ad5624_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; + this->_write_aux_dac(unit); + } } usrp2_dboard_iface::~usrp2_dboard_iface(void){ @@ -240,42 +255,63 @@ byte_vector_t usrp2_dboard_iface::read_i2c(int i2c_addr, size_t num_bytes){ /*********************************************************************** * Aux DAX/ADC **********************************************************************/ -/*! - * Static function to convert a unit type enum - * to an over-the-wire value for the usrp2 control. - * \param unit the dboard interface unit type enum - * \return an over the wire representation - */ -static boost::uint8_t unit_to_otw(dboard_iface::unit_t unit){ - switch(unit){ - case dboard_iface::UNIT_TX: return USRP2_DIR_TX; - case dboard_iface::UNIT_RX: return USRP2_DIR_RX; - } - throw std::invalid_argument("unknown unit type"); +void usrp2_dboard_iface::_write_aux_dac(unit_t unit){ + static const uhd::dict unit_to_spi_dac = boost::assign::map_list_of + (UNIT_RX, SPI_SS_RX_DAC) + (UNIT_TX, SPI_SS_TX_DAC) + ; + _iface->transact_spi( + unit_to_spi_dac[unit], spi_config_t::EDGE_FALL, + _dac_regs[unit].get_reg(), 24, false /*no rb*/ + ); } void usrp2_dboard_iface::write_aux_dac(unit_t unit, int which, float value){ - //setup the out data - usrp2_ctrl_data_t out_data; - out_data.id = htonl(USRP2_CTRL_ID_WRITE_THIS_TO_THE_AUX_DAC_BRO); - out_data.data.aux_args.dir = unit_to_otw(unit); - out_data.data.aux_args.which = which; - out_data.data.aux_args.value = htonl(boost::math::iround(4095*value/3.3)); - - //send and recv - usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_DONE_WITH_THAT_AUX_DAC_DUDE); + _dac_regs[unit].data = boost::math::iround(4095*value/3.3); + _dac_regs[unit].cmd = ad5624_regs_t::CMD_WR_UP_DAC_CHAN_N; + 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; + default: throw std::runtime_error("not a possible aux dac, must be 0, 1, 2, or 3"); + } + this->_write_aux_dac(unit); } float usrp2_dboard_iface::read_aux_adc(unit_t unit, int which){ - //setup the out data - usrp2_ctrl_data_t out_data; - out_data.id = htonl(USRP2_CTRL_ID_READ_FROM_THIS_AUX_ADC_BRO); - out_data.data.aux_args.dir = unit_to_otw(unit); - out_data.data.aux_args.which = which; + static const uhd::dict unit_to_spi_adc = boost::assign::map_list_of + (UNIT_RX, SPI_SS_RX_ADC) + (UNIT_TX, SPI_SS_TX_ADC) + ; + + //setup spi config args + spi_config_t config; + config.mosi_edge = spi_config_t::EDGE_FALL; + config.miso_edge = spi_config_t::EDGE_RISE; + + //setup the spi registers + ad7922_regs_t ad7922_regs; + ad7922_regs.mod = which; //normal mode: mod == chn + ad7922_regs.chn = which; + + //write and read spi + _iface->transact_spi( + unit_to_spi_adc[unit], config, + ad7922_regs.get_reg(), 16, false /*no rb*/ + ); + boost::uint16_t reg = _iface->transact_spi( + unit_to_spi_adc[unit], config, + ad7922_regs.get_reg(), 16, true /*rb*/ + ); + ad7922_regs.set_reg(reg); + + //convert to voltage and return + return float(3.3*ad7922_regs.result/4095); + + + + + - //send and recv - usrp2_ctrl_data_t in_data = _iface->ctrl_send_and_recv(out_data); - ASSERT_THROW(htonl(in_data.id) == USRP2_CTRL_ID_DONE_WITH_THAT_AUX_ADC_DUDE); - return float(3.3*ntohl(in_data.data.aux_args.value)/4095); } -- cgit v1.2.3 From 6b015b1c517733e85cb0c08a379e8d20377bf2fa Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 19 Apr 2010 23:48:00 -0700 Subject: added comments to cmakelists, makedir in file generation script so python doesnt have to --- host/docs/CMakeLists.txt | 30 +++++++++++++++++++++++------- host/include/uhd/types/metadata.hpp | 10 ++++++++-- host/lib/CMakeLists.txt | 7 +++++++ host/lib/ic_reg_maps/common.py | 4 ---- host/lib/ic_reg_maps/gen_ad5624_regs.py | 2 -- host/lib/ic_reg_maps/gen_ad7922_regs.py | 2 -- host/lib/ic_reg_maps/gen_ad9510_regs.py | 2 -- host/lib/ic_reg_maps/gen_ad9777_regs.py | 2 -- host/lib/ic_reg_maps/gen_adf4360_regs.py | 2 -- 9 files changed, 38 insertions(+), 23 deletions(-) (limited to 'host/lib/ic_reg_maps') diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt index 52376fe8c..476023a1e 100644 --- a/host/docs/CMakeLists.txt +++ b/host/docs/CMakeLists.txt @@ -35,25 +35,33 @@ IF(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") ELSE(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") MESSAGE(STATUS "Checking for rst2html (docutils) - found") MESSAGE(STATUS " Enabled generation of HTML manual.") - SET(stylesheet ${CMAKE_CURRENT_SOURCE_DIR}/style.css) + + #setup rst2html options SET(rst2html_options - --stylesheet=${stylesheet} - --no-toc-backlinks - --date - --time + --stylesheet=${CMAKE_CURRENT_SOURCE_DIR}/style.css + --no-toc-backlinks --date --time ) + + #create generation rule for each source FOREACH(rstfile ${manual_sources}) + #set input and output file names SET(rstfile ${CMAKE_CURRENT_SOURCE_DIR}/${rstfile}) GET_FILENAME_COMPONENT(rstfile_we ${rstfile} NAME_WE) SET(htmlfile ${CMAKE_CURRENT_BINARY_DIR}/${rstfile_we}.html) + + #make the html file depend on the rst file ADD_CUSTOM_COMMAND( OUTPUT ${htmlfile} DEPENDS ${rstfile} ${stylesheet} COMMAND ${RST2HTML} ${rstfile} ${htmlfile} ${rst2html_options} COMMENT "Generating ${htmlfile}" ) + + #make the manual target depend on the html file LIST(APPEND manual_html_files ${htmlfile}) INSTALL(FILES ${htmlfile} DESTINATION ${PKG_DOC_DIR}/manual/html) ENDFOREACH(rstfile ${manual_sources}) + + #make the html manual a build-time dependency ADD_CUSTOM_TARGET(manual_html ALL DEPENDS ${manual_html_files}) ENDIF(${RST2HTML} STREQUAL "RST2HTML-NOTFOUND") @@ -66,16 +74,24 @@ INCLUDE(FindDoxygen) IF(DOXYGEN_FOUND) MESSAGE(STATUS " Enabled generation of Doxygen documentation.") + + #generate the doxygen configuration file SET(CMAKE_CURRENT_BINARY_DIR_DOXYGEN ${CMAKE_CURRENT_BINARY_DIR}/doxygen) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) - ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN} + + #make doxygen directory depend on the header files + FILE(GLOB_RECURSE header_files ${CMAKE_SOURCE_DIR}/include/*.hpp) + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN} DEPENDS ${header_files} COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile COMMENT "Generating documentation with doxygen" ) - ADD_CUSTOM_TARGET(doxygen_html ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN}) + + #make the doxygen generation a built-time dependency + ADD_CUSTOM_TARGET(doxygen_docs ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN}) INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN} DESTINATION ${PKG_DOC_DIR}) ELSE(DOXYGEN_FOUND) MESSAGE(STATUS " Disabled generation of Doxygen documentation.") diff --git a/host/include/uhd/types/metadata.hpp b/host/include/uhd/types/metadata.hpp index d93b38b50..55add71cc 100644 --- a/host/include/uhd/types/metadata.hpp +++ b/host/include/uhd/types/metadata.hpp @@ -70,7 +70,10 @@ namespace uhd{ * Timed-out on receive? */ - //default constructor + /*! + * The default constructor: + * Sets the fields to default values (flags set to false). + */ rx_metadata_t(void); }; @@ -103,7 +106,10 @@ namespace uhd{ bool start_of_burst; bool end_of_burst; - //default constructor + /*! + * The default constructor: + * Sets the fields to default values (flags set to false). + */ tx_metadata_t(void); }; diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 7b8149802..7cb74d30a 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -66,11 +66,18 @@ SET(libuhd_sources # Generate Files ######################################################################## MACRO(UHD_PYTHON_GEN_SOURCE_FILE pyfile outfile) + #ensure that the directory exists for outfile + GET_FILENAME_COMPONENT(outfile_dir ${outfile} PATH) + FILE(MAKE_DIRECTORY ${outfile_dir}) + + #make the outfile depend on the python script ADD_CUSTOM_COMMAND( OUTPUT ${outfile} DEPENDS ${pyfile} COMMAND ${PYTHON_EXECUTABLE} ${pyfile} ${outfile} COMMENT "Generating ${outfile}" ) + + #make libuhd depend on the outfile LIST(APPEND libuhd_sources ${outfile}) ENDMACRO(UHD_PYTHON_GEN_SOURCE_FILE) diff --git a/host/lib/ic_reg_maps/common.py b/host/lib/ic_reg_maps/common.py index b7fa27bbe..bf51073ae 100644 --- a/host/lib/ic_reg_maps/common.py +++ b/host/lib/ic_reg_maps/common.py @@ -19,16 +19,12 @@ # Boston, MA 02110-1301, USA. import re -import os import math from Cheetah.Template import Template def parse_tmpl(_tmpl_text, **kwargs): return str(Template(_tmpl_text, kwargs)) -def safe_makedirs(path): - not os.path.isdir(path) and os.makedirs(path) - class reg: def __init__(self, reg_des): x = re.match('^(\w*)\s*(\w*)\[(.*)\]\s*(\w*)\s*(.*)$', reg_des) diff --git a/host/lib/ic_reg_maps/gen_ad5624_regs.py b/host/lib/ic_reg_maps/gen_ad5624_regs.py index 378a6912f..a809d2f47 100755 --- a/host/lib/ic_reg_maps/gen_ad5624_regs.py +++ b/host/lib/ic_reg_maps/gen_ad5624_regs.py @@ -19,7 +19,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import os import sys from common import * @@ -83,5 +82,4 @@ struct ad5624_regs_t{ if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) - safe_makedirs(os.path.dirname(sys.argv[1])) open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/ic_reg_maps/gen_ad7922_regs.py b/host/lib/ic_reg_maps/gen_ad7922_regs.py index e1e67d617..512dcdc46 100755 --- a/host/lib/ic_reg_maps/gen_ad7922_regs.py +++ b/host/lib/ic_reg_maps/gen_ad7922_regs.py @@ -19,7 +19,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import os import sys from common import * @@ -89,5 +88,4 @@ struct ad7922_regs_t{ if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) - safe_makedirs(os.path.dirname(sys.argv[1])) open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/ic_reg_maps/gen_ad9510_regs.py b/host/lib/ic_reg_maps/gen_ad9510_regs.py index 32a8a04c6..4f28d5597 100755 --- a/host/lib/ic_reg_maps/gen_ad9510_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9510_regs.py @@ -19,7 +19,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import os import sys from common import * @@ -174,5 +173,4 @@ struct ad9510_regs_t{ if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) - safe_makedirs(os.path.dirname(sys.argv[1])) open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/ic_reg_maps/gen_ad9777_regs.py b/host/lib/ic_reg_maps/gen_ad9777_regs.py index e4369291a..65a9657a4 100755 --- a/host/lib/ic_reg_maps/gen_ad9777_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9777_regs.py @@ -19,7 +19,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import os import sys from common import * @@ -152,5 +151,4 @@ struct ad9777_regs_t{ if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) - safe_makedirs(os.path.dirname(sys.argv[1])) open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/ic_reg_maps/gen_adf4360_regs.py b/host/lib/ic_reg_maps/gen_adf4360_regs.py index f82e8c7c5..c659766dc 100755 --- a/host/lib/ic_reg_maps/gen_adf4360_regs.py +++ b/host/lib/ic_reg_maps/gen_adf4360_regs.py @@ -19,7 +19,6 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -import os import sys from common import * @@ -123,5 +122,4 @@ struct adf4360_regs_t{ if __name__ == '__main__': regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) - safe_makedirs(os.path.dirname(sys.argv[1])) open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) -- cgit v1.2.3 From fd1067907d6e19249129d52bb7dcfd3f7b21d7d1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Apr 2010 15:55:01 -0700 Subject: added regs for max2829 --- host/README | 1 + host/lib/CMakeLists.txt | 5 + host/lib/ic_reg_maps/gen_max2829_regs.py | 169 +++++++++++++++++++++++++++++++ host/lib/usrp/dboard/db_xcvr2450.cpp | 29 +++--- 4 files changed, 192 insertions(+), 12 deletions(-) create mode 100755 host/lib/ic_reg_maps/gen_max2829_regs.py (limited to 'host/lib/ic_reg_maps') diff --git a/host/README b/host/README index 05a53b197..e67bb25f8 100644 --- a/host/README +++ b/host/README @@ -16,6 +16,7 @@ Basic TX LF RX LF TX RFX Series +XCVR 2450 ######################################################################## # Documentation diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index d43a61010..5495620ec 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -111,6 +111,11 @@ UHD_PYTHON_GEN_SOURCE_FILE( ${CMAKE_CURRENT_BINARY_DIR}/ic_reg_maps/ad7922_regs.hpp ) +UHD_PYTHON_GEN_SOURCE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/ic_reg_maps/gen_max2829_regs.py + ${CMAKE_CURRENT_BINARY_DIR}/ic_reg_maps/max2829_regs.hpp +) + ######################################################################## # Add dboard sources ######################################################################## diff --git a/host/lib/ic_reg_maps/gen_max2829_regs.py b/host/lib/ic_reg_maps/gen_max2829_regs.py new file mode 100755 index 000000000..91a711ecc --- /dev/null +++ b/host/lib/ic_reg_maps/gen_max2829_regs.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 asversion 3, or (at your option) +# any later version. +# +# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +import sys +from common import * + +######################################################################## +# Template for raw text data describing registers +# name addr[bit range inclusive] default optional enums +######################################################################## +REGS_DATA_TMPL="""\ +######################################################################## +## Note: offsets given from perspective of data bits (excludes address) +######################################################################## +## +######################################################################## +## Standby (2) +######################################################################## +_set_to_1_2_0 2[0] 1 +_set_to_1_2_1 2[1] 1 +_set_to_1_2_2 2[2] 1 +pa_bias_dac 2[10] 0 +voltage_ref 2[11] 0 +_set_to_1_2_12 2[12] 1 +mimo_select 2[13] 0 normal, mimo +######################################################################## +## Integer Divider Ratio (3) +######################################################################## +id_ratio_word 3[0:7] a2 +frac_div_ratio_lsb 3[12:13] 0 +######################################################################## +## Fractional Divider Ratio (4) +######################################################################## +frac_div_ratio_msb 4[0:13] 0 +######################################################################## +## Band Select and PLL (5) +######################################################################## +band_select 5[0] 0 2_4ghz, 5ghz +ref_divider 5[1:3] 1 +pll_cp_select 5[5] 1 2ma, 4ma +band_select_802_11a 5[6] 0 4_9ghz_to_5_35ghz, 5_47ghz_to_5_875ghz +vco_bandswitch 5[7] 0 disable, automatic +vco_spi_bandswitch 5[8] 0 fsm, spi +vco_sub_band 5[9:10] 0 +_set_to_1_5_11 5[11] 1 +_set_to_1_5_12 5[12] 1 +band_sel_mimo 5[13] 0 normal, mimo +######################################################################## +## Calibration (6) +######################################################################## +rx_cal_mode 6[0] 0 dis, enb +tx_cal_mode 6[1] 0 dis, enb +_set_to_1_6_10 6[10] 1 +iq_cal_gain 6[11:12] 3 8db, 18db, 24db, 34db +######################################################################## +## Lopass Filter (7) +######################################################################## +rx_lpf_fine_adj 7[0:2] 2 90, 95, 100, 105, 110 +rx_lpf_coarse_adj 7[3:4] 1 7_5mhz, 9_5mhz, 14mhz, 18mhz +tx_lpf_coarse_adj 7[5:6] 1 12mhz=1, 18mhz=2, 24mhz=3 +rssi_high_bw 7[11] 0 2mhz, 6mhz +######################################################################## +## Rx Control/RSSI (8) +######################################################################## +_set_to_1_8_0 8[0] 1 +rx_highpass 8[2] 1 100hz, 30khz +_set_to_1_8_5 8[5] 1 +rssi_pin_fcn 8[8] 0 rssi, temp +rssi_op_mode 8[10] 0 rssi_rxhp, enabled +rssi_output_range 8[11] 0 low, high +rx_vga_gain_spi 8[12] 0 io, spi +######################################################################## +## Tx Linearity/Baseband Gain (9) +######################################################################## +tx_baseband_gain 9[0:1] 0 0db, 2db, 3_5db, 5db +tx_upconv_linearity 9[2:3] 0 50, 63, 78, 100 +tx_vga_linearity 9[6:7] 0 50, 63, 78, 100 +pa_driver_linearity 9[8:9] 2 50, 63, 78, 100 +tx_vga_gain_spi 9[10] 0 io, spi +######################################################################## +## PA Bias DAC (10) +######################################################################## +pa_bias_dac_out_curr a[0:5] 0 +pa_bias_dac_delay a[6:9] f +######################################################################## +## Rx Gain (11) +######################################################################## +rx_vga_gain b[0:4] 1f +rx_lna_gain b[5:6] 3 +######################################################################## +## Tx VGA Gain (12) +######################################################################## +tx_vga_gain c[0:5] 0 +""" + +######################################################################## +# Header and Source templates below +######################################################################## +HEADER_TEXT=""" +#import time + +/*********************************************************************** + * This file was generated by $file on $time.strftime("%c") + **********************************************************************/ + +\#ifndef INCLUDED_MAX2829_REGS_HPP +\#define INCLUDED_MAX2829_REGS_HPP + +\#include + +struct max2829_regs_t{ +#for $reg in $regs + #if $reg.get_enums() + enum $(reg.get_name())_t{ + #for $i, $enum in enumerate($reg.get_enums()) + #set $end_comma = ',' if $i < len($reg.get_enums())-1 else '' + $(reg.get_name().upper())_$(enum[0].upper()) = $enum[1]$end_comma + #end for + } $reg.get_name(); + #else + boost::$reg.get_stdint_type() $reg.get_name(); + #end if +#end for + + max2829_regs_t(void){ +#for $reg in $regs + $reg.get_name() = $reg.get_default(); +#end for + } + + boost::uint32_t get_reg(boost::uint8_t addr){ + boost::uint16_t reg = 0; + switch(addr){ + #for $addr in range(2, 12+1) + case $addr: + #for $reg in filter(lambda r: r.get_addr() == addr, $regs) + reg |= (boost::uint16_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); + #end for + break; + #end for + } + return (boost::uint32_t(reg) << 4) | (addr & 0xf); + } +}; + +\#endif /* INCLUDED_MAX2829_REGS_HPP */ +""" + +if __name__ == '__main__': + regs = map(reg, parse_tmpl(REGS_DATA_TMPL).splitlines()) + open(sys.argv[1], 'w').write(parse_tmpl(HEADER_TEXT, regs=regs, file=__file__)) diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 44921d7d4..8002acc01 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -47,6 +47,7 @@ #define RX_ENB_RXIO RX_EN_RXIO #define RX_DIS_RXIO 0 +#include "max2829_regs.hpp" #include #include #include @@ -65,10 +66,23 @@ using namespace uhd::usrp; using namespace boost::assign; /*********************************************************************** - * The XCVR 2450 dboard + * The XCVR 2450 constants **********************************************************************/ static const freq_range_t xcvr_freq_range(2.4e9, 6.0e9); +static const prop_names_t xcvr_antennas = list_of("J1")("J2"); + +static const uhd::dict xcvr_tx_gain_ranges = map_list_of + ("VGA", gain_range_t(0, 30, 0.5)) +; +static const uhd::dict xcvr_rx_gain_ranges = map_list_of + ("RF LNA", gain_range_t(0, 30.5, 15)) + ("BB VGA", gain_range_t(0, 62, 2.0)) +; + +/*********************************************************************** + * The XCVR 2450 dboard class + **********************************************************************/ class xcvr2450 : public xcvr_dboard_base{ public: xcvr2450(ctor_args_t const& args); @@ -85,6 +99,7 @@ private: uhd::dict _tx_gains, _rx_gains; std::string _tx_ant, _rx_ant; int _ad9515div; + max2829_regs_t _max2829_regs; void set_lo_freq(double target_freq); void set_tx_ant(const std::string &ant); @@ -96,7 +111,7 @@ private: }; /*********************************************************************** - * Register the XCVR dboard + * Register the XCVR 2450 dboard **********************************************************************/ static dboard_base::sptr make_xcvr2450(dboard_base::ctor_args_t const& args){ return dboard_base::sptr(new xcvr2450(args)); @@ -164,8 +179,6 @@ void xcvr2450::set_lo_freq(double target_freq){ /*********************************************************************** * Antenna Handling **********************************************************************/ -static const prop_names_t xcvr_antennas = list_of("J1")("J2"); - void xcvr2450::set_tx_ant(const std::string &ant){ assert_has(xcvr_antennas, ant, "xcvr antenna name"); //TODO @@ -179,14 +192,6 @@ void xcvr2450::set_rx_ant(const std::string &ant){ /*********************************************************************** * Gain Handling **********************************************************************/ -static const uhd::dict xcvr_tx_gain_ranges = map_list_of - ("VGA", gain_range_t(0, 30, 0.5)) -; -static const uhd::dict xcvr_rx_gain_ranges = map_list_of - ("RF LNA", gain_range_t(0, 30.5, 15)) - ("BB VGA", gain_range_t(0, 62, 2.0)) -; - /*! * Convert a requested gain for the tx vga into the integer register value. * The gain passed into the function will be set to the actual value. -- cgit v1.2.3 From 3551ef506737576d15b86b151bce3ae225d36092 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Apr 2010 18:18:44 -0700 Subject: filled in xcvr tuning, set gain, spi reset --- host/lib/ic_reg_maps/gen_max2829_regs.py | 2 +- host/lib/usrp/dboard/db_xcvr2450.cpp | 165 ++++++++++++++++++++++++++++--- 2 files changed, 152 insertions(+), 15 deletions(-) (limited to 'host/lib/ic_reg_maps') diff --git a/host/lib/ic_reg_maps/gen_max2829_regs.py b/host/lib/ic_reg_maps/gen_max2829_regs.py index 91a711ecc..46b48dfe7 100755 --- a/host/lib/ic_reg_maps/gen_max2829_regs.py +++ b/host/lib/ic_reg_maps/gen_max2829_regs.py @@ -44,7 +44,7 @@ mimo_select 2[13] 0 normal, mimo ######################################################################## ## Integer Divider Ratio (3) ######################################################################## -id_ratio_word 3[0:7] a2 +int_div_ratio_word 3[0:7] a2 frac_div_ratio_lsb 3[12:13] 0 ######################################################################## ## Fractional Divider Ratio (4) diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 8002acc01..fbce4b932 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -68,16 +68,19 @@ using namespace boost::assign; /*********************************************************************** * The XCVR 2450 constants **********************************************************************/ +static const bool xcvr2450_debug = true; + static const freq_range_t xcvr_freq_range(2.4e9, 6.0e9); static const prop_names_t xcvr_antennas = list_of("J1")("J2"); static const uhd::dict xcvr_tx_gain_ranges = map_list_of ("VGA", gain_range_t(0, 30, 0.5)) + ("BB", gain_range_t(0, 5, 1.5)) ; static const uhd::dict xcvr_rx_gain_ranges = map_list_of - ("RF LNA", gain_range_t(0, 30.5, 15)) - ("BB VGA", gain_range_t(0, 62, 2.0)) + ("LNA", gain_range_t(0, 30.5, 15)) + ("VGA", gain_range_t(0, 62, 2.0)) ; /*********************************************************************** @@ -108,6 +111,14 @@ private: void set_rx_gain(float gain, const std::string &name); void update_atr(void); + void spi_reset(void); + void send_reg(boost::uint8_t addr){ + this->get_iface()->write_spi( + dboard_iface::UNIT_RX, + spi_config_t::EDGE_RISE, + _max2829_regs.get_reg(addr), 24 + ); + } }; /*********************************************************************** @@ -134,22 +145,54 @@ xcvr2450::xcvr2450(ctor_args_t const& args) : xcvr_dboard_base(args){ this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_TX, TXIO_MASK); this->get_iface()->set_gpio_ddr(dboard_iface::UNIT_RX, RXIO_MASK); + spi_reset(); //prepare the spi + + //setup the misc max2829 registers + _max2829_regs.mimo_select = max2829_regs_t::MIMO_SELECT_MIMO; + _max2829_regs.band_sel_mimo = max2829_regs_t::BAND_SEL_MIMO_MIMO; + _max2829_regs.pll_cp_select = max2829_regs_t::PLL_CP_SELECT_4MA; + _max2829_regs.rssi_high_bw = max2829_regs_t::RSSI_HIGH_BW_6MHZ; + _max2829_regs.tx_lpf_coarse_adj = max2829_regs_t::TX_LPF_COARSE_ADJ_12MHZ; + _max2829_regs.rx_lpf_coarse_adj = max2829_regs_t::RX_LPF_COARSE_ADJ_9_5MHZ; + _max2829_regs.rx_lpf_fine_adj = max2829_regs_t::RX_LPF_FINE_ADJ_95; + _max2829_regs.rx_vga_gain_spi = max2829_regs_t::RX_VGA_GAIN_SPI_SPI; + _max2829_regs.rssi_output_range = max2829_regs_t::RSSI_OUTPUT_RANGE_HIGH; + _max2829_regs.rssi_op_mode = max2829_regs_t::RSSI_OP_MODE_ENABLED; + _max2829_regs.rssi_pin_fcn = max2829_regs_t::RSSI_PIN_FCN_RSSI; + _max2829_regs.rx_highpass = max2829_regs_t::RX_HIGHPASS_100HZ; + _max2829_regs.tx_vga_gain_spi = max2829_regs_t::TX_VGA_GAIN_SPI_SPI; + _max2829_regs.pa_driver_linearity = max2829_regs_t::PA_DRIVER_LINEARITY_78; + _max2829_regs.tx_vga_linearity = max2829_regs_t::TX_VGA_LINEARITY_78; + _max2829_regs.tx_upconv_linearity = max2829_regs_t::TX_UPCONV_LINEARITY_78; + + //send initial register settings + for(boost::uint8_t reg = 0; reg <= 0xC; reg++){ + this->send_reg(reg); + } + //set defaults for LO, gains, antennas set_lo_freq(2.45e9); set_rx_ant("J1"); set_tx_ant("J2"); - set_rx_gain(0, "RF LNA"); - set_rx_gain(0, "BB VGA"); + set_rx_gain(0, "LNA"); + set_rx_gain(0, "VGA"); set_tx_gain(0, "VGA"); + set_tx_gain(0, "BB"); } xcvr2450::~xcvr2450(void){ - /* NOP */ + spi_reset(); +} + +void xcvr2450::spi_reset(void){ + //spi reset mode: global enable = off, tx and rx enable = on + this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE, TX_ENB_TXIO); + this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, RX_ENB_RXIO); } void xcvr2450::update_atr(void){ //calculate tx atr pins - int band_sel = (_lo_freq > 4e9)? HB_PA_TXIO : LB_PA_TXIO; + int band_sel = (_lo_freq > 3e9)? HB_PA_TXIO : LB_PA_TXIO; int tx_ant_sel = (_tx_ant == "J1")? ANTSEL_TX1_RX2_TXIO : ANTSEL_TX2_RX1_TXIO; int rx_ant_sel = (_rx_ant == "J1")? ANTSEL_TX1_RX2_TXIO : ANTSEL_TX2_RX1_TXIO; int xx_ant_sel = tx_ant_sel; //prefer the tx antenna selection for full duplex (rx will get the other antenna) @@ -172,8 +215,57 @@ void xcvr2450::update_atr(void){ * Tuning **********************************************************************/ void xcvr2450::set_lo_freq(double target_freq){ - //TODO - //set _ad9515div + //variables used in the calculation below + double scaler = (_lo_freq > 3e9)? (4.0/5.0) : (4.0/3.0); + double ref_freq = this->get_iface()->get_clock_rate(dboard_iface::UNIT_TX); + int R, intdiv, fracdiv; + + //loop through values until we get a match + for(R = 1; R <= 7; R++){ + for(_ad9515div = 2; _ad9515div <= 3; _ad9515div++){ + double N = (target_freq*scaler*R*_ad9515div)/ref_freq; + intdiv = int(std::floor(N)); + fracdiv = (N - intdiv)*double(1 << 16); + //actual minimum is 128, but most chips seems to require higher to lock + if (intdiv < 131 or intdiv > 255) continue; + //constraints met: exit loop + goto done_loop; + } + } done_loop: + + //calculate the actual freq from the values above + double N = double(intdiv) + double(fracdiv)/double(1 << 16); + _lo_freq = (scaler*R*_ad9515div)/(N*ref_freq); + + if (xcvr2450_debug) std::cerr << boost::format( + "XCVR2450 tune: R=%d, N=%f, ad9515=%d, scaler=%f\n" + " Target Freq=%fMHz, Actual Freq=%fMHz" + ) % R % N % _ad9515div % scaler % (target_freq/1e6) % (_lo_freq/1e6) << std::endl; + + //high-high band or low-high band? + if(_lo_freq > (5.35e9 + 4.47e9)/2.0){ + _max2829_regs.band_select_802_11a = max2829_regs_t::BAND_SELECT_802_11A_5_47GHZ_TO_5_875GHZ; + }else{ + _max2829_regs.band_select_802_11a = max2829_regs_t::BAND_SELECT_802_11A_4_9GHZ_TO_5_35GHZ; + } + + //new band select settings and ad9515 divider + this->update_atr(); + + //load new counters into registers + _max2829_regs.int_div_ratio_word = intdiv; + _max2829_regs.frac_div_ratio_lsb = fracdiv & 0x3; + _max2829_regs.frac_div_ratio_msb = fracdiv >> 2; + this->send_reg(0x3); //integer + this->send_reg(0x4); //fractional + + //load the reference divider and band select into registers + //toggle the bandswitch from off to automatic (which really means start) + _max2829_regs.ref_divider = R; + _max2829_regs.vco_bandswitch = max2829_regs_t::VCO_BANDSWITCH_DISABLE; + this->send_reg(0x5); + _max2829_regs.vco_bandswitch = max2829_regs_t::VCO_BANDSWITCH_AUTOMATIC;; + this->send_reg(0x5); } /*********************************************************************** @@ -181,12 +273,14 @@ void xcvr2450::set_lo_freq(double target_freq){ **********************************************************************/ void xcvr2450::set_tx_ant(const std::string &ant){ assert_has(xcvr_antennas, ant, "xcvr antenna name"); - //TODO + _tx_ant = ant; + this->update_atr(); //sets the atr to the new antenna setting } void xcvr2450::set_rx_ant(const std::string &ant){ assert_has(xcvr_antennas, ant, "xcvr antenna name"); - //TODO + _rx_ant = ant; + this->update_atr(); //sets the atr to the new antenna setting } /*********************************************************************** @@ -211,13 +305,38 @@ static int gain_to_tx_vga_reg(float &gain){ return reg; } +/*! + * Convert a requested gain for the tx bb into the integer register value. + * The gain passed into the function will be set to the actual value. + * \param gain the requested gain in dB + * \return gain enum value + */ +static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(float &gain){ + int reg = std::clip(boost::math::iround(gain*3/5.0), 0, 3); + switch(reg){ + case 0: + gain = 0; + return max2829_regs_t::TX_BASEBAND_GAIN_0DB; + case 1: + gain = 2; + return max2829_regs_t::TX_BASEBAND_GAIN_2DB; + case 2: + gain = 3.5; + return max2829_regs_t::TX_BASEBAND_GAIN_3_5DB; + case 3: + gain = 5; + return max2829_regs_t::TX_BASEBAND_GAIN_5DB; + } + ASSERT_THROW(false); +} + /*! * Convert a requested gain for the rx vga into the integer register value. * The gain passed into the function will be set to the actual value. * \param gain the requested gain in dB * \return 5 bit the register value */ -static int gain_to_rx_bb_vga_reg(float &gain){ +static int gain_to_rx_vga_reg(float &gain){ int reg = std::clip(boost::math::iround(gain/2.0), 0, 31); gain = reg*2; return reg; @@ -229,7 +348,7 @@ static int gain_to_rx_bb_vga_reg(float &gain){ * \param gain the requested gain in dB * \return 2 bit the register value */ -static int gain_to_rx_rf_lna_reg(float &gain){ +static int gain_to_rx_lna_reg(float &gain){ int reg = std::clip(boost::math::iround(gain*2/30.5) + 1, 0, 3); switch(reg){ case 0: @@ -242,12 +361,30 @@ static int gain_to_rx_rf_lna_reg(float &gain){ void xcvr2450::set_tx_gain(float gain, const std::string &name){ assert_has(xcvr_tx_gain_ranges.keys(), name, "xcvr tx gain name"); - //TODO + if (name == "VGA"){ + _max2829_regs.tx_vga_gain = gain_to_tx_vga_reg(gain); + send_reg(0xC); + } + else if(name == "BB"){ + _max2829_regs.tx_baseband_gain = gain_to_tx_bb_reg(gain); + send_reg(0x9); + } + else ASSERT_THROW(false); + _tx_gains[name] = gain; } void xcvr2450::set_rx_gain(float gain, const std::string &name){ assert_has(xcvr_rx_gain_ranges.keys(), name, "xcvr rx gain name"); - //TODO + if (name == "VGA"){ + _max2829_regs.rx_vga_gain = gain_to_rx_vga_reg(gain); + send_reg(0xB); + } + else if(name == "LNA"){ + _max2829_regs.rx_lna_gain = gain_to_rx_lna_reg(gain); + send_reg(0xB); + } + else ASSERT_THROW(false); + _rx_gains[name] = gain; } /*********************************************************************** -- cgit v1.2.3 From 6779af928778d3baf3fff26ab611be71592a4323 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 23 Apr 2010 15:05:42 -0700 Subject: whoops, copied wrong license --- host/lib/ic_reg_maps/common.py | 23 ++++++++++------------- host/lib/ic_reg_maps/gen_ad5624_regs.py | 23 ++++++++++------------- host/lib/ic_reg_maps/gen_ad7922_regs.py | 23 ++++++++++------------- host/lib/ic_reg_maps/gen_ad9510_regs.py | 23 ++++++++++------------- host/lib/ic_reg_maps/gen_ad9777_regs.py | 23 ++++++++++------------- host/lib/ic_reg_maps/gen_adf4360_regs.py | 23 ++++++++++------------- host/lib/ic_reg_maps/gen_max2829_regs.py | 23 ++++++++++------------- 7 files changed, 70 insertions(+), 91 deletions(-) (limited to 'host/lib/ic_reg_maps') diff --git a/host/lib/ic_reg_maps/common.py b/host/lib/ic_reg_maps/common.py index bf51073ae..d05470706 100644 --- a/host/lib/ic_reg_maps/common.py +++ b/host/lib/ic_reg_maps/common.py @@ -1,22 +1,19 @@ # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import re import math diff --git a/host/lib/ic_reg_maps/gen_ad5624_regs.py b/host/lib/ic_reg_maps/gen_ad5624_regs.py index a809d2f47..9e8ae5be5 100755 --- a/host/lib/ic_reg_maps/gen_ad5624_regs.py +++ b/host/lib/ic_reg_maps/gen_ad5624_regs.py @@ -1,23 +1,20 @@ #!/usr/bin/env python # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import sys from common import * diff --git a/host/lib/ic_reg_maps/gen_ad7922_regs.py b/host/lib/ic_reg_maps/gen_ad7922_regs.py index 512dcdc46..23f28c0da 100755 --- a/host/lib/ic_reg_maps/gen_ad7922_regs.py +++ b/host/lib/ic_reg_maps/gen_ad7922_regs.py @@ -1,23 +1,20 @@ #!/usr/bin/env python # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import sys from common import * diff --git a/host/lib/ic_reg_maps/gen_ad9510_regs.py b/host/lib/ic_reg_maps/gen_ad9510_regs.py index 4f28d5597..2dc19c691 100755 --- a/host/lib/ic_reg_maps/gen_ad9510_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9510_regs.py @@ -1,23 +1,20 @@ #!/usr/bin/env python # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import sys from common import * diff --git a/host/lib/ic_reg_maps/gen_ad9777_regs.py b/host/lib/ic_reg_maps/gen_ad9777_regs.py index 65a9657a4..2ac73efcf 100755 --- a/host/lib/ic_reg_maps/gen_ad9777_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9777_regs.py @@ -1,23 +1,20 @@ #!/usr/bin/env python # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import sys from common import * diff --git a/host/lib/ic_reg_maps/gen_adf4360_regs.py b/host/lib/ic_reg_maps/gen_adf4360_regs.py index c659766dc..478e471a3 100755 --- a/host/lib/ic_reg_maps/gen_adf4360_regs.py +++ b/host/lib/ic_reg_maps/gen_adf4360_regs.py @@ -1,23 +1,20 @@ #!/usr/bin/env python # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import sys from common import * diff --git a/host/lib/ic_reg_maps/gen_max2829_regs.py b/host/lib/ic_reg_maps/gen_max2829_regs.py index 46b48dfe7..33dc3e641 100755 --- a/host/lib/ic_reg_maps/gen_max2829_regs.py +++ b/host/lib/ic_reg_maps/gen_max2829_regs.py @@ -1,23 +1,20 @@ #!/usr/bin/env python # -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify +# 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 asversion 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, +# 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 GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. +# along with this program. If not, see . +# import sys from common import * -- cgit v1.2.3 From a29b30fdf17b5703c9b5c5dd015f11ecd44fbdfe Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 23 Apr 2010 15:59:22 -0700 Subject: XCVR seems to be working, fixed the spi reset routine. --- host/lib/ic_reg_maps/gen_max2829_regs.py | 2 +- host/lib/usrp/dboard/db_xcvr2450.cpp | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'host/lib/ic_reg_maps') diff --git a/host/lib/ic_reg_maps/gen_max2829_regs.py b/host/lib/ic_reg_maps/gen_max2829_regs.py index 33dc3e641..7fef302a8 100755 --- a/host/lib/ic_reg_maps/gen_max2829_regs.py +++ b/host/lib/ic_reg_maps/gen_max2829_regs.py @@ -68,7 +68,7 @@ tx_cal_mode 6[1] 0 dis, enb _set_to_1_6_10 6[10] 1 iq_cal_gain 6[11:12] 3 8db, 18db, 24db, 34db ######################################################################## -## Lopass Filter (7) +## Lowpass Filter (7) ######################################################################## rx_lpf_fine_adj 7[0:2] 2 90, 95, 100, 105, 110 rx_lpf_coarse_adj 7[3:4] 1 7_5mhz, 9_5mhz, 14mhz, 18mhz diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 4df40e980..2c2843d3a 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include @@ -68,7 +69,7 @@ using namespace boost::assign; /*********************************************************************** * The XCVR 2450 constants **********************************************************************/ -static const bool xcvr2450_debug = true; +static const bool xcvr2450_debug = false; static const freq_range_t xcvr_freq_range(2.4e9, 6.0e9); @@ -178,12 +179,14 @@ xcvr2450::xcvr2450(ctor_args_t const& args) : xcvr_dboard_base(args){ //set defaults for LO, gains, antennas set_lo_freq(2.45e9); - set_rx_ant("J1"); - set_tx_ant("J2"); - set_rx_gain(0, "LNA"); - set_rx_gain(0, "VGA"); - set_tx_gain(0, "VGA"); - set_tx_gain(0, "BB"); + set_rx_ant(xcvr_antennas.at(0)); + set_tx_ant(xcvr_antennas.at(1)); + BOOST_FOREACH(const std::string &name, xcvr_tx_gain_ranges.keys()){ + set_tx_gain(xcvr_tx_gain_ranges[name].min, name); + } + BOOST_FOREACH(const std::string &name, xcvr_rx_gain_ranges.keys()){ + set_rx_gain(xcvr_rx_gain_ranges[name].min, name); + } } xcvr2450::~xcvr2450(void){ @@ -194,6 +197,11 @@ void xcvr2450::spi_reset(void){ //spi reset mode: global enable = off, tx and rx enable = on this->get_iface()->set_atr_reg(dboard_iface::UNIT_TX, dboard_iface::ATR_REG_IDLE, TX_ENB_TXIO); this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, RX_ENB_RXIO | POWER_DOWN_RXIO); + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + + //take it back out of spi reset mode and wait a bit + this->get_iface()->set_atr_reg(dboard_iface::UNIT_RX, dboard_iface::ATR_REG_IDLE, RX_DIS_RXIO | POWER_UP_RXIO); + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } void xcvr2450::update_atr(void){ -- cgit v1.2.3