diff options
author | Josh Blum <josh@joshknows.com> | 2010-05-04 17:58:46 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-05-04 17:58:46 -0700 |
commit | 3198ff91dcd3a06433654f9e50818f4566cbbe13 (patch) | |
tree | f48dbbc18c8eb3fe078285668a1096d3a6dfb017 /host/lib/ic_reg_maps | |
parent | 3f4c6b6121350b19a63c029efa5c1e8fe22a1210 (diff) | |
download | uhd-3198ff91dcd3a06433654f9e50818f4566cbbe13.tar.gz uhd-3198ff91dcd3a06433654f9e50818f4566cbbe13.tar.bz2 uhd-3198ff91dcd3a06433654f9e50818f4566cbbe13.zip |
code tweaks to get wbx compiling with master
Diffstat (limited to 'host/lib/ic_reg_maps')
-rwxr-xr-x | host/lib/ic_reg_maps/gen_adf4350_regs.py | 93 |
1 files changed, 30 insertions, 63 deletions
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 <http://www.gnu.org/licenses/>. # -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 <boost/cstdint.hpp> - -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__, + ) |