Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / usrp2 / usrp2_iface.hpp @ 476afe68

History | View | Annotate | Download (3.98 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
#ifndef INCLUDED_USRP2_IFACE_HPP
19
#define INCLUDED_USRP2_IFACE_HPP
20

    
21
#include <uhd/transport/udp_simple.hpp>
22
#include <uhd/types/serial.hpp>
23
#include <uhd/usrp/mboard_eeprom.hpp>
24
#include <boost/shared_ptr.hpp>
25
#include <boost/utility.hpp>
26
#include <boost/cstdint.hpp>
27
#include <utility>
28
#include <string>
29
#include "fw_common.h"
30
#include "usrp2_regs.hpp"
31

    
32
/*!
33
 * The usrp2 interface class:
34
 * Provides a set of functions to implementation layer.
35
 * Including spi, peek, poke, control...
36
 */
37
class usrp2_iface : public uhd::i2c_iface, boost::noncopyable{
38
public:
39
    typedef boost::shared_ptr<usrp2_iface> sptr;
40
    typedef std::pair<boost::uint32_t, boost::uint32_t> pair64;
41

    
42
    /*!
43
     * Make a new usrp2 interface with the control transport.
44
     * \param ctrl_transport the udp transport object
45
     * \return a new usrp2 interface object
46
     */
47
    static sptr make(uhd::transport::udp_simple::sptr ctrl_transport);
48

    
49
    /*!
50
     * Perform a control transaction.
51
     * \param data a control data struct
52
     * \return the result control data
53
     */
54
    virtual usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &data) = 0;
55

    
56
    /*!
57
     * Read a dual register (64 bits)
58
     * \param addrlo the address for the low-32 bits
59
     * \param addrhi the address for the high-32 bits
60
     * \return a pair of 32 bit integers lo, hi
61
     */
62
    virtual pair64 peek64(boost::uint32_t addrlo, boost::uint32_t addrhi) = 0;
63

    
64
    /*!
65
     * Write a register (32 bits)
66
     * \param addr the address
67
     * \param data the 32bit data
68
     */
69
    virtual void poke32(boost::uint32_t addr, boost::uint32_t data) = 0;
70

    
71
    /*!
72
     * Read a register (32 bits)
73
     * \param addr the address
74
     * \return the 32bit data
75
     */
76
    virtual boost::uint32_t peek32(boost::uint32_t addr) = 0;
77

    
78
    /*!
79
     * Write a register (16 bits)
80
     * \param addr the address
81
     * \param data the 16bit data
82
     */
83
    virtual void poke16(boost::uint32_t addr, boost::uint16_t data) = 0;
84

    
85
    /*!
86
     * Read a register (16 bits)
87
     * \param addr the address
88
     * \return the 16bit data
89
     */
90
    virtual boost::uint16_t peek16(boost::uint32_t addr) = 0;
91

    
92
    /*!
93
     * Perform an spi transaction.
94
     * \param which_slave the slave device number
95
     * \param config spi config args
96
     * \param data the bits to write
97
     * \param num_bits how many bits in data
98
     * \param readback true to readback a value
99
     * \return spi data if readback set
100
     */
101
    virtual boost::uint32_t transact_spi(
102
        int which_slave,
103
        const uhd::spi_config_t &config,
104
        boost::uint32_t data,
105
        size_t num_bits,
106
        bool readback
107
    ) = 0;
108

    
109
    virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0;
110

    
111
    virtual std::string read_uart(boost::uint8_t dev) = 0;
112

    
113
    //! The list of possible revision types
114
    enum rev_type {
115
        USRP2_REV3 = 3,
116
        USRP2_REV4 = 4,
117
        USRP_N200 = 200,
118
        USRP_N210 = 210,
119
        USRP_NXXX = 0
120
    };
121

    
122
    //! Get the revision type for this device
123
    virtual rev_type get_rev(void) = 0;
124

    
125
    //! Get the canonical name for this device
126
    virtual const std::string get_cname(void) = 0;
127

    
128
    /*!
129
     * Register map selected from USRP2/USRP2+.
130
     */
131
    usrp2_regs_t regs;
132

    
133
    //motherboard eeprom map structure
134
    uhd::usrp::mboard_eeprom_t mb_eeprom;
135
};
136

    
137
#endif /* INCLUDED_USRP2_IFACE_HPP */