Statistics
| Branch: | Tag: | Revision:

root / host / lib / usrp / usrp1 / usrp1_ctrl.hpp @ b96088b6

History | View | Annotate | Download (5.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_USRP_CTRL_HPP
19
#define INCLUDED_USRP_CTRL_HPP
20

    
21
#include <uhd/transport/usb_control.hpp> 
22
#include <boost/shared_ptr.hpp>
23
#include <boost/utility.hpp>
24

    
25
class usrp_ctrl : boost::noncopyable{
26
public:
27
    typedef boost::shared_ptr<usrp_ctrl> sptr;
28

    
29
    /*!
30
     * Make a usrp control object from a control transport
31
     * \param ctrl_transport a USB control transport
32
     * \return a new usrp control object
33
     */
34
    static sptr make(uhd::transport::usb_control::sptr ctrl_transport);
35

    
36
    /*!
37
     * Load firmware in Intel HEX Format onto device 
38
     * \param filename name of firmware file
39
     * \param force reload firmware if already loaded
40
     * \return 0 on success, error code otherwise
41
     */
42
    virtual int usrp_load_firmware(std::string filename,
43
                                   bool force = false) = 0;
44

    
45
    /*!
46
     * Load fpga file onto usrp 
47
     * \param filename name of fpga image 
48
     * \return 0 on success, error code otherwise
49
     */
50
    virtual int usrp_load_fpga(std::string filename) = 0;
51

    
52
    /*!
53
     * Load USB descriptor file in Intel HEX format into EEPROM
54
     * \param filename name of EEPROM image 
55
     * \return 0 on success, error code otherwise
56
     */
57
    virtual int usrp_load_eeprom(std::string filestring) = 0;
58

    
59
    /*!
60
     * Set led usrp 
61
     * \param led_num which LED to control (0 or 1)
62
     * \param on turn LED on or off
63
     * \return 0 on success, error code otherwise
64
     */
65
    virtual int usrp_set_led(int led_num, bool on) = 0;
66

    
67
    /*!
68
     * Get firmware hash 
69
     * \param hash a size_t hash value
70
     * \return 0 on success, error code otherwise
71
     */
72
    virtual int usrp_get_firmware_hash(size_t &hash) = 0;
73

    
74
    /*!
75
     * Set firmware hash 
76
     * \param hash a size_t hash value
77
     * \return 0 on success, error code otherwise
78
     */
79
    virtual int usrp_set_firmware_hash(size_t hash) = 0;
80
                              
81
    /*!
82
     * Get fpga hash 
83
     * \param hash a size_t hash value
84
     * \return 0 on success, error code otherwise
85
     */
86
    virtual int usrp_get_fpga_hash(size_t &hash) = 0;
87

    
88
    /*!
89
     * Set fpga hash 
90
     * \param hash a size_t hash value
91
     * \return 0 on success, error code otherwise
92
     */
93
    virtual int usrp_set_fpga_hash(size_t hash) = 0;
94

    
95
    /*!
96
     * Set rx enable or disable 
97
     * \param on enable or disable value
98
     * \return 0 on success, error code otherwise
99
     */
100
    virtual int usrp_rx_enable(bool on) = 0;
101

    
102
    /*!
103
     * Set rx enable or disable 
104
     * \param on enable or disable value
105
     * \return 0 on success, error code otherwise
106
     */
107
    virtual int usrp_tx_enable(bool on) = 0;
108

    
109
    /*!
110
     * Submit an IN transfer 
111
     * \param request device specific request 
112
     * \param value device specific field
113
     * \param index device specific field
114
     * \param buff buffer to place data
115
     * \return number of bytes read or error 
116
     */
117
    virtual int usrp_control_read(boost::uint8_t request,
118
                                  boost::uint16_t value,
119
                                  boost::uint16_t index,
120
                                  unsigned char *buff,
121
                                  boost::uint16_t length) = 0;
122

    
123
    /*!
124
     * Submit an OUT transfer 
125
     * \param request device specific request 
126
     * \param value device specific field
127
     * \param index device specific field
128
     * \param buff buffer of data to be sent 
129
     * \return number of bytes written or error 
130
     */
131
    virtual int usrp_control_write(boost::uint8_t request,
132
                                   boost::uint16_t value,
133
                                   boost::uint16_t index,
134
                                   unsigned char *buff,
135
                                   boost::uint16_t length) = 0;
136

    
137
    /*!
138
     * Perform an I2C write
139
     * \param i2c_addr I2C device address
140
     * \param buf data to be written 
141
     * \param len length of data in bytes
142
     * \return number of bytes written or error 
143
     */
144

    
145
    virtual int usrp_i2c_write(boost::uint16_t i2c_addr,
146
                               unsigned char *buf, 
147
                               boost::uint16_t len) = 0;
148

    
149
    /*!
150
     * Perform an I2C read
151
     * \param i2c_addr I2C device address
152
     * \param buf data to be read 
153
     * \param len length of data in bytes
154
     * \return number of bytes read or error 
155
     */
156

    
157
    virtual int usrp_i2c_read(boost::uint16_t i2c_addr,
158
                               unsigned char *buf, 
159
                               boost::uint16_t len) = 0;
160

    
161
};
162

    
163
#endif /* INCLUDED_USRP_CTRL_HPP */