aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2010-11-04 08:02:10 -0400
committerPhilip Balister <philip@opensdr.com>2010-11-04 08:02:10 -0400
commit40080e474268291c915f8d68e99506e8ae2a3f75 (patch)
tree99581ec02c77b08a11f38af901dc9db35adcbe3a /host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py
parent7f8d7b0e2fef1b2d5bb9c8047380dcf958c0c49c (diff)
parent16351339eb6962288844cefefbdb3f6eece8aca1 (diff)
downloaduhd-40080e474268291c915f8d68e99506e8ae2a3f75.tar.gz
uhd-40080e474268291c915f8d68e99506e8ae2a3f75.tar.bz2
uhd-40080e474268291c915f8d68e99506e8ae2a3f75.zip
Merge remote branch 'origin/usrp_e_next' into usrp_e_next
Diffstat (limited to 'host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py')
-rw-r--r--host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py b/host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py
new file mode 100644
index 000000000..73f7aa3db
--- /dev/null
+++ b/host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+#
+# 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 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 this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+########################################################################
+# Template for raw text data describing registers
+# name addr[bit range inclusive] default optional enums
+########################################################################
+REGS_TMPL="""\
+########################################################################
+## Note: offsets given from perspective of data bits (excludes address)
+########################################################################
+## Divider byte 1
+########################################################################
+db1 0[0:6] 0x00
+########################################################################
+## Divider byte 2
+########################################################################
+db2 1[0:7] 0x00
+########################################################################
+## Control byte 1
+########################################################################
+cb7 2[7] 0x01
+cp 2[6] 0x00 low,high
+os 2[0] 0x00 on,off
+rs 2[1:2] 0x00 d512=3,d640=0,d1024=1
+test 2[3:5] 0x01 normal=0x01,cpoff=0x02,cpsink=0x06,cpsrc=0x07,cptest1=0x04,cptest2=0x05
+########################################################################
+## Control byte 2
+########################################################################
+bandsel 3[4:7] 0x03 uhf=0x03,vhfhi=0x09,vhflo=0x0a
+power 3[3] 0x00 on,off
+"""
+
+########################################################################
+# Template for methods in the body of the struct
+########################################################################
+BODY_TMPL="""\
+boost::uint8_t get_reg(boost::uint8_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::uint8_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift();
+ #end for
+ break;
+ #end for
+ }
+ return boost::uint8_t(reg);
+}
+
+"""
+
+if __name__ == '__main__':
+ import common; common.generate(
+ name='tuner_4937di5_regs',
+ regs_tmpl=REGS_TMPL,
+ body_tmpl=BODY_TMPL,
+ file=__file__,
+ )