Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / usrp2 / usrp2_iface.hpp @ 51a9c2d4

History | View | Annotate | Download (3.02 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/usrp/dboard_interface.hpp> //spi config
23
#include <boost/shared_ptr.hpp>
24
#include <boost/utility.hpp>
25
#include <boost/cstdint.hpp>
26
#include "fw_common.h"
27

    
28
/*!
29
 * The usrp2 interface class:
30
 * Provides a set of functions to implementation layer.
31
 * Including spi, peek, poke, control...
32
 */
33
class usrp2_iface : boost::noncopyable{
34
public:
35
    typedef boost::shared_ptr<usrp2_iface> sptr;
36

    
37
    /*!
38
     * Make a new usrp2 interface with the control transport.
39
     * \param ctrl_transport the udp transport object
40
     * \return a new usrp2 interface object
41
     */
42
    static sptr make(uhd::transport::udp_simple::sptr ctrl_transport);
43

    
44
    /*!
45
     * Perform a control transaction.
46
     * \param data a control data struct
47
     * \return the result control data
48
     */
49
    virtual usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &data) = 0;
50

    
51
    /*!
52
     * Write a register (32 bits)
53
     * \param addr the address
54
     * \param data the 32bit data
55
     */
56
    virtual void poke32(boost::uint32_t addr, boost::uint32_t data) = 0;
57

    
58
    /*!
59
     * Read a register (32 bits)
60
     * \param addr the address
61
     * \return the 32bit data
62
     */
63
    virtual boost::uint32_t peek32(boost::uint32_t addr) = 0;
64

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

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

    
79
    /*!
80
     * Perform an spi transaction.
81
     * \param which_slave the slave device number
82
     * \param config spi config args
83
     * \param data the bits to write
84
     * \param num_bits how many bits in data
85
     * \param readback true to readback a value
86
     * \return spi data if readback set
87
     */
88
    virtual boost::uint32_t transact_spi(
89
        int which_slave,
90
        const uhd::usrp::spi_config_t &config,
91
        boost::uint32_t data,
92
        size_t num_bits,
93
        bool readback
94
    ) = 0;
95

    
96
    /*!
97
     * Get the master clock frequency.
98
     * \return the frequency in Hz
99
     */
100
    virtual double get_master_clock_freq(void) = 0;
101
};
102

    
103
#endif /* INCLUDED_USRP2_IFACE_HPP */