Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (4.2 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
     * Set led usrp 
54
     * \param led_num which LED to control (0 or 1)
55
     * \param on turn LED on or off
56
     * \return 0 on success, error code otherwise
57
     */
58
    virtual int usrp_set_led(int led_num, bool on) = 0;
59

    
60
    /*!
61
     * Get firmware hash 
62
     * \param hash a size_t hash value
63
     * \return 0 on success, error code otherwise
64
     */
65
    virtual int usrp_get_firmware_hash(size_t &hash) = 0;
66

    
67
    /*!
68
     * Set firmware hash 
69
     * \param hash a size_t hash value
70
     * \return 0 on success, error code otherwise
71
     */
72
    virtual int usrp_set_firmware_hash(size_t hash) = 0;
73
                              
74
    /*!
75
     * Get fpga hash 
76
     * \param hash a size_t hash value
77
     * \return 0 on success, error code otherwise
78
     */
79
    virtual int usrp_get_fpga_hash(size_t &hash) = 0;
80

    
81
    /*!
82
     * Set fpga hash 
83
     * \param hash a size_t hash value
84
     * \return 0 on success, error code otherwise
85
     */
86
    virtual int usrp_set_fpga_hash(size_t hash) = 0;
87

    
88
    /*!
89
     * Set rx enable or disable 
90
     * \param on enable or disable value
91
     * \return 0 on success, error code otherwise
92
     */
93
    virtual int usrp_rx_enable(bool on) = 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_tx_enable(bool on) = 0;
101

    
102
    /*!
103
     * Submit an IN transfer 
104
     * \param request device specific request 
105
     * \param value device specific field
106
     * \param index device specific field
107
     * \param buff buffer to place data
108
     * \return number of bytes read or error 
109
     */
110
    virtual int usrp_control_read(boost::uint8_t request,
111
                                  boost::uint16_t value,
112
                                  boost::uint16_t index,
113
                                  unsigned char *buff,
114
                                  boost::uint16_t length) = 0;
115

    
116
    /*!
117
     * Submit an OUT transfer 
118
     * \param request device specific request 
119
     * \param value device specific field
120
     * \param index device specific field
121
     * \param buff buffer of data to be sent 
122
     * \return number of bytes written or error 
123
     */
124
    virtual int usrp_control_write(boost::uint8_t request,
125
                                   boost::uint16_t value,
126
                                   boost::uint16_t index,
127
                                   unsigned char *buff,
128
                                   boost::uint16_t length) = 0;
129

    
130
};
131

    
132
#endif /* INCLUDED_USRP_CTRL_HPP */