Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / usrp1 / usrp1_iface.hpp @ 9cb9e7d5

History | View | Annotate | Download (3.1 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_USRP1_IFACE_HPP
19
#define INCLUDED_USRP1_IFACE_HPP
20

    
21
#include <uhd/types/serial.hpp>
22
#include <boost/shared_ptr.hpp>
23
#include <boost/utility.hpp>
24
#include "usrp1_ctrl.hpp"
25

    
26
/*!
27
 * The usrp1 interface class:
28
 * Provides a set of functions to implementation layer.
29
 * Including spi, peek, poke, control...
30
 */
31
class usrp1_iface : boost::noncopyable, public uhd::i2c_iface{
32
public:
33
    typedef boost::shared_ptr<usrp1_iface> sptr;
34

    
35
    /*!
36
     * Make a new usrp1 interface with the control transport.
37
     * \param ctrl_transport the usrp controller object
38
     * \return a new usrp1 interface object
39
     */
40
    static sptr make(usrp_ctrl::sptr ctrl_transport);
41

    
42
    /*!
43
     * Write a register (32 bits)
44
     * \param addr the address
45
     * \param data the 32bit data
46
     */
47
    virtual void poke32(boost::uint32_t addr, boost::uint32_t data) = 0;
48

    
49
    /*!
50
     * Read a register (32 bits)
51
     * \param addr the address
52
     * \return the 32bit data
53
     */
54
    virtual boost::uint32_t peek32(boost::uint32_t addr) = 0;
55

    
56
    /*!
57
     * Write a register (16 bits)
58
     * \param addr the address
59
     * \param data the 16bit data
60
     */
61
    virtual void poke16(boost::uint32_t addr, boost::uint16_t data) = 0;
62

    
63
    /*!
64
     * read a register (16 bits)
65
     * \param addr the address
66
     * \return the 16bit data
67
     */
68
    virtual boost::uint16_t peek16(boost::uint32_t addr) = 0;
69

    
70
    /*!
71
     * Perform an spi transaction.
72
     * \param which_slave the slave device number
73
     * \param config spi config args
74
     * \param data the bits to write
75
     * \param num_bits how many bits in data
76
     * \param readback true to readback a value
77
     * \return spi data if readback set
78
     */
79
    virtual boost::uint32_t transact_spi(int which_slave,
80
                                         const uhd::spi_config_t &config,
81
                                         boost::uint32_t data,
82
                                         size_t num_bits,
83
                                         bool readback) = 0;
84

    
85
    /*!
86
     * Perform a general USB firmware OUT operation
87
     * \param request 
88
     * \param value
89
     * \param index 
90
     * \param data 
91
     * \return 
92
     */
93
    virtual void write_firmware_cmd(boost::uint8_t request,
94
                                   boost::uint16_t value,
95
                                   boost::uint16_t index,
96
                                   unsigned char* buff,
97
                                   boost::uint16_t length) = 0;
98
};
99

    
100
#endif /* INCLUDED_USRP1_IFACE_HPP */