root / host / lib / usrp / usrp2 / usrp2_impl.hpp @ c6042a0b
History | View | Annotate | Download (7.25 KB)
| 1 |
//
|
|---|---|
| 2 |
// Copyright 2010 Ettus Research LLC
|
| 3 |
//
|
| 4 |
// This program is free software: you can redistribute it and/or modify
|
| 5 |
// it under the terms of the GNU General Public License as published by
|
| 6 |
// the Free Software Foundation, either version 3 of the License, or
|
| 7 |
// (at your option) any later version.
|
| 8 |
//
|
| 9 |
// This program is distributed in the hope that it will be useful,
|
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 12 |
// GNU General Public License for more details.
|
| 13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
| 16 |
//
|
| 17 |
|
| 18 |
#ifndef INCLUDED_USRP2_IMPL_HPP
|
| 19 |
#define INCLUDED_USRP2_IMPL_HPP
|
| 20 |
|
| 21 |
#include "usrp2_iface.hpp" |
| 22 |
#include "clock_ctrl.hpp" |
| 23 |
#include "codec_ctrl.hpp" |
| 24 |
#include "serdes_ctrl.hpp" |
| 25 |
#include <uhd/device.hpp> |
| 26 |
#include <uhd/utils/pimpl.hpp> |
| 27 |
#include <uhd/types/dict.hpp> |
| 28 |
#include <uhd/types/otw_type.hpp> |
| 29 |
#include <uhd/types/stream_cmd.hpp> |
| 30 |
#include <uhd/types/clock_config.hpp> |
| 31 |
#include <uhd/usrp/dboard_eeprom.hpp> |
| 32 |
#include <boost/shared_ptr.hpp> |
| 33 |
#include <boost/function.hpp> |
| 34 |
#include <uhd/transport/vrt_if_packet.hpp> |
| 35 |
#include <uhd/transport/udp_simple.hpp> //mtu |
| 36 |
#include <uhd/transport/zero_copy.hpp> |
| 37 |
#include <uhd/usrp/dboard_manager.hpp> |
| 38 |
#include <uhd/usrp/subdev_spec.hpp> |
| 39 |
|
| 40 |
/*!
|
| 41 |
* Make a usrp2 dboard interface.
|
| 42 |
* \param iface the usrp2 interface object
|
| 43 |
* \param clk_ctrl the clock control object
|
| 44 |
* \return a sptr to a new dboard interface
|
| 45 |
*/
|
| 46 |
uhd::usrp::dboard_iface::sptr make_usrp2_dboard_iface( |
| 47 |
usrp2_iface::sptr iface, |
| 48 |
usrp2_clock_ctrl::sptr clk_ctrl |
| 49 |
); |
| 50 |
|
| 51 |
/*!
|
| 52 |
* Simple wax obj proxy class:
|
| 53 |
* Provides a wax obj interface for a set and a get function.
|
| 54 |
* This allows us to create nested properties structures
|
| 55 |
* while maintaining flattened code within the implementation.
|
| 56 |
*/
|
| 57 |
class wax_obj_proxy : public wax::obj{ |
| 58 |
public:
|
| 59 |
typedef boost::function<void(const wax::obj &, wax::obj &)> get_t; |
| 60 |
typedef boost::function<void(const wax::obj &, const wax::obj &)> set_t; |
| 61 |
typedef boost::shared_ptr<wax_obj_proxy> sptr;
|
| 62 |
|
| 63 |
static sptr make(const get_t &get, const set_t &set){ |
| 64 |
return sptr(new wax_obj_proxy(get, set)); |
| 65 |
} |
| 66 |
|
| 67 |
private:
|
| 68 |
get_t _get; set_t _set; |
| 69 |
wax_obj_proxy(const get_t &get, const set_t &set): _get(get), _set(set){}; |
| 70 |
void get(const wax::obj &key, wax::obj &val){return _get(key, val);} |
| 71 |
void set(const wax::obj &key, const wax::obj &val){return _set(key, val);} |
| 72 |
}; |
| 73 |
|
| 74 |
/*!
|
| 75 |
* USRP2 mboard implementation guts:
|
| 76 |
* The implementation details are encapsulated here.
|
| 77 |
* Handles properties on the mboard, dboard, dsps...
|
| 78 |
*/
|
| 79 |
class usrp2_mboard_impl : public wax::obj{ |
| 80 |
public:
|
| 81 |
typedef boost::shared_ptr<usrp2_mboard_impl> sptr;
|
| 82 |
|
| 83 |
//structors
|
| 84 |
usrp2_mboard_impl( |
| 85 |
size_t index, |
| 86 |
uhd::transport::udp_simple::sptr, |
| 87 |
size_t recv_samps_per_packet, |
| 88 |
size_t send_bytes_per_packet, |
| 89 |
const uhd::device_addr_t &flow_control_hints
|
| 90 |
); |
| 91 |
~usrp2_mboard_impl(void);
|
| 92 |
|
| 93 |
inline double get_master_clock_freq(void){ |
| 94 |
return _clock_ctrl->get_master_clock_rate();
|
| 95 |
} |
| 96 |
|
| 97 |
private:
|
| 98 |
size_t _index; |
| 99 |
int _rev_hi, _rev_lo;
|
| 100 |
const size_t _recv_samps_per_packet;
|
| 101 |
|
| 102 |
//properties for this mboard
|
| 103 |
void get(const wax::obj &, wax::obj &); |
| 104 |
void set(const wax::obj &, const wax::obj &); |
| 105 |
uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec; |
| 106 |
|
| 107 |
//interfaces
|
| 108 |
usrp2_iface::sptr _iface; |
| 109 |
usrp2_clock_ctrl::sptr _clock_ctrl; |
| 110 |
usrp2_codec_ctrl::sptr _codec_ctrl; |
| 111 |
usrp2_serdes_ctrl::sptr _serdes_ctrl; |
| 112 |
|
| 113 |
//rx and tx dboard methods and objects
|
| 114 |
uhd::usrp::dboard_manager::sptr _dboard_manager; |
| 115 |
uhd::usrp::dboard_iface::sptr _dboard_iface; |
| 116 |
void dboard_init(void); |
| 117 |
|
| 118 |
//methods and shadows for clock configuration
|
| 119 |
uhd::clock_config_t _clock_config; |
| 120 |
void init_clock_config(void); |
| 121 |
void update_clock_config(void); |
| 122 |
void set_time_spec(const uhd::time_spec_t &time_spec, bool now); |
| 123 |
|
| 124 |
//properties interface for the codec
|
| 125 |
void codec_init(void); |
| 126 |
void rx_codec_get(const wax::obj &, wax::obj &); |
| 127 |
void rx_codec_set(const wax::obj &, const wax::obj &); |
| 128 |
void tx_codec_get(const wax::obj &, wax::obj &); |
| 129 |
void tx_codec_set(const wax::obj &, const wax::obj &); |
| 130 |
wax_obj_proxy::sptr _rx_codec_proxy; |
| 131 |
wax_obj_proxy::sptr _tx_codec_proxy; |
| 132 |
|
| 133 |
//properties interface for rx dboard
|
| 134 |
void rx_dboard_get(const wax::obj &, wax::obj &); |
| 135 |
void rx_dboard_set(const wax::obj &, const wax::obj &); |
| 136 |
wax_obj_proxy::sptr _rx_dboard_proxy; |
| 137 |
uhd::usrp::dboard_eeprom_t _rx_db_eeprom; |
| 138 |
|
| 139 |
//properties interface for tx dboard
|
| 140 |
void tx_dboard_get(const wax::obj &, wax::obj &); |
| 141 |
void tx_dboard_set(const wax::obj &, const wax::obj &); |
| 142 |
wax_obj_proxy::sptr _tx_dboard_proxy; |
| 143 |
uhd::usrp::dboard_eeprom_t _tx_db_eeprom; |
| 144 |
|
| 145 |
//methods and shadows for the ddc dsp
|
| 146 |
std::vector<size_t> _allowed_decim_and_interp_rates; |
| 147 |
size_t _ddc_decim; |
| 148 |
double _ddc_freq;
|
| 149 |
void init_ddc_config(void); |
| 150 |
void issue_ddc_stream_cmd(const uhd::stream_cmd_t &stream_cmd); |
| 151 |
|
| 152 |
//methods and shadows for the duc dsp
|
| 153 |
size_t _duc_interp; |
| 154 |
double _duc_freq;
|
| 155 |
void init_duc_config(void); |
| 156 |
|
| 157 |
//properties interface for ddc
|
| 158 |
void ddc_get(const wax::obj &, wax::obj &); |
| 159 |
void ddc_set(const wax::obj &, const wax::obj &); |
| 160 |
wax_obj_proxy::sptr _rx_dsp_proxy; |
| 161 |
|
| 162 |
//properties interface for duc
|
| 163 |
void duc_get(const wax::obj &, wax::obj &); |
| 164 |
void duc_set(const wax::obj &, const wax::obj &); |
| 165 |
wax_obj_proxy::sptr _tx_dsp_proxy; |
| 166 |
|
| 167 |
}; |
| 168 |
|
| 169 |
/*!
|
| 170 |
* USRP2 implementation guts:
|
| 171 |
* The implementation details are encapsulated here.
|
| 172 |
* Handles device properties and streaming...
|
| 173 |
*/
|
| 174 |
class usrp2_impl : public uhd::device{ |
| 175 |
public:
|
| 176 |
static const size_t sram_bytes = size_t(1 << 20); |
| 177 |
|
| 178 |
/*!
|
| 179 |
* Create a new usrp2 impl base.
|
| 180 |
* \param ctrl_transports the udp transports for control
|
| 181 |
* \param data_transports the udp transports for data
|
| 182 |
* \param flow_control_hints optional flow control params
|
| 183 |
*/
|
| 184 |
usrp2_impl( |
| 185 |
std::vector<uhd::transport::udp_simple::sptr> ctrl_transports, |
| 186 |
std::vector<uhd::transport::zero_copy_if::sptr> data_transports, |
| 187 |
const uhd::device_addr_t &flow_control_hints
|
| 188 |
); |
| 189 |
|
| 190 |
~usrp2_impl(void);
|
| 191 |
|
| 192 |
//the io interface
|
| 193 |
size_t send( |
| 194 |
const std::vector<const void *> &, size_t, |
| 195 |
const uhd::tx_metadata_t &, const uhd::io_type_t &, |
| 196 |
uhd::device::send_mode_t, double
|
| 197 |
); |
| 198 |
size_t recv( |
| 199 |
const std::vector<void *> &, size_t, |
| 200 |
uhd::rx_metadata_t &, const uhd::io_type_t &,
|
| 201 |
uhd::device::recv_mode_t, double
|
| 202 |
); |
| 203 |
size_t get_max_send_samps_per_packet(void) const; |
| 204 |
size_t get_max_recv_samps_per_packet(void) const; |
| 205 |
bool recv_async_msg(uhd::async_metadata_t &, double); |
| 206 |
|
| 207 |
private:
|
| 208 |
//device properties interface
|
| 209 |
void get(const wax::obj &, wax::obj &); |
| 210 |
void set(const wax::obj &, const wax::obj &); |
| 211 |
|
| 212 |
//pointers to mboards on this device (think mimo setup)
|
| 213 |
std::vector<usrp2_mboard_impl::sptr> _mboards; |
| 214 |
uhd::dict<std::string, usrp2_mboard_impl::sptr> _mboard_dict;
|
| 215 |
|
| 216 |
//io impl methods and members
|
| 217 |
std::vector<uhd::transport::zero_copy_if::sptr> _data_transports; |
| 218 |
uhd::otw_type_t _rx_otw_type, _tx_otw_type; |
| 219 |
UHD_PIMPL_DECL(io_impl) _io_impl; |
| 220 |
void io_init(void); |
| 221 |
}; |
| 222 |
|
| 223 |
#endif /* INCLUDED_USRP2_IMPL_HPP */ |