aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-10-05 11:13:25 -0700
committerNick Foster <nick@nerdnetworks.org>2010-10-05 11:14:45 -0700
commite4d088fa9169eef81473cb7d83bda7c82bc5d243 (patch)
tree0798f4c0863bcb27ff4164f9e2fcc2ccd7bf80d3 /host/lib/ic_reg_maps/gen_tuner_4937di5_regs.py
parent6dd502737bcf6e59933be01720672db9a496803b (diff)
parentbd3bd0dfbc1a87af5839c9b23450434cfb9c763c (diff)
downloaduhd-e4d088fa9169eef81473cb7d83bda7c82bc5d243.tar.gz
uhd-e4d088fa9169eef81473cb7d83bda7c82bc5d243.tar.bz2
uhd-e4d088fa9169eef81473cb7d83bda7c82bc5d243.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp2p
Conflicts: host/lib/ic_reg_maps/CMakeLists.txt host/lib/usrp/usrp2/io_impl.cpp
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__,
+ )