From 3198ff91dcd3a06433654f9e50818f4566cbbe13 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 4 May 2010 17:58:46 -0700 Subject: code tweaks to get wbx compiling with master --- host/lib/ic_reg_maps/gen_adf4350_regs.py | 93 +++++++++++--------------------- host/lib/usrp/dboard/db_wbx.cpp | 10 ++-- 2 files changed, 35 insertions(+), 68 deletions(-) (limited to 'host/lib') diff --git a/host/lib/ic_reg_maps/gen_adf4350_regs.py b/host/lib/ic_reg_maps/gen_adf4350_regs.py index 8cc6fd16c..e97772843 100755 --- a/host/lib/ic_reg_maps/gen_adf4350_regs.py +++ b/host/lib/ic_reg_maps/gen_adf4350_regs.py @@ -16,24 +16,21 @@ # along with this program. If not, see . # -import sys -from common import * - ######################################################################## # Template for raw text data describing registers # name addr[bit range inclusive] default optional enums ######################################################################## -REGS_DATA_TMPL="""\ +REGS_TMPL="""\ ######################################################################## ## address 0 ######################################################################## frac_12_bit 0[3:14] 0 -int_16_bit 0[15:30] 23 +int_16_bit 0[15:30] 0x23 ##reserved 0[31] 0 ######################################################################## ## address 1 ######################################################################## -mod_12_bit 1[3:14] fff +mod_12_bit 1[3:14] 0xfff phase_12_bit 1[15:26] 0 prescaler 1[27] 0 4_5, 8_9 ##reserved 1[28:31] 0 @@ -88,67 +85,37 @@ ld_pin_mode 5[22:23] 1 low0, dld, low, high """ ######################################################################## -# Header and Source templates below +# Template for methods in the body of the struct ######################################################################## -HEADER_TEXT=""" -#import time - -/*********************************************************************** - * This file was generated by $file on $time.strftime("%c") - **********************************************************************/ - -\#ifndef INCLUDED_ADF4350_REGS_HPP -\#define INCLUDED_ADF4350_REGS_HPP - -\#include - -struct adf4350_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 - - adf4350_regs_t(void){ -#for $reg in $regs - $reg.get_name() = $reg.get_default(); -#end for - } - - enum addr_t{ - ADDR_R0 = 0, - ADDR_R1 = 1, - ADDR_R2 = 2, - ADDR_R3 = 3, - ADDR_R4 = 4, - ADDR_R5 = 5 - }; +BODY_TMPL="""\ +enum addr_t{ + ADDR_R0 = 0, + ADDR_R1 = 1, + ADDR_R2 = 2, + ADDR_R3 = 3, + ADDR_R4 = 4, + ADDR_R5 = 5 +}; - boost::uint32_t get_reg(boost::uint8_t addr){ - boost::uint32_t reg = addr & 0x7; - switch(addr){ - #for $addr in range(5+1) - case $addr: - #for $reg in filter(lambda r: r.get_addr() == addr, $regs) - reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); - #end for - break; +boost::uint32_t get_reg(boost::uint8_t addr){ + boost::uint32_t reg = addr & 0x7; + switch(addr){ + #for $addr in range(5+1) + case $addr: + #for $reg in filter(lambda r: r.get_addr() == addr, $regs) + reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift(); #end for - } - return reg; + break; + #end for } -}; - -\#endif /* INCLUDED_ADF4350_REGS_HPP */ + return reg; +} """ 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__)) + import common; common.generate( + name='adf4350_regs', + regs_tmpl=REGS_TMPL, + body_tmpl=BODY_TMPL, + file=__file__, + ) diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp index b4aaf587c..2a8a3a9f2 100644 --- a/host/lib/usrp/dboard/db_wbx.cpp +++ b/host/lib/usrp/dboard/db_wbx.cpp @@ -92,7 +92,7 @@ static const float _max_tx_pga0_gain = 25; class wbx_xcvr : public xcvr_dboard_base{ public: wbx_xcvr( - ctor_args_t const& args, + ctor_args_t args, const freq_range_t &freq_range ); ~wbx_xcvr(void); @@ -142,7 +142,7 @@ private: /*********************************************************************** * Register the WBX dboard (min freq, max freq, rx div2, tx div2) **********************************************************************/ -static dboard_base::sptr make_wbx(dboard_base::ctor_args_t const& args){ +static dboard_base::sptr make_wbx(dboard_base::ctor_args_t args){ return dboard_base::sptr(new wbx_xcvr(args, freq_range_t(50e6, 2220e6))); } @@ -155,7 +155,7 @@ UHD_STATIC_BLOCK(reg_wbx_dboards){ * Structors **********************************************************************/ wbx_xcvr::wbx_xcvr( - ctor_args_t const& args, + ctor_args_t args, const freq_range_t &freq_range ) : xcvr_dboard_base(args){ _freq_range = freq_range; @@ -429,7 +429,7 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ case SUBDEV_PROP_NAME: - val = dboard_id::to_string(get_rx_id()); + val = get_rx_id().to_pp_string(); return; case SUBDEV_PROP_OTHERS: @@ -526,7 +526,7 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ //handle the get request conditioned on the key switch(key.as()){ case SUBDEV_PROP_NAME: - val = dboard_id::to_string(get_tx_id()); + val = get_tx_id().to_pp_string(); return; case SUBDEV_PROP_OTHERS: -- cgit v1.2.3