2 # Copyright 2003,2004 Free Software Foundation, Inc.
4 # This file is part of GNU Radio
6 # GNU Radio is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # GNU Radio is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Radio; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 51 Franklin Street,
19 # Boston, MA 02110-1301, USA.
22 from gnuradio import gr
24 class sdr_1000 (gr.sdr_1000_base):
25 "Control the DDS on the SDR-1000"
26 def __init__(self, pport = 0):
27 gr.sdr_1000_base.__init__(self, pport)
28 self.write_latch (3, 0x00, 0xC0) # Reset low, WRS/ low
29 self.write_reg (0x20, 0x40)
31 def write_reg(self, addr, data):
32 self.write_latch (3, addr & 0x3f, 0x3f)
33 self.write_latch (2, data, 0xff)
34 self.write_latch (3, 0x40, 0x40)
35 self.write_latch (3, 0x00, 0x40)
37 def set_freq(self, freq):
43 # print (('%d [%02x]') % (i, word))
44 self.write_reg (4+i, word)
46 def set_band (self, freq):
52 band = 3 # due to wiring mistake on board
54 band = 2 # due to wiring mistake on board
60 self.write_latch (1, 1 << band, 0x3f)
62 def set_bit (self, reg, bit, state):
64 if state: val = 1<<bit
65 self.write_latch (reg, val, 1<<bit)
67 def set_tx (self, on = 1):
68 self.set_bit(1, 6, on)
73 def set_gain (self, high):
74 self.set_bit(0, 7, high)
76 def set_mute (self, mute = 1):
77 self.set_bit(1, 7, mute)
79 def set_unmute (self):
82 def set_external_pin (self, pin, on = 1):
83 assert (pin < 8 and pin > 0), "Out of range 1..7"
84 self.set_bit(0, pin-1, on)