-
Notifications
You must be signed in to change notification settings - Fork 52
/
limesdr_impl.hpp
168 lines (117 loc) · 5.61 KB
/
limesdr_impl.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//
// Copyright (c) 2016, Jiang Wei <[email protected]>
// Copyright 2013-2015 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef INCLUDED_LIMESDR_IMPL_HPP
#define INCLUDED_LIMESDR_IMPL_HPP
#include <IConnection.h>
#include <LMS7002M.h>
#include <LMS7002M_RegistersMap.h>
#include <ConnectionRegistry.h>
#include <uhd/device.hpp>
#include <uhd/property_tree.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/sensors.hpp>
#include <uhd/types/ranges.hpp>
#include <uhd/types/direction.hpp>
#include <uhd/types/clock_config.hpp>
#include <uhd/types/filters.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/usrp/subdev_spec.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/utils/pimpl.hpp>
#include <uhd/utils/tasks.hpp>
#include <uhd/utils/cast.hpp>
#include <uhd/utils/static.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/safe_call.hpp>
#include <uhd/convert.hpp>
#include <boost/assign.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/thread/recursive_mutex.hpp>
#define TX_GAIN_MAX 89.8
#define RX_GAIN_MAX 76.0
static const double DEFAULT_CLOCK_RATE = 80e6;
class limesdr_impl : public uhd::device {
public:
limesdr_impl(const lime::ConnectionHandle &handle, const uhd::device_addr_t &);
~limesdr_impl(void);
//the io interface
uhd::rx_streamer::sptr get_rx_stream(const uhd::stream_args_t &args);
uhd::tx_streamer::sptr get_tx_stream(const uhd::stream_args_t &args);
bool recv_async_msg(uhd::async_metadata_t &, double);
private:
lime::IConnection *_conn;
const std::string _moduleName;
lime::LMS7002M *getRFIC(const size_t channel) const;
std::vector<lime::LMS7002M *> _rfics;
boost::recursive_mutex _accessMutex;
std::set<std::pair<uhd::direction_t, size_t>> _channelsToCal;
#ifndef ENABLE_MAUNAL_CLOCK
double fakeMasterClock;
#endif // ENABLE_MAUNAL_CLOCK
bool _autoTickRate;
std::map<size_t, bool> _fixedRxSampRate;
std::map<size_t, bool> _fixedTxSampRate;
std::map<size_t, int> _interps;
std::map<size_t, int> _decims;
std::map<int, std::map<size_t, double>> _actualBw;
std::map<size_t, boost::weak_ptr<uhd::rx_streamer> > _rx_streamers;
std::map<size_t, boost::weak_ptr<uhd::tx_streamer> > _tx_streamers;
std::vector<size_t> _rx_frontend_map;
std::vector<size_t> _tx_frontend_map;
uhd::usrp::subdev_spec_t get_frontend_mapping(const uhd::direction_t dir);
void set_frontend_mapping(const uhd::direction_t, const uhd::usrp::subdev_spec_t &);
void setHardwareTime(const std::string &what, const uhd::time_spec_t &time);
uhd::time_spec_t getHardwareTime(const std::string &what);
double getMasterClockRate(void);
void setMasterClockRate(const double);
uhd::meta_range_t getSampleRange(const uhd::direction_t dir, const size_t chan);
double getSampleRate(const uhd::direction_t dir, const size_t channel);
void setSampleRate(const uhd::direction_t dir, const size_t channel, const double rate);
double getGain(const uhd::direction_t dir, const size_t channel);
void setGain(const uhd::direction_t dir, const size_t channel, const double gain);
uhd::meta_range_t getGainRange(const uhd::direction_t dir, const size_t chan, const std::string &name);
double getFrequency(const uhd::direction_t dir, const size_t channel, const std::string &name);
void setFrequency(const uhd::direction_t direction, const size_t channel, const std::string &name, const double frequency);
uhd::meta_range_t getFrequencyRange(const uhd::direction_t dir, const size_t chan, const std::string &name);
void old_issue_stream_cmd(const size_t chan, const uhd::stream_cmd_t &cmd);
void setAntenna(const uhd::direction_t, const size_t channel, const std::string &name);
double getBandwidth(const uhd::direction_t dir, const size_t channel);
void setBandwidth(const uhd::direction_t dir, const size_t channel, const double bw);
uhd::meta_range_t getBandwidthRange(const uhd::direction_t dir, const size_t channel);
void setDCOffsetMode(const uhd::direction_t direction, const size_t channel, const bool automatic);
void setDCOffset(const uhd::direction_t direction, const size_t channel, const std::complex<double> &offset);
void setIQBalance(const uhd::direction_t direction, const size_t channel, const std::complex<double> &balance);
bool getDCOffsetMode(const uhd::direction_t direction, const size_t channel);
void setAutoTickRate(const bool enable);
uhd::filter_info_base::sptr getFilter(const uhd::direction_t dir, const size_t channel, const std::string &name);
void setFilter(const uhd::direction_t dir, const size_t channel, const std::string &name, const uhd::filter_info_base::sptr filter);
uhd::sensor_value_t get_temp(void);
void setup_radio(const size_t dspno);
uhd::sensor_value_t get_ref_locked(void);
uhd::sensor_value_t get_rssi(void);
uhd::sensor_value_t get_lo_locked(const uhd::direction_t dir, const size_t channel);
void error(void);
}
;
#endif /* INCLUDED_LIMESDR_IMPL_HPP */