1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
/* -*- c++ -*- */
/*
* Copyright 2004,2006,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* GNU Radio 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, or (at your option)
* any later version.
*
* GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_USRP_SINK_BASE_H
#define INCLUDED_USRP_SINK_BASE_H
#include <usrp_base.h>
#include <stdexcept>
#include <usrp_tune_result.h>
#include <usrp_dbid.h>
class usrp_standard_tx;
/*!
* \brief abstract interface to Universal Software Radio Peripheral Tx path (Rev 1)
*/
class usrp_sink_base : public usrp_base {
private:
boost::shared_ptr<usrp_standard_tx> d_usrp;
int d_nunderruns;
protected:
usrp_sink_base (const std::string &name,
gr_io_signature_sptr input_signature,
int which_board,
unsigned int interp_rate,
int nchan,
int mux,
int fusb_block_size,
int fusb_nblocks,
const std::string fpga_filename,
const std::string firmware_filename
) throw (std::runtime_error);
/*!
* \brief convert between input item format and usrp native format
*
* \param input_items[in] stream(s) of input items
* \param input_index[in] starting index in input_items
* \param input_items_available[in] number of items available starting at item[index]
* \param input_items_consumed[out] number of input items consumed by copy
* \param usrp_buffer[out] destination buffer
* \param usrp_buffer_length[in] \p usrp_buffer length in bytes
* \param bytes_written[out] number of bytes written into \p usrp_buffer
*/
virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
int input_index,
int input_items_available,
int &input_items_consumed,
void *usrp_buffer,
int usrp_buffer_length,
int &bytes_written) = 0;
public:
~usrp_sink_base ();
int work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
/*!
* \brief Set interpolator rate. \p rate must be in [4, 1024] and a multiple of 4.
*
* The final complex sample rate across the USB is
* dac_freq () / interp_rate () * nchannels ()
*/
bool set_interp_rate (unsigned int rate);
bool set_nchannels (int nchan);
bool set_mux (int mux);
int determine_tx_mux_value(usrp_subdev_spec ss);
int determine_tx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b);
/*!
* \brief set the frequency of the digital up converter.
*
* \p channel must be 0. \p freq is the center frequency in Hz.
* It must be in the range [-44M, 44M]. The frequency specified is
* quantized. Use tx_freq to retrieve the actual value used.
*/
bool set_tx_freq (int channel, double freq);
long dac_rate() const { return converter_rate(); } // alias
long dac_freq() const { return converter_rate(); } // deprecated alias
unsigned int interp_rate () const;
int nchannels () const;
int mux () const;
double tx_freq (int channel) const;
int nunderruns () const { return d_nunderruns; }
bool has_rx_halfband();
bool has_tx_halfband();
int nddcs();
int nducs();
/*!
* \brief Called to enable drivers, etc for i/o devices.
*
* This allows a block to enable an associated driver to begin
* transfering data just before we start to execute the scheduler.
* The end result is that this reduces latency in the pipeline when
* dealing with audio devices, usrps, etc.
*/
bool start();
/*!
* \brief Called to disable drivers, etc for i/o devices.
*/
bool stop();
/*!
* \brief High-level "tune" method. Works for the single channel case.
*
* This method adjusts both the daughterboard LO and the DUC so that
* DC in the complex baseband samples ends up at RF target_freq.
*
* \param chan which DUC channel we're controlling (usually == which_side).
* \param db the daughterboard we're controlling.
* \param target_freq the RF frequency we want our baseband translated to.
* \param[out] tune_result details how the hardware was configured.
*
* \returns true iff everything was successful.
*/
bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result);
/*!
* \brief Select suitable Tx daughterboard
*/
usrp_subdev_spec pick_tx_subdevice();
};
#endif /* INCLUDED_USRP_SINK_BASE_H */
|