4 * Copyright 2004,2006,2008,2009 Free Software Foundation, Inc.
6 * This file is part of GNU Radio
8 * GNU Radio is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3, or (at your option)
13 * GNU Radio is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Radio; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street,
21 * Boston, MA 02110-1301, USA.
24 #ifndef INCLUDED_USRP_SINK_BASE_H
25 #define INCLUDED_USRP_SINK_BASE_H
27 #include <usrp_base.h>
29 #include <usrp/usrp_tune_result.h>
30 #include <usrp/usrp_dbid.h>
32 class usrp_standard_tx;
35 * \brief abstract interface to Universal Software Radio Peripheral Tx path (Rev 1)
37 class usrp_sink_base : public usrp_base {
39 boost::shared_ptr<usrp_standard_tx> d_usrp;
43 usrp_sink_base (const std::string &name,
44 gr_io_signature_sptr input_signature,
46 unsigned int interp_rate,
51 const std::string fpga_filename,
52 const std::string firmware_filename
53 ) throw (std::runtime_error);
56 * \brief convert between input item format and usrp native format
58 * \param[in] input_items stream(s) of input items
59 * \param[in] input_index starting index in input_items
60 * \param[in] input_items_available number of items available starting at item[index]
61 * \param[out] input_items_consumed number of input items consumed by copy
62 * \param[out] usrp_buffer destination buffer
63 * \param[in] usrp_buffer_length \p usrp_buffer length in bytes
64 * \param[out] bytes_written number of bytes written into \p usrp_buffer
66 virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
68 int input_items_available,
69 int &input_items_consumed,
71 int usrp_buffer_length,
72 int &bytes_written) = 0;
77 int work (int noutput_items,
78 gr_vector_const_void_star &input_items,
79 gr_vector_void_star &output_items);
82 * \brief Set interpolator rate. \p rate must be in [4, 1024] and a multiple of 4.
84 * The final complex sample rate across the USB is
85 * dac_freq () / interp_rate () * nchannels ()
87 bool set_interp_rate (unsigned int rate);
88 bool set_nchannels (int nchan);
89 bool set_mux (int mux);
90 int determine_tx_mux_value(usrp_subdev_spec ss);
91 int determine_tx_mux_value(usrp_subdev_spec ss_a, usrp_subdev_spec ss_b);
94 * \brief set the frequency of the digital up converter.
96 * \p channel must be 0. \p freq is the center frequency in Hz.
97 * It must be in the range [-44M, 44M]. The frequency specified is
98 * quantized. Use tx_freq to retrieve the actual value used.
100 bool set_tx_freq (int channel, double freq);
102 long dac_rate() const { return converter_rate(); } // alias
103 long dac_freq() const { return converter_rate(); } // deprecated alias
105 unsigned int interp_rate () const;
106 int nchannels () const;
108 double tx_freq (int channel) const;
109 int nunderruns () const { return d_nunderruns; }
111 bool has_rx_halfband();
112 bool has_tx_halfband();
117 * \brief Called to enable drivers, etc for i/o devices.
119 * This allows a block to enable an associated driver to begin
120 * transfering data just before we start to execute the scheduler.
121 * The end result is that this reduces latency in the pipeline when
122 * dealing with audio devices, usrps, etc.
127 * \brief Called to disable drivers, etc for i/o devices.
132 * \brief High-level "tune" method. Works for the single channel case.
134 * This method adjusts both the daughterboard LO and the DUC so that
135 * DC in the complex baseband samples ends up at RF target_freq.
137 * \param chan which DUC channel we're controlling (usually == which_side).
138 * \param db the daughterboard we're controlling.
139 * \param target_freq the RF frequency we want our baseband translated to.
140 * \param[out] result details how the hardware was configured.
142 * \returns true iff everything was successful.
144 bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result);
147 * \brief Select suitable Tx daughterboard
149 usrp_subdev_spec pick_tx_subdevice();
152 #endif /* INCLUDED_USRP_SINK_BASE_H */