Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / usrp2 / usrp2_impl.hpp @ 25494489

History | View | Annotate | Download (4.97 KB)

1
//
2
// Copyright 2010-2011 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 "rx_frontend_core_200.hpp"
25
#include "tx_frontend_core_200.hpp"
26
#include "rx_dsp_core_200.hpp"
27
#include "tx_dsp_core_200.hpp"
28
#include "time64_core_200.hpp"
29
#include <uhd/property_tree.hpp>
30
#include <uhd/usrp/gps_ctrl.hpp>
31
#include <uhd/device.hpp>
32
#include <uhd/utils/pimpl.hpp>
33
#include <uhd/types/dict.hpp>
34
#include <uhd/types/otw_type.hpp>
35
#include <uhd/types/stream_cmd.hpp>
36
#include <uhd/types/clock_config.hpp>
37
#include <uhd/usrp/dboard_eeprom.hpp>
38
#include <boost/shared_ptr.hpp>
39
#include <boost/function.hpp>
40
#include <uhd/transport/vrt_if_packet.hpp>
41
#include <uhd/transport/udp_simple.hpp>
42
#include <uhd/transport/udp_zero_copy.hpp>
43
#include <uhd/usrp/dboard_manager.hpp>
44
#include <uhd/usrp/subdev_spec.hpp>
45

    
46
static const double USRP2_LINK_RATE_BPS = 1000e6/8;
47
static const double mimo_clock_delay_usrp2_rev4 = 4.18e-9;
48
static const double mimo_clock_delay_usrp_n2xx = 3.55e-9;
49
static const size_t mimo_clock_sync_delay_cycles = 138;
50
static const size_t USRP2_SRAM_BYTES = size_t(1 << 20);
51
static const boost::uint32_t USRP2_TX_ASYNC_SID = 2;
52
static const boost::uint32_t USRP2_RX_SID_BASE = 3;
53

    
54
/*!
55
 * Make a usrp2 dboard interface.
56
 * \param iface the usrp2 interface object
57
 * \param clk_ctrl the clock control object
58
 * \return a sptr to a new dboard interface
59
 */
60
uhd::usrp::dboard_iface::sptr make_usrp2_dboard_iface(
61
    usrp2_iface::sptr iface,
62
    usrp2_clock_ctrl::sptr clk_ctrl
63
);
64

    
65
/*!
66
 * USRP2 implementation guts:
67
 * The implementation details are encapsulated here.
68
 * Handles device properties and streaming...
69
 */
70
class usrp2_impl : public uhd::device{
71
public:
72
    usrp2_impl(const uhd::device_addr_t &);
73
    ~usrp2_impl(void);
74

    
75
    //the io interface
76
    size_t send(
77
        const send_buffs_type &, size_t,
78
        const uhd::tx_metadata_t &, const uhd::io_type_t &,
79
        uhd::device::send_mode_t, double
80
    );
81
    size_t recv(
82
        const recv_buffs_type &, size_t,
83
        uhd::rx_metadata_t &, const uhd::io_type_t &,
84
        uhd::device::recv_mode_t, double
85
    );
86
    size_t get_max_send_samps_per_packet(void) const;
87
    size_t get_max_recv_samps_per_packet(void) const;
88
    bool recv_async_msg(uhd::async_metadata_t &, double);
89

    
90
private:
91
    uhd::property_tree::sptr _tree;
92
    struct mb_container_type{
93
        usrp2_iface::sptr iface;
94
        usrp2_clock_ctrl::sptr clock;
95
        usrp2_codec_ctrl::sptr codec;
96
        uhd::gps_ctrl::sptr gps;
97
        rx_frontend_core_200::sptr rx_fe;
98
        tx_frontend_core_200::sptr tx_fe;
99
        std::vector<rx_dsp_core_200::sptr> rx_dsps;
100
        tx_dsp_core_200::sptr tx_dsp;
101
        time64_core_200::sptr time64;
102
        std::vector<uhd::transport::zero_copy_if::sptr> rx_dsp_xports;
103
        uhd::transport::zero_copy_if::sptr tx_dsp_xport;
104
        uhd::usrp::dboard_manager::sptr dboard_manager;
105
        uhd::usrp::dboard_iface::sptr dboard_iface;
106
        size_t rx_chan_occ, tx_chan_occ;
107
        mb_container_type(void): rx_chan_occ(0), tx_chan_occ(0){}
108
    };
109
    uhd::dict<std::string, mb_container_type> _mbc;
110

    
111
    void set_mb_eeprom(const std::string &, const uhd::usrp::mboard_eeprom_t &);
112
    void set_db_eeprom(const std::string &, const std::string &, const uhd::usrp::dboard_eeprom_t &);
113

    
114
    uhd::sensor_value_t get_mimo_locked(const std::string &);
115
    uhd::sensor_value_t get_ref_locked(const std::string &);
116

    
117
    //device properties interface
118
    uhd::property_tree::sptr get_tree(void) const{
119
        return _tree;
120
    }
121

    
122
    //io impl methods and members
123
    uhd::otw_type_t _rx_otw_type, _tx_otw_type;
124
    UHD_PIMPL_DECL(io_impl) _io_impl;
125
    void io_init(void);
126
    void update_tick_rate(const double rate);
127
    void update_rx_samp_rate(const double rate);
128
    void update_tx_samp_rate(const double rate);
129
    //update spec methods are coercers until we only accept db_name == A
130
    uhd::usrp::subdev_spec_t update_rx_subdev_spec(const std::string &, const uhd::usrp::subdev_spec_t &);
131
    uhd::usrp::subdev_spec_t update_tx_subdev_spec(const std::string &, const uhd::usrp::subdev_spec_t &);
132
    double set_tx_dsp_freq(const std::string &, const double);
133
    uhd::meta_range_t get_tx_dsp_freq_range(const std::string &);
134
    void update_clock_source(const std::string &, const std::string &);
135
};
136

    
137
#endif /* INCLUDED_USRP2_IMPL_HPP */