root / host / lib / usrp / usrp1 / usrp1_impl.hpp @ 43e5480d
History | View | Annotate | Download (6.7 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/dict.hpp> |
| 25 |
#include <uhd/types/otw_type.hpp> |
| 26 |
#include <uhd/types/clock_config.hpp> |
| 27 |
#include <uhd/types/stream_cmd.hpp> |
| 28 |
#include <uhd/usrp/subdev_spec.hpp> |
| 29 |
#include <uhd/usrp/dboard_eeprom.hpp> |
| 30 |
#include <uhd/usrp/dboard_manager.hpp> |
| 31 |
#include <uhd/transport/usb_zero_copy.hpp> |
| 32 |
|
| 33 |
#ifndef INCLUDED_USRP1_IMPL_HPP
|
| 34 |
#define INCLUDED_USRP1_IMPL_HPP
|
| 35 |
|
| 36 |
/*!
|
| 37 |
* Simple wax obj proxy class:
|
| 38 |
* Provides a wax obj interface for a set and a get function.
|
| 39 |
* This allows us to create nested properties structures
|
| 40 |
* while maintaining flattened code within the implementation.
|
| 41 |
*/
|
| 42 |
class wax_obj_proxy : public wax::obj { |
| 43 |
public:
|
| 44 |
typedef boost::function<void(const wax::obj &, wax::obj &)> get_t; |
| 45 |
typedef boost::function<void(const wax::obj &, const wax::obj &)> set_t; |
| 46 |
typedef boost::shared_ptr<wax_obj_proxy> sptr;
|
| 47 |
|
| 48 |
static sptr make(const get_t &get, const set_t &set) |
| 49 |
{
|
| 50 |
return sptr(new wax_obj_proxy(get, set)); |
| 51 |
} |
| 52 |
|
| 53 |
private:
|
| 54 |
get_t _get; set_t _set; |
| 55 |
wax_obj_proxy(const get_t &get, const set_t &set): _get(get), _set(set) {}; |
| 56 |
void get(const wax::obj &key, wax::obj &val) {return _get(key, val);} |
| 57 |
void set(const wax::obj &key, const wax::obj &val) {return _set(key, val);} |
| 58 |
}; |
| 59 |
|
| 60 |
/*!
|
| 61 |
* USRP1 implementation guts:
|
| 62 |
* The implementation details are encapsulated here.
|
| 63 |
* Handles properties on the mboard, dboard, dsps...
|
| 64 |
*/
|
| 65 |
class usrp1_impl : public uhd::device { |
| 66 |
public:
|
| 67 |
//! used everywhere to differentiate slots/sides...
|
| 68 |
enum dboard_slot_t{
|
| 69 |
DBOARD_SLOT_A = 'A',
|
| 70 |
DBOARD_SLOT_B = 'B'
|
| 71 |
}; |
| 72 |
//and a way to enumerate through a list of the above...
|
| 73 |
static const std::vector<dboard_slot_t> _dboard_slots; |
| 74 |
|
| 75 |
//structors
|
| 76 |
usrp1_impl(uhd::transport::usb_zero_copy::sptr data_transport, |
| 77 |
usrp_ctrl::sptr ctrl_transport); |
| 78 |
|
| 79 |
~usrp1_impl(void);
|
| 80 |
|
| 81 |
//the io interface
|
| 82 |
size_t send(const std::vector<const void *> &, |
| 83 |
size_t, |
| 84 |
const uhd::tx_metadata_t &,
|
| 85 |
const uhd::io_type_t &,
|
| 86 |
send_mode_t); |
| 87 |
|
| 88 |
size_t recv(const std::vector<void *> &, |
| 89 |
size_t, uhd::rx_metadata_t &, |
| 90 |
const uhd::io_type_t &,
|
| 91 |
recv_mode_t, |
| 92 |
size_t timeout); |
| 93 |
|
| 94 |
size_t get_max_send_samps_per_packet(void) const { return 0; } |
| 95 |
size_t get_max_recv_samps_per_packet(void) const { return 0; } |
| 96 |
|
| 97 |
bool recv_async_msg(uhd::async_metadata_t &, size_t) {
|
| 98 |
//TODO sleep the number of ms supplied (dont want to hog CPU)
|
| 99 |
return false; |
| 100 |
} |
| 101 |
|
| 102 |
private:
|
| 103 |
/*!
|
| 104 |
* Make a usrp1 dboard interface.
|
| 105 |
* \param iface the usrp1 interface object
|
| 106 |
* \param clock the clock control interface
|
| 107 |
* \param codec the codec control interface
|
| 108 |
* \param dboard_slot the slot identifier
|
| 109 |
* \return a sptr to a new dboard interface
|
| 110 |
*/
|
| 111 |
static uhd::usrp::dboard_iface::sptr make_dboard_iface(
|
| 112 |
usrp1_iface::sptr iface, |
| 113 |
usrp1_clock_ctrl::sptr clock, |
| 114 |
usrp1_codec_ctrl::sptr codec, |
| 115 |
dboard_slot_t dboard_slot |
| 116 |
); |
| 117 |
|
| 118 |
//interface to ioctls and file descriptor
|
| 119 |
usrp1_iface::sptr _iface; |
| 120 |
|
| 121 |
//handle io stuff
|
| 122 |
UHD_PIMPL_DECL(io_impl) _io_impl; |
| 123 |
void io_init(void); |
| 124 |
void issue_stream_cmd(const uhd::stream_cmd_t &stream_cmd); |
| 125 |
void handle_overrun(size_t);
|
| 126 |
|
| 127 |
//otw types
|
| 128 |
uhd::otw_type_t _rx_otw_type; |
| 129 |
uhd::otw_type_t _tx_otw_type; |
| 130 |
|
| 131 |
//configuration shadows
|
| 132 |
uhd::clock_config_t _clock_config; |
| 133 |
uhd::usrp::subdev_spec_t _rx_subdev_spec, _tx_subdev_spec; |
| 134 |
|
| 135 |
//clock control
|
| 136 |
usrp1_clock_ctrl::sptr _clock_ctrl; |
| 137 |
|
| 138 |
//ad9862 codec control interface
|
| 139 |
uhd::dict<dboard_slot_t, usrp1_codec_ctrl::sptr> _codec_ctrls; |
| 140 |
|
| 141 |
//codec properties interfaces
|
| 142 |
void codec_init(void); |
| 143 |
void rx_codec_get(const wax::obj &, wax::obj &, dboard_slot_t); |
| 144 |
void rx_codec_set(const wax::obj &, const wax::obj &, dboard_slot_t); |
| 145 |
void tx_codec_get(const wax::obj &, wax::obj &, dboard_slot_t); |
| 146 |
void tx_codec_set(const wax::obj &, const wax::obj &, dboard_slot_t); |
| 147 |
uhd::dict<dboard_slot_t, wax_obj_proxy::sptr> _rx_codec_proxies, _tx_codec_proxies; |
| 148 |
|
| 149 |
//device functions and settings
|
| 150 |
void get(const wax::obj &, wax::obj &); |
| 151 |
void set(const wax::obj &, const wax::obj &); |
| 152 |
|
| 153 |
//mboard functions and settings
|
| 154 |
void mboard_init(void); |
| 155 |
void mboard_get(const wax::obj &, wax::obj &); |
| 156 |
void mboard_set(const wax::obj &, const wax::obj &); |
| 157 |
wax_obj_proxy::sptr _mboard_proxy; |
| 158 |
|
| 159 |
//xx dboard functions and settings
|
| 160 |
void dboard_init(void); |
| 161 |
uhd::dict<dboard_slot_t, uhd::usrp::dboard_manager::sptr> _dboard_managers; |
| 162 |
uhd::dict<dboard_slot_t, uhd::usrp::dboard_iface::sptr> _dboard_ifaces; |
| 163 |
|
| 164 |
//rx dboard functions and settings
|
| 165 |
uhd::dict<dboard_slot_t, uhd::usrp::dboard_eeprom_t> _rx_db_eeproms; |
| 166 |
void rx_dboard_get(const wax::obj &, wax::obj &, dboard_slot_t); |
| 167 |
void rx_dboard_set(const wax::obj &, const wax::obj &, dboard_slot_t); |
| 168 |
uhd::dict<dboard_slot_t, wax_obj_proxy::sptr> _rx_dboard_proxies; |
| 169 |
|
| 170 |
//tx dboard functions and settings
|
| 171 |
uhd::dict<dboard_slot_t, uhd::usrp::dboard_eeprom_t> _tx_db_eeproms; |
| 172 |
void tx_dboard_get(const wax::obj &, wax::obj &, dboard_slot_t); |
| 173 |
void tx_dboard_set(const wax::obj &, const wax::obj &, dboard_slot_t); |
| 174 |
uhd::dict<dboard_slot_t, wax_obj_proxy::sptr> _tx_dboard_proxies; |
| 175 |
|
| 176 |
//rx dsp functions and settings
|
| 177 |
void rx_dsp_init(void); |
| 178 |
void rx_dsp_get(const wax::obj &, wax::obj &); |
| 179 |
void rx_dsp_set(const wax::obj &, const wax::obj &); |
| 180 |
double _rx_dsp_freq; size_t _rx_dsp_decim;
|
| 181 |
wax_obj_proxy::sptr _rx_dsp_proxy; |
| 182 |
|
| 183 |
//tx dsp functions and settings
|
| 184 |
void tx_dsp_init(void); |
| 185 |
void tx_dsp_get(const wax::obj &, wax::obj &); |
| 186 |
void tx_dsp_set(const wax::obj &, const wax::obj &); |
| 187 |
double _tx_dsp_freq; size_t _tx_dsp_interp;
|
| 188 |
wax_obj_proxy::sptr _tx_dsp_proxy; |
| 189 |
|
| 190 |
//transports
|
| 191 |
uhd::transport::usb_zero_copy::sptr _data_transport; |
| 192 |
usrp_ctrl::sptr _ctrl_transport; |
| 193 |
}; |
| 194 |
|
| 195 |
#endif /* INCLUDED_USRP1_IMPL_HPP */ |