Statistics
| Branch: | Tag: | Revision:

root / usrp / host / lib / legacy / db_basic.cc @ 72c625f7

History | View | Annotate | Download (5.1 kB)

1
//
2
// Copyright 2008 Free Software Foundation, Inc.
3
// 
4
// This file is part of GNU Radio
5
// 
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 asversion 3, or (at your option)
9
// any later version.
10
// 
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.
15
// 
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.
20
21
#include <db_basic.h>
22
#include <db_base_impl.h>
23
24
25
db_basic_tx::db_basic_tx(boost::shared_ptr<usrp_basic> usrp, int which)
26
  : db_base(usrp, which)
27
{
28
  // Handler for Basic Tx daughterboards.
29
  // 
30
  // @param usrp: instance of usrp.source_c
31
  // @param which: which side: 0 or 1 corresponding to TX_A or TX_B respectively
32
33
  set_gain((gain_min() + gain_max()) / 2);         // initialize gain
34
}
35
36
db_basic_tx::~db_basic_tx()
37
{
38
}
39
40
double 
41
db_basic_tx::freq_min() 
42
{
43
  return -90e9;
44
}
45
46
double 
47
db_basic_tx::freq_max() 
48
{
49
  return 90e9;
50
}
51
52
struct freq_result_t 
53
db_basic_tx::set_freq(double target_freq)
54
{
55
  // Set the frequency.
56
  // 
57
  // @param freq:  target RF frequency in Hz
58
  // @type freq:   double
59
  // 
60
  // @returns (ok, actual_baseband_freq) where:
61
  //   ok is True or False and indicates success or failure,
62
  //   actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
63
  
64
  struct freq_result_t args = {false, 0};
65
  args.ok = true;
66
  args.baseband_freq = 0.0;
67
  return args;
68
}
69
70
float
71
db_basic_tx::gain_min()
72
{
73
  return usrp()->pga_min();
74
}
75
76
float
77
db_basic_tx::gain_max()
78
{
79
  return usrp()->pga_max();
80
}
81
82
float
83
db_basic_tx::gain_db_per_step()
84
{
85
  return usrp()->pga_db_per_step();
86
}
87
88
bool 
89
db_basic_tx::set_gain(float gain)
90
{
91
  // Set the gain.
92
  // 
93
  // @param gain:  gain in decibels
94
  // @returns True/False
95
96
  bool ok = usrp()->set_pga(d_which * 2 + 0, gain);
97
  ok = ok && usrp()->set_pga(d_which * 2 + 1, gain);
98
  return ok;
99
}
100
101
bool 
102
db_basic_tx::is_quadrature()
103
{
104
  // Return True if this board requires both I & Q analog channels.
105
  
106
  return true;
107
}
108
109
110
/******************************************************************************/
111
112
113
db_basic_rx::db_basic_rx(usrp_basic_sptr usrp, int which, int subdev)
114
  : db_base(usrp, which)
115
{
116
  // Handler for Basic Rx daughterboards.
117
  // 
118
  // @param usrp: instance of usrp.source_c
119
  // @param which: which side: 0 or 1 corresponding to TX_A or TX_B respectively
120
  // @param subdev: which analog i/o channel: 0 or 1
121
  // @type subdev: int
122
  
123
  d_subdev = subdev;
124
    
125
  bypass_adc_buffers(true);
126
127
  if(0) {       // Doing this would give us a different default than the historical values...
128
    set_gain(float(gain_min() + gain_max()) / 2.0);       // initialize gain
129
  }
130
}
131
132
db_basic_rx::~db_basic_rx()
133
{
134
}
135
136
double
137
db_basic_rx::freq_min() 
138
{
139
  return -90e9;
140
}
141
142
double
143
db_basic_rx::freq_max()
144
{
145
  return 90e9;
146
}
147
148
struct freq_result_t 
149
db_basic_rx::set_freq(double target_freq)
150
{
151
  // Set the frequency.
152
  // 
153
  // @param freq:  target RF frequency in Hz
154
  // @type freq:   double
155
  // 
156
  // @returns (ok, actual_baseband_freq) where:
157
  //   ok is True or False and indicates success or failure,
158
  //   actual_baseband_freq is the RF frequency that corresponds to DC in the IF.
159
  
160
  struct freq_result_t args = {true, 0.0};
161
  return args;
162
}
163
164
float
165
db_basic_rx::gain_min()
166
{
167
  return usrp()->pga_min();
168
}
169
170
float
171
db_basic_rx::gain_max()
172
{
173
  return usrp()->pga_max();
174
}
175
176
float
177
db_basic_rx::gain_db_per_step()
178
{
179
  return usrp()->pga_db_per_step();
180
}
181
182
bool 
183
db_basic_rx::set_gain(float gain)
184
{
185
  // Set the gain.
186
  // 
187
  // @param gain:  gain in decibels
188
  // @returns True/False
189
  
190
  return usrp()->set_pga(d_which * 2 + d_subdev, gain);
191
}
192
193
bool 
194
db_basic_rx::is_quadrature()
195
{
196
  // Return True if this board requires both I & Q analog channels.
197
198
  // This bit of info is useful when setting up the USRP Rx mux register.
199
  
200
  return false;
201
}
202
203
204
205
/******************************************************************************/
206
207
208
db_lf_tx::db_lf_tx(usrp_basic_sptr usrp, int which)
209
  : db_basic_tx(usrp, which)
210
{
211
  // Handler for Low Freq Tx daughterboards.
212
  //
213
  // @param usrp: instance of usrp.source_c
214
  // @param which: which side: 0 or 1 corresponding to RX_A or RX_B respectively
215
}
216
217
db_lf_tx::~db_lf_tx()
218
{
219
}
220
221
double 
222
db_lf_tx::freq_min() 
223
{
224
  return -32e6;
225
}
226
227
double 
228
db_lf_tx::freq_max()
229
{
230
  return 32e6;
231
}
232
233
/******************************************************************************/
234
235
236
db_lf_rx::db_lf_rx(usrp_basic_sptr usrp, int which, int subdev)
237
  : db_basic_rx(usrp, which, subdev)
238
{
239
  // Handler for Low Freq Rx daughterboards.
240
  //
241
  // @param usrp: instance of usrp.source_c
242
  // @param which: which side: 0 or 1 corresponding to RX_A or RX_B respectively
243
  // @param subdev: which analog i/o channel: 0 or 1
244
  // @type subdev: int
245
}
246
247
db_lf_rx::~db_lf_rx()
248
{
249
}
250
251
double
252
db_lf_rx::freq_min() 
253
{
254
  return 0.0;
255
}
256
257
double
258
db_lf_rx::freq_max() 
259
{
260
  return 32e6;
261
}
262
263