root / host / lib / ic_reg_maps / gen_ad5623_regs.py @ f73a3688
History | View | Annotate | Download (1.8 kB)
| 1 |
#!/usr/bin/env python
|
|---|---|
| 2 |
#
|
| 3 |
# Copyright 2010 Ettus Research LLC
|
| 4 |
#
|
| 5 |
# This program is free software: you can redistribute it and/or modify
|
| 6 |
# it under the terms of the GNU General Public License as published by
|
| 7 |
# the Free Software Foundation, either version 3 of the License, or
|
| 8 |
# (at your option) any later version.
|
| 9 |
#
|
| 10 |
# This program is distributed in the hope that it will be useful,
|
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 |
# GNU General Public License for more details.
|
| 14 |
#
|
| 15 |
# You should have received a copy of the GNU General Public License
|
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 17 |
#
|
| 18 |
|
| 19 |
########################################################################
|
| 20 |
# Template for raw text data describing registers
|
| 21 |
# name addr[bit range inclusive] default optional enums
|
| 22 |
########################################################################
|
| 23 |
REGS_TMPL="""\
|
| 24 |
data 0[4:15] 0
|
| 25 |
addr 0[16:18] 0 DAC_A=0, DAC_B=1, ALL=7
|
| 26 |
cmd 0[19:21] 0 wr_input_n, up_dac_n, wr_input_n_up_all, wr_up_dac_chan_n, power_down, reset, load_ldac
|
| 27 |
"""
|
| 28 |
|
| 29 |
########################################################################
|
| 30 |
# Template for methods in the body of the struct
|
| 31 |
########################################################################
|
| 32 |
BODY_TMPL="""\
|
| 33 |
boost::uint32_t get_reg(void){
|
| 34 |
boost::uint32_t reg = 0;
|
| 35 |
#for $reg in filter(lambda r: r.get_addr() == 0, $regs)
|
| 36 |
reg |= (boost::uint32_t($reg.get_name()) & $reg.get_mask()) << $reg.get_shift();
|
| 37 |
#end for
|
| 38 |
return reg;
|
| 39 |
}
|
| 40 |
"""
|
| 41 |
|
| 42 |
if __name__ == '__main__': |
| 43 |
import common; common.generate( |
| 44 |
name='ad5623_regs',
|
| 45 |
regs_tmpl=REGS_TMPL, |
| 46 |
body_tmpl=BODY_TMPL, |
| 47 |
file=__file__, |
| 48 |
) |