root / gr-usrp / src / usrp_sink_base.h @ c276a4ff
History | View | Annotate | Download (4.8 kB)
| 1 | |
|---|---|
| 2 | /* -*- c++ -*- */
|
| 3 | /*
|
| 4 | * Copyright 2004,2006,2008,2009 Free Software Foundation, Inc. |
| 5 | * |
| 6 | * This file is part of GNU Radio |
| 7 | * |
| 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) |
| 11 | * any later version. |
| 12 | * |
| 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. |
| 17 | * |
| 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. |
| 22 | */ |
| 23 | |
| 24 | #ifndef INCLUDED_USRP_SINK_BASE_H
|
| 25 | #define INCLUDED_USRP_SINK_BASE_H
|
| 26 | |
| 27 | #include <usrp_base.h> |
| 28 | #include <stdexcept> |
| 29 | #include <usrp/usrp_tune_result.h> |
| 30 | #include <usrp/usrp_dbid.h> |
| 31 | |
| 32 | class usrp_standard_tx; |
| 33 | |
| 34 | /*!
|
| 35 | * \brief abstract interface to Universal Software Radio Peripheral Tx path (Rev 1) |
| 36 | */ |
| 37 | class usrp_sink_base : public usrp_base {
|
| 38 | private:
|
| 39 | boost::shared_ptr<usrp_standard_tx> d_usrp; |
| 40 | int d_nunderruns;
|
| 41 | |
| 42 | protected:
|
| 43 | usrp_sink_base (const std::string &name,
|
| 44 | gr_io_signature_sptr input_signature, |
| 45 | int which_board,
|
| 46 | unsigned int interp_rate, |
| 47 | int nchan,
|
| 48 | int mux,
|
| 49 | int fusb_block_size,
|
| 50 | int fusb_nblocks,
|
| 51 | const std::string fpga_filename,
|
| 52 | const std::string firmware_filename
|
| 53 | ) throw (std::runtime_error); |
| 54 | |
| 55 | /*!
|
| 56 | * \brief convert between input item format and usrp native format |
| 57 | * |
| 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 |
| 65 | */ |
| 66 | virtual void copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
|
| 67 | int input_index,
|
| 68 | int input_items_available,
|
| 69 | int &input_items_consumed,
|
| 70 | void *usrp_buffer,
|
| 71 | int usrp_buffer_length,
|
| 72 | int &bytes_written) = 0; |
| 73 | |
| 74 | public:
|
| 75 | ~usrp_sink_base (); |
| 76 | |
| 77 | int work (int noutput_items, |
| 78 | gr_vector_const_void_star &input_items, |
| 79 | gr_vector_void_star &output_items); |
| 80 | |
| 81 | /*!
|
| 82 | * \brief Set interpolator rate. \p rate must be in [4, 1024] and a multiple of 4. |
| 83 | * |
| 84 | * The final complex sample rate across the USB is |
| 85 | * dac_freq () / interp_rate () * nchannels () |
| 86 | */ |
| 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);
|
| 92 | |
| 93 | /*!
|
| 94 | * \brief set the frequency of the digital up converter. |
| 95 | * |
| 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. |
| 99 | */ |
| 100 | bool set_tx_freq (int channel, double freq); |
| 101 | |
| 102 | long dac_rate() const { return converter_rate(); } // alias |
| 103 | long dac_freq() const { return converter_rate(); } // deprecated alias |
| 104 | |
| 105 | unsigned int interp_rate () const; |
| 106 | int nchannels () const; |
| 107 | int mux () const; |
| 108 | double tx_freq (int channel) const; |
| 109 | int nunderruns () const { return d_nunderruns; } |
| 110 | |
| 111 | bool has_rx_halfband();
|
| 112 | bool has_tx_halfband();
|
| 113 | int nddcs();
|
| 114 | int nducs();
|
| 115 | |
| 116 | /*!
|
| 117 | * \brief Called to enable drivers, etc for i/o devices. |
| 118 | * |
| 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. |
| 123 | */ |
| 124 | bool start();
|
| 125 | |
| 126 | /*!
|
| 127 | * \brief Called to disable drivers, etc for i/o devices. |
| 128 | */ |
| 129 | bool stop();
|
| 130 | |
| 131 | /*!
|
| 132 | * \brief High-level "tune" method. Works for the single channel case. |
| 133 | * |
| 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. |
| 136 | * |
| 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. |
| 141 | * |
| 142 | * \returns true iff everything was successful. |
| 143 | */ |
| 144 | bool tune(int chan, db_base_sptr db, double target_freq, usrp_tune_result *result); |
| 145 | |
| 146 | /*!
|
| 147 | * \brief Select suitable Tx daughterboard |
| 148 | */ |
| 149 | usrp_subdev_spec pick_tx_subdevice(); |
| 150 | }; |
| 151 | |
| 152 | #endif /* INCLUDED_USRP_SINK_BASE_H */ |