Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (5.31 KB)

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

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

    
57
//! Make a usrp2 dboard interface.
58
uhd::usrp::dboard_iface::sptr make_usrp2_dboard_iface(
59
    wb_iface::sptr wb_iface,
60
    uhd::i2c_iface::sptr i2c_iface,
61
    uhd::spi_iface::sptr spi_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
    uhd::rx_streamer::sptr get_rx_stream(const uhd::stream_args_t &args);
77
    uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args);
78
    bool recv_async_msg(uhd::async_metadata_t &, double);
79

    
80
private:
81
    uhd::property_tree::sptr _tree;
82
    struct mb_container_type{
83
        usrp2_iface::sptr iface;
84
        usrp2_fifo_ctrl::sptr fifo_ctrl;
85
        uhd::spi_iface::sptr spiface;
86
        wb_iface::sptr wbiface;
87
        usrp2_clock_ctrl::sptr clock;
88
        usrp2_codec_ctrl::sptr codec;
89
        uhd::gps_ctrl::sptr gps;
90
        rx_frontend_core_200::sptr rx_fe;
91
        tx_frontend_core_200::sptr tx_fe;
92
        std::vector<rx_dsp_core_200::sptr> rx_dsps;
93
        std::vector<boost::weak_ptr<uhd::rx_streamer> > rx_streamers;
94
        std::vector<boost::weak_ptr<uhd::tx_streamer> > tx_streamers;
95
        tx_dsp_core_200::sptr tx_dsp;
96
        time64_core_200::sptr time64;
97
        user_settings_core_200::sptr user;
98
        std::vector<uhd::transport::zero_copy_if::sptr> rx_dsp_xports;
99
        uhd::transport::zero_copy_if::sptr tx_dsp_xport;
100
        uhd::transport::zero_copy_if::sptr fifo_ctrl_xport;
101
        uhd::usrp::dboard_manager::sptr dboard_manager;
102
        uhd::usrp::dboard_iface::sptr dboard_iface;
103
        size_t rx_chan_occ, tx_chan_occ;
104
        mb_container_type(void): rx_chan_occ(0), tx_chan_occ(0){}
105
    };
106
    uhd::dict<std::string, mb_container_type> _mbc;
107

    
108
    void set_mb_eeprom(const std::string &, const uhd::usrp::mboard_eeprom_t &);
109
    void set_db_eeprom(const std::string &, const std::string &, const uhd::usrp::dboard_eeprom_t &);
110

    
111
    uhd::sensor_value_t get_mimo_locked(const std::string &);
112
    uhd::sensor_value_t get_ref_locked(const std::string &);
113

    
114
    void set_rx_fe_corrections(const std::string &mb, const double);
115
    void set_tx_fe_corrections(const std::string &mb, const double);
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_PIMPL_DECL(io_impl) _io_impl;
124
    void io_init(void);
125
    void update_tick_rate(const double rate);
126
    void update_rx_samp_rate(const std::string &, const size_t, const double rate);
127
    void update_tx_samp_rate(const std::string &, const size_t, const double rate);
128
    void update_rates(void);
129
    //update spec methods are coercers until we only accept db_name == A
130
    void update_rx_subdev_spec(const std::string &, const uhd::usrp::subdev_spec_t &);
131
    void 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
    void program_stream_dest(uhd::transport::zero_copy_if::sptr &, const uhd::stream_args_t &);
136
};
137

    
138
#endif /* INCLUDED_USRP2_IMPL_HPP */