Statistics
| Branch: | Tag: | Revision:

root / host / include / uhd / usrp / simple_usrp.hpp @ 48ad3b73

History | View | Annotate | Download (6.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_UHD_USRP_SIMPLE_USRP_HPP
19
#define INCLUDED_UHD_USRP_SIMPLE_USRP_HPP
20

    
21
#include <uhd/config.hpp>
22
#include <uhd/device.hpp>
23
#include <uhd/types/ranges.hpp>
24
#include <uhd/types/stream_cmd.hpp>
25
#include <uhd/types/clock_config.hpp>
26
#include <uhd/types/tune_result.hpp>
27
#include <uhd/usrp/subdev_spec.hpp>
28
#include <uhd/usrp/dboard_iface.hpp>
29
#include <boost/shared_ptr.hpp>
30
#include <boost/utility.hpp>
31
#include <vector>
32

    
33
namespace uhd{ namespace usrp{
34

    
35
/*!
36
 * The simple USRP device class:
37
 * A simple usrp facilitates ease-of-use for most use-case scenarios.
38
 * The wrapper provides convenience functions to tune the devices
39
 * as well as to set the dboard gains, antennas, and other properties.
40
 */
41
class UHD_API simple_usrp : boost::noncopyable{
42
public:
43
    typedef boost::shared_ptr<simple_usrp> sptr;
44

    
45
    /*!
46
     * Make a new simple usrp from the device address.
47
     * \param dev_addr the device address
48
     * \return a new simple usrp object
49
     */
50
    static sptr make(const device_addr_t &dev_addr);
51

    
52
    /*!
53
     * Get the underlying device object.
54
     * This is needed to get access to the streaming API and properties.
55
     * \return the device object within this simple usrp
56
     */
57
    virtual device::sptr get_device(void) = 0;
58

    
59
    /*!
60
     * Get a printable name for this simple usrp.
61
     * \return a printable string
62
     */
63
    virtual std::string get_pp_string(void) = 0;
64

    
65
    /*******************************************************************
66
     * Misc
67
     ******************************************************************/
68
    /*!
69
     * Gets the current time in the usrp time registers.
70
     * \return a timespec representing current usrp time
71
     */
72
    virtual time_spec_t get_time_now(void) = 0;
73

    
74
    /*!
75
     * Sets the time registers on the usrp immediately.
76
     * \param time_spec the time to latch into the usrp device
77
     */
78
    virtual void set_time_now(const time_spec_t &time_spec) = 0;
79

    
80
    /*!
81
     * Set the time registers on the usrp at the next pps tick.
82
     * The values will not be latched in until the pulse occurs.
83
     * It is recommended that the user sleep(1) after calling to ensure
84
     * that the time registers will be in a known state prior to use.
85
     *
86
     * Note: Because this call sets the time on the "next" pps,
87
     * the seconds in the time spec should be current seconds + 1.
88
     *
89
     * \param time_spec the time to latch into the usrp device
90
     */
91
    virtual void set_time_next_pps(const time_spec_t &time_spec) = 0;
92

    
93
    /*!
94
     * Issue a stream command to the usrp device.
95
     * This tells the usrp to send samples into the host.
96
     * See the documentation for stream_cmd_t for more info.
97
     * \param stream_cmd the stream command to issue
98
     */
99
    virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0;
100

    
101
    /*!
102
     * Set the clock configuration for the usrp device.
103
     * This tells the usrp how to get a 10Mhz reference and PPS clock.
104
     * See the documentation for clock_config_t for more info.
105
     * \param clock_config the clock configuration to set
106
     */
107
    virtual void set_clock_config(const clock_config_t &clock_config) = 0;
108

    
109
    /*******************************************************************
110
     * RX methods
111
     ******************************************************************/
112
    virtual void set_rx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0;
113
    virtual uhd::usrp::subdev_spec_t get_rx_subdev_spec(void) = 0;
114

    
115
    virtual void set_rx_rate(double rate) = 0;
116
    virtual double get_rx_rate(void) = 0;
117

    
118
    virtual tune_result_t set_rx_freq(double freq) = 0;
119
    virtual tune_result_t set_rx_freq(double freq, double lo_off) = 0;
120
    virtual double get_rx_freq(void) = 0;
121
    virtual freq_range_t get_rx_freq_range(void) = 0;
122

    
123
    virtual void set_rx_gain(float gain) = 0;
124
    virtual float get_rx_gain(void) = 0;
125
    virtual gain_range_t get_rx_gain_range(void) = 0;
126

    
127
    virtual void set_rx_antenna(const std::string &ant) = 0;
128
    virtual std::string get_rx_antenna(void) = 0;
129
    virtual std::vector<std::string> get_rx_antennas(void) = 0;
130

    
131
    virtual bool get_rx_lo_locked(void) = 0;
132

    
133
    /*!
134
     * Read the RSSI value from a usrp device.
135
     * Or throw if the dboard does not support an RSSI readback.
136
     * \return the rssi in dB
137
     */
138
    virtual float read_rssi(void) = 0;
139

    
140
    virtual dboard_iface::sptr get_rx_dboard_iface(void) = 0;
141

    
142
    /*******************************************************************
143
     * TX methods
144
     ******************************************************************/
145
    virtual void set_tx_subdev_spec(const uhd::usrp::subdev_spec_t &spec) = 0;
146
    virtual uhd::usrp::subdev_spec_t get_tx_subdev_spec(void) = 0;
147

    
148
    virtual void set_tx_rate(double rate) = 0;
149
    virtual double get_tx_rate(void) = 0;
150

    
151
    virtual tune_result_t set_tx_freq(double freq) = 0;
152
    virtual tune_result_t set_tx_freq(double freq, double lo_off) = 0;
153
    virtual double get_tx_freq(void) = 0;
154
    virtual freq_range_t get_tx_freq_range(void) = 0;
155

    
156
    virtual void set_tx_gain(float gain) = 0;
157
    virtual float get_tx_gain(void) = 0;
158
    virtual gain_range_t get_tx_gain_range(void) = 0;
159

    
160
    virtual void set_tx_antenna(const std::string &ant) = 0;
161
    virtual std::string get_tx_antenna(void) = 0;
162
    virtual std::vector<std::string> get_tx_antennas(void) = 0;
163

    
164
    virtual bool get_tx_lo_locked(void) = 0;
165

    
166
    virtual dboard_iface::sptr get_tx_dboard_iface(void) = 0;
167
};
168

    
169
}}
170

    
171
#endif /* INCLUDED_UHD_USRP_SIMPLE_USRP_HPP */