root / host / lib / usrp / usrp1 / usrp1_impl.hpp @ 9cb9e7d5
History | View | Annotate | Download (6 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 |
#include "usrp1_iface.hpp" |
| 19 |
#include "usrp1_ctrl.hpp" |
| 20 |
#include "clock_ctrl.hpp" |
| 21 |
#include "codec_ctrl.hpp" |
| 22 |
#include <uhd/device.hpp> |
| 23 |
#include <uhd/utils/pimpl.hpp> |
| 24 |
#include <uhd/types/otw_type.hpp> |
| 25 |
#include <uhd/types/clock_config.hpp> |
| 26 |
#include <uhd/types/stream_cmd.hpp> |
| 27 |
#include <uhd/usrp/dboard_eeprom.hpp> |
| 28 |
#include <uhd/usrp/dboard_manager.hpp> |
| 29 |
#include <uhd/transport/usb_zero_copy.hpp> |
| 30 |
|
| 31 |
#ifndef INCLUDED_USRP1_IMPL_HPP
|
| 32 |
#define INCLUDED_USRP1_IMPL_HPP
|
| 33 |
|
| 34 |
static const double MASTER_CLOCK_RATE = 64e6; //TODO get from clock control |
| 35 |
|
| 36 |
/*!
|
| 37 |
* Make a usrp1 dboard interface.
|
| 38 |
* \param iface the usrp1 interface object
|
| 39 |
* \param clock the clock control interface
|
| 40 |
* \param codec the codec control interface
|
| 41 |
* \return a sptr to a new dboard interface
|
| 42 |
*/
|
| 43 |
uhd::usrp::dboard_iface::sptr make_usrp1_dboard_iface(usrp1_iface::sptr iface, |
| 44 |
usrp1_clock_ctrl::sptr clock, |
| 45 |
usrp1_codec_ctrl::sptr codec); |
| 46 |
|
| 47 |
/*!
|
| 48 |
* Simple wax obj proxy class:
|
| 49 |
* Provides a wax obj interface for a set and a get function.
|
| 50 |
* This allows us to create nested properties structures
|
| 51 |
* while maintaining flattened code within the implementation.
|
| 52 |
*/
|
| 53 |
class wax_obj_proxy : public wax::obj { |
| 54 |
public:
|
| 55 |
typedef boost::function<void(const wax::obj &, wax::obj &)> get_t; |
| 56 |
typedef boost::function<void(const wax::obj &, const wax::obj &)> set_t; |
| 57 |
typedef boost::shared_ptr<wax_obj_proxy> sptr;
|
| 58 |
|
| 59 |
static sptr make(const get_t &get, const set_t &set) |
| 60 |
{
|
| 61 |
return sptr(new wax_obj_proxy(get, set)); |
| 62 |
} |
| 63 |
|
| 64 |
private:
|
| 65 |
get_t _get; set_t _set; |
| 66 |
wax_obj_proxy(const get_t &get, const set_t &set): _get(get), _set(set) {}; |
| 67 |
void get(const wax::obj &key, wax::obj &val) {return _get(key, val);} |
| 68 |
void set(const wax::obj &key, const wax::obj &val) {return _set(key, val);} |
| 69 |
}; |
| 70 |
|
| 71 |
/*!
|
| 72 |
* USRP1 implementation guts:
|
| 73 |
* The implementation details are encapsulated here.
|
| 74 |
* Handles properties on the mboard, dboard, dsps...
|
| 75 |
*/
|
| 76 |
class usrp1_impl : public uhd::device { |
| 77 |
public:
|
| 78 |
//structors
|
| 79 |
usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport, |
| 80 |
usrp_ctrl::sptr ctrl_transport); |
| 81 |
|
| 82 |
~usrp1_impl(void);
|
| 83 |
|
| 84 |
//the io interface
|
| 85 |
size_t send(const std::vector<const void *> &, |
| 86 |
size_t, |
| 87 |
const uhd::tx_metadata_t &,
|
| 88 |
const uhd::io_type_t &,
|
| 89 |
send_mode_t); |
| 90 |
|
| 91 |
size_t recv(const std::vector<void *> &, |
| 92 |
size_t, uhd::rx_metadata_t &, |
| 93 |
const uhd::io_type_t &,
|
| 94 |
recv_mode_t, |
| 95 |
size_t timeout); |
| 96 |
|
| 97 |
size_t get_max_send_samps_per_packet(void) const { return 0; } |
| 98 |
size_t get_max_recv_samps_per_packet(void) const { return 0; } |
| 99 |
|
| 100 |
bool recv_async_msg(uhd::async_metadata_t &, size_t) { return true; } |
| 101 |
|
| 102 |
private:
|
| 103 |
//interface to ioctls and file descriptor
|
| 104 |
usrp1_iface::sptr _iface; |
| 105 |
|
| 106 |
//handle io stuff
|
| 107 |
UHD_PIMPL_DECL(io_impl) _io_impl; |
| 108 |
void io_init(void); |
| 109 |
void issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd); |
| 110 |
void handle_overrun(size_t);
|
| 111 |
|
| 112 |
//otw types
|
| 113 |
uhd::otw_type_t _rx_otw_type; |
| 114 |
uhd::otw_type_t _tx_otw_type; |
| 115 |
|
| 116 |
//configuration shadows
|
| 117 |
uhd::clock_config_t _clock_config; |
| 118 |
|
| 119 |
//clock control
|
| 120 |
usrp1_clock_ctrl::sptr _clock_ctrl; |
| 121 |
|
| 122 |
//ad9862 codec control interface
|
| 123 |
usrp1_codec_ctrl::sptr _codec_ctrl; |
| 124 |
|
| 125 |
//codec properties interfaces
|
| 126 |
void codec_init(void); |
| 127 |
void rx_codec_get(const wax::obj &, wax::obj &); |
| 128 |
void rx_codec_set(const wax::obj &, const wax::obj &); |
| 129 |
void tx_codec_get(const wax::obj &, wax::obj &); |
| 130 |
void tx_codec_set(const wax::obj &, const wax::obj &); |
| 131 |
wax_obj_proxy::sptr _rx_codec_proxy; |
| 132 |
wax_obj_proxy::sptr _tx_codec_proxy; |
| 133 |
|
| 134 |
//device functions and settings
|
| 135 |
void get(const wax::obj &, wax::obj &); |
| 136 |
void set(const wax::obj &, const wax::obj &); |
| 137 |
|
| 138 |
//mboard functions and settings
|
| 139 |
void mboard_init(void); |
| 140 |
void mboard_get(const wax::obj &, wax::obj &); |
| 141 |
void mboard_set(const wax::obj &, const wax::obj &); |
| 142 |
wax_obj_proxy::sptr _mboard_proxy; |
| 143 |
|
| 144 |
//xx dboard functions and settings
|
| 145 |
void dboard_init(void); |
| 146 |
uhd::usrp::dboard_manager::sptr _dboard_manager; |
| 147 |
uhd::usrp::dboard_iface::sptr _dboard_iface; |
| 148 |
|
| 149 |
//rx dboard functions and settings
|
| 150 |
uhd::usrp::dboard_eeprom_t _rx_db_eeprom; |
| 151 |
void rx_dboard_get(const wax::obj &, wax::obj &); |
| 152 |
void rx_dboard_set(const wax::obj &, const wax::obj &); |
| 153 |
uhd::prop_names_t _rx_subdevs_in_use; |
| 154 |
wax_obj_proxy::sptr _rx_dboard_proxy; |
| 155 |
|
| 156 |
//tx dboard functions and settings
|
| 157 |
uhd::usrp::dboard_eeprom_t _tx_db_eeprom; |
| 158 |
void tx_dboard_get(const wax::obj &, wax::obj &); |
| 159 |
void tx_dboard_set(const wax::obj &, const wax::obj &); |
| 160 |
uhd::prop_names_t _tx_subdevs_in_use; |
| 161 |
wax_obj_proxy::sptr _tx_dboard_proxy; |
| 162 |
|
| 163 |
//rx ddc functions and settings
|
| 164 |
void rx_ddc_init(void); |
| 165 |
void rx_ddc_get(const wax::obj &, wax::obj &); |
| 166 |
void rx_ddc_set(const wax::obj &, const wax::obj &); |
| 167 |
double _ddc_freq; size_t _ddc_decim;
|
| 168 |
wax_obj_proxy::sptr _rx_ddc_proxy; |
| 169 |
|
| 170 |
//tx duc functions and settings
|
| 171 |
void tx_duc_init(void); |
| 172 |
void tx_duc_get(const wax::obj &, wax::obj &); |
| 173 |
void tx_duc_set(const wax::obj &, const wax::obj &); |
| 174 |
double _duc_freq; size_t _duc_interp;
|
| 175 |
wax_obj_proxy::sptr _tx_duc_proxy; |
| 176 |
|
| 177 |
//transports
|
| 178 |
uhd::transport::usb_zero_copy::sptr _data_transport; |
| 179 |
usrp_ctrl::sptr _ctrl_transport; |
| 180 |
}; |
| 181 |
|
| 182 |
#endif /* INCLUDED_USRP1_IMPL_HPP */ |