diff options
author | Josh Blum <josh@joshknows.com> | 2010-04-29 06:29:54 +0000 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-04-29 06:29:54 +0000 |
commit | ef678a479cc4d4d60e16300e8654d19ebb6e43f0 (patch) | |
tree | da968df0580f1043b353d76ed550a56b35864974 /host/lib/ic_reg_maps/gen_ad9510_regs.py | |
parent | 4e97e9c4845814994e1e9d3deabb5abd4d177738 (diff) | |
parent | c7df3878779cf461cef01d910e6c52c7ac3e1105 (diff) | |
download | uhd-ef678a479cc4d4d60e16300e8654d19ebb6e43f0.tar.gz uhd-ef678a479cc4d4d60e16300e8654d19ebb6e43f0.tar.bz2 uhd-ef678a479cc4d4d60e16300e8654d19ebb6e43f0.zip |
Merge branch 'master' of git@ettus.sourcerepo.com:ettus/uhdpriv into usrp_e
Diffstat (limited to 'host/lib/ic_reg_maps/gen_ad9510_regs.py')
-rwxr-xr-x | host/lib/ic_reg_maps/gen_ad9510_regs.py | 104 |
1 files changed, 35 insertions, 69 deletions
diff --git a/host/lib/ic_reg_maps/gen_ad9510_regs.py b/host/lib/ic_reg_maps/gen_ad9510_regs.py index 2dc19c691..83236c921 100755 --- a/host/lib/ic_reg_maps/gen_ad9510_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9510_regs.py @@ -16,14 +16,11 @@ # 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="""\ ######################################################################## ## serial control port config ######################################################################## @@ -46,14 +43,14 @@ reset_all_counters 9[0] 0 ncounter_reset 9[1] 0 rcounter_reset 9[2] 0 cp_current_setting 9[4:6] 0 0_60ma, 1_2ma, 1_8ma, 2_4ma, 3_0ma, 3_6ma, 4_2ma, 4_8ma -pll_power_down A[0:1] 0 normal=0, async_pd=1, sync_pd=3 -prescaler_value A[2:4] 0 div1, div2, 2_3, 4_5, 8_9, 16_17, 32_33, div3 -b_counter_bypass A[6] 0 -ref_counter_msb B[0:5] 0 -ref_counter_lsb C[0:7] 0 -antibacklash_pw D[0:1] 0 1_3ns, 2_9ns, 6_0ns -dld_window D[5] 0 9_5ns, 3_5ns -lock_detect_disable D[6] 0 enb, dis +pll_power_down 0xA[0:1] 0 normal=0, async_pd=1, sync_pd=3 +prescaler_value 0xA[2:4] 0 div1, div2, 2_3, 4_5, 8_9, 16_17, 32_33, div3 +b_counter_bypass 0xA[6] 0 +ref_counter_msb 0xB[0:5] 0 +ref_counter_lsb 0xC[0:7] 0 +antibacklash_pw 0xD[0:1] 0 1_3ns, 2_9ns, 6_0ns +dld_window 0xD[5] 0 9_5ns, 3_5ns +lock_detect_disable 0xD[6] 0 enb, dis ######################################################################## ## fine delay adjust ######################################################################## @@ -103,71 +100,40 @@ soft_sync 58[2] 0 dist_power_down 58[3] 0 sync_power_down 58[4] 0 function_pin_select 58[5:6] 0 resetb, syncb, test, pdb -update_registers 5A[0] 0 +update_registers 0x5A[0] 0 """ ######################################################################## -# 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_AD9510_REGS_HPP -\#define INCLUDED_AD9510_REGS_HPP - -\#include <boost/cstdint.hpp> - -struct ad9510_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 +BODY_TMPL="""\ +boost::uint8_t get_reg(boost::uint16_t addr){ + boost::uint8_t reg = 0; + switch(addr){ + #for $addr in sorted(set(map(lambda r: r.get_addr(), $regs))) + 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 - } $reg.get_name(); - #else - boost::$reg.get_stdint_type() $reg.get_name(); - #end if -#end for - - ad9510_regs_t(void){ -#for $reg in $regs - $reg.get_name() = $reg.get_default(); -#end for - } - - boost::uint8_t get_reg(boost::uint16_t addr){ - boost::uint8_t reg = 0; - switch(addr){ - #for $addr in sorted(set(map(lambda r: r.get_addr(), $regs))) - 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; - #end for - } - return reg; - } - - boost::uint32_t get_write_reg(boost::uint16_t addr){ - return (boost::uint32_t(addr) << 8) | get_reg(addr); - } - - boost::uint32_t get_read_reg(boost::uint16_t addr){ - return (boost::uint32_t(addr) << 8) | (1 << 15); + break; + #end for } + return reg; +} -}; +boost::uint32_t get_write_reg(boost::uint16_t addr){ + return (boost::uint32_t(addr) << 8) | get_reg(addr); +} -\#endif /* INCLUDED_AD9510_REGS_HPP */ +boost::uint32_t get_read_reg(boost::uint16_t addr){ + return (boost::uint32_t(addr) << 8) | (1 << 23); +} """ 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='ad9510_regs', + regs_tmpl=REGS_TMPL, + body_tmpl=BODY_TMPL, + file=__file__, + ) |