Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / b100 / b100_impl.hpp @ 4bcab9c5

History | View | Annotate | Download (4.57 KB)

1
//
2
// Copyright 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_B100_IMPL_HPP
19
#define INCLUDED_B100_IMPL_HPP
20

    
21
#include "fx2_ctrl.hpp"
22
#include "b100_ctrl.hpp"
23
#include "clock_ctrl.hpp"
24
#include "codec_ctrl.hpp"
25
#include "spi_core_100.hpp"
26
#include "i2c_core_100.hpp"
27
#include "rx_frontend_core_200.hpp"
28
#include "tx_frontend_core_200.hpp"
29
#include "rx_dsp_core_200.hpp"
30
#include "tx_dsp_core_200.hpp"
31
#include "time64_core_200.hpp"
32
#include <uhd/device.hpp>
33
#include <uhd/property_tree.hpp>
34
#include <uhd/utils/pimpl.hpp>
35
#include <uhd/types/dict.hpp>
36
#include <uhd/types/otw_type.hpp>
37
#include <uhd/types/clock_config.hpp>
38
#include <uhd/types/stream_cmd.hpp>
39
#include <uhd/usrp/mboard_eeprom.hpp>
40
#include <uhd/usrp/subdev_spec.hpp>
41
#include <uhd/usrp/dboard_eeprom.hpp>
42
#include <uhd/usrp/dboard_manager.hpp>
43
#include <uhd/transport/usb_zero_copy.hpp>
44

    
45
static const std::string     B100_FW_FILE_NAME = "usrp_b100_fw.ihx";
46
static const std::string     B100_FPGA_FILE_NAME = "usrp_b100_fpga.bin";
47
static const boost::uint16_t B100_FW_COMPAT_NUM = 0x02;
48
static const boost::uint16_t B100_FPGA_COMPAT_NUM = 0x05;
49
static const boost::uint32_t B100_RX_SID_BASE = 2;
50
static const boost::uint32_t B100_TX_ASYNC_SID = 1;
51
static const double          B100_DEFAULT_TICK_RATE = 64e6;
52

    
53
//! Make a b100 dboard interface
54
uhd::usrp::dboard_iface::sptr make_b100_dboard_iface(
55
    wb_iface::sptr wb_iface,
56
    uhd::i2c_iface::sptr i2c_iface,
57
    uhd::spi_iface::sptr spi_iface,
58
    b100_clock_ctrl::sptr clock,
59
    b100_codec_ctrl::sptr codec
60
);
61

    
62
//! Implementation guts
63
class b100_impl : public uhd::device {
64
public:
65
    //structors
66
    b100_impl(const uhd::device_addr_t &);
67
    ~b100_impl(void);
68

    
69
    //the io interface
70
    size_t send(const send_buffs_type &,
71
                size_t,
72
                const uhd::tx_metadata_t &,
73
                const uhd::io_type_t &,
74
                send_mode_t, double);
75
    size_t recv(const recv_buffs_type &,
76
                size_t, uhd::rx_metadata_t &,
77
                const uhd::io_type_t &,
78
                recv_mode_t, double);
79
    size_t get_max_send_samps_per_packet(void) const;
80
    size_t get_max_recv_samps_per_packet(void) const;
81
    bool recv_async_msg(uhd::async_metadata_t &, double);
82

    
83
private:
84
    uhd::property_tree::sptr _tree;
85

    
86
    //controllers
87
    spi_core_100::sptr _fpga_spi_ctrl;
88
    i2c_core_100::sptr _fpga_i2c_ctrl;
89
    rx_frontend_core_200::sptr _rx_fe;
90
    tx_frontend_core_200::sptr _tx_fe;
91
    std::vector<rx_dsp_core_200::sptr> _rx_dsps;
92
    tx_dsp_core_200::sptr _tx_dsp;
93
    time64_core_200::sptr _time64;
94
    b100_clock_ctrl::sptr _clock_ctrl;
95
    b100_codec_ctrl::sptr _codec_ctrl;
96
    b100_ctrl::sptr _fpga_ctrl;
97
    uhd::usrp::fx2_ctrl::sptr _fx2_ctrl;
98

    
99
    //transports
100
    uhd::transport::zero_copy_if::sptr _data_transport, _ctrl_transport;
101

    
102
    //dboard stuff
103
    uhd::usrp::dboard_manager::sptr _dboard_manager;
104
    uhd::usrp::dboard_iface::sptr _dboard_iface;
105

    
106
    //handle io stuff
107
    uhd::otw_type_t _rx_otw_type, _tx_otw_type;
108
    UHD_PIMPL_DECL(io_impl) _io_impl;
109
    void io_init(void);
110

    
111
    //device properties interface
112
    void get(const wax::obj &, wax::obj &val){
113
        val = _tree; //entry point into property tree
114
    }
115

    
116
    void check_fw_compat(void);
117
    void check_fpga_compat(void);
118
    double update_rx_codec_gain(const double); //sets A and B at once
119
    void set_mb_eeprom(const uhd::usrp::mboard_eeprom_t &);
120
    void set_db_eeprom(const std::string &, const uhd::usrp::dboard_eeprom_t &);
121
    void update_tick_rate(const double rate);
122
    void update_rx_samp_rate(const double rate);
123
    void update_tx_samp_rate(const double rate);
124
    void update_rx_subdev_spec(const uhd::usrp::subdev_spec_t &);
125
    void update_tx_subdev_spec(const uhd::usrp::subdev_spec_t &);
126
    void update_clock_source(const std::string &);
127
    void reset_gpif(const boost::uint16_t);
128
    void enable_gpif(const bool);
129
    void clear_fpga_fifo(void);
130
    void handle_async_message(uhd::transport::managed_recv_buffer::sptr);
131
};
132

    
133
#endif /* INCLUDED_b100_IMPL_HPP */