Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhongxiao
OpenXG-RAN
Commits
00ebfbb0
Commit
00ebfbb0
authored
Feb 01, 2017
by
Laurent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix merge compilation
parent
9f33d090
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
253 deletions
+44
-253
targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
+44
-253
No files found.
targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
View file @
00ebfbb0
...
...
@@ -312,6 +312,7 @@ int trx_usrp_set_freq(openair0_device* device, openair0_config_t *openair0_cfg,
s
->
usrp
->
set_rx_freq
(
device
->
openair0_cfg
[
0
].
rx_freq
[
0
]);
}
return
(
0
);
}
...
...
@@ -495,22 +496,16 @@ extern "C" {
// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096";
// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096";
uhd
::
device_addrs_t
device_adds
=
uhd
::
device
::
find
(
args
);
if
(
device_adds
.
size
()
==
0
)
{
if
(
device_adds
.
size
()
==
0
)
{
std
::
cerr
<<
"No USRP Device Found. "
<<
std
::
endl
;
free
(
s
);
return
-
1
;
}
printf
(
"Found USRP X300
\n
"
);
LOG_I
(
PHY
,
"Found USRP X300
\n
"
);
s
->
usrp
=
uhd
::
usrp
::
multi_usrp
::
make
(
args
);
// s->usrp->set_rx_subdev_spec(rx_subdev);
// s->usrp->set_tx_subdev_spec(tx_subdev);
// lock mboard clocks
if
(
openair0_cfg
[
0
].
clock_source
==
internal
)
s
->
usrp
->
set_clock_source
(
"internal"
);
...
...
@@ -553,13 +548,13 @@ extern "C" {
openair0_cfg
[
0
].
rx_bw
=
1.25e6
;
break
;
default:
printf
(
"Error: unknown sampling rate %f
\n
"
,
openair0_cfg
[
0
].
sample_rate
);
LOG_E
(
PHY
,
"Error: unknown sampling rate %f
\n
"
,
openair0_cfg
[
0
].
sample_rate
);
exit
(
-
1
);
break
;
}
}
else
{
printf
(
"Found USRP B200
"
);
LOG_I
(
PHY
,
"Found USRP B200
\n
"
);
args
+=
",num_send_frames=256,num_recv_frames=256, send_frame_size=15360, recv_frame_size=15360"
;
s
->
usrp
=
uhd
::
usrp
::
multi_usrp
::
make
(
args
);
...
...
@@ -578,13 +573,10 @@ extern "C" {
s
->
usrp
->
set_clock_source
(
"external"
);
device
->
type
=
USRP_B200_DEV
;
if
((
vers
==
3
)
&&
(
subvers
==
9
)
&&
(
subsubvers
>=
2
))
{
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_b210
;
bw_gain_adjust
=
0
;
}
else
{
}
else
{
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_b210_38
;
bw_gain_adjust
=
1
;
}
...
...
@@ -626,7 +618,7 @@ extern "C" {
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
default:
printf
(
"Error: unknown sampling rate %f
\n
"
,
openair0_cfg
[
0
].
sample_rate
);
LOG_E
(
PHY
,
"Error: unknown sampling rate %f
\n
"
,
openair0_cfg
[
0
].
sample_rate
);
exit
(
-
1
);
break
;
}
...
...
@@ -638,208 +630,6 @@ extern "C" {
openair0_cfg
[
0
].
iq_txshift
=
4
;
//shift
openair0_cfg
[
0
].
iq_rxrescale
=
15
;
//rescale iqs
for
(
i
=
0
;
i
<
s
->
usrp
->
get_rx_num_channels
();
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
rx_num_channels
)
{
s
->
usrp
->
set_rx_rate
(
openair0_cfg
[
0
].
sample_rate
,
i
);
//s->usrp->set_rx_bandwidth(openair0_cfg[0].rx_bw,i);
//printf("Setting rx freq/gain on channel %lu/%lu : BW %f (readback %f)\n",i,s->usrp->get_rx_num_channels(),openair0_cfg[0].rx_bw/1e6,s->usrp->get_rx_bandwidth(i)/1e6);
s
->
usrp
->
set_rx_freq
(
openair0_cfg
[
0
].
rx_freq
[
i
],
i
);
set_rx_gain_offset
(
&
openair0_cfg
[
0
],
i
,
bw_gain_adjust
);
::
uhd
::
gain_range_t
gain_range
=
s
->
usrp
->
get_rx_gain_range
(
i
);
// limit to maximum gain
if
(
openair0_cfg
[
0
].
rx_gain
[
i
]
-
openair0_cfg
[
0
].
rx_gain_offset
[
i
]
>
gain_range
.
stop
())
{
printf
(
"RX Gain %lu too high, lower by %f dB
\n
"
,
i
,
openair0_cfg
[
0
].
rx_gain
[
i
]
-
openair0_cfg
[
0
].
rx_gain_offset
[
i
]
-
gain_range
.
stop
());
exit
(
-
1
);
}
s
->
usrp
->
set_rx_gain
(
openair0_cfg
[
0
].
rx_gain
[
i
]
-
openair0_cfg
[
0
].
rx_gain_offset
[
i
],
i
);
printf
(
"RX Gain %lu %f (%f) => %f (max %f)
\n
"
,
i
,
openair0_cfg
[
0
].
rx_gain
[
i
],
openair0_cfg
[
0
].
rx_gain_offset
[
i
],
openair0_cfg
[
0
].
rx_gain
[
i
]
-
openair0_cfg
[
0
].
rx_gain_offset
[
i
],
gain_range
.
stop
());
}
}
for
(
i
=
0
;
i
<
s
->
usrp
->
get_tx_num_channels
();
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
tx_num_channels
)
{
s
->
usrp
->
set_tx_rate
(
openair0_cfg
[
0
].
sample_rate
,
i
);
//s->usrp->set_tx_bandwidth(openair0_cfg[0].tx_bw,i);
//printf("Setting tx freq/gain on channel %lu/%lu: BW %f (readback %f)\n",i,s->usrp->get_tx_num_channels(),openair0_cfg[0].tx_bw/1e6,s->usrp->get_tx_bandwidth(i)/1e6);
s
->
usrp
->
set_tx_freq
(
openair0_cfg
[
0
].
tx_freq
[
i
],
i
);
s
->
usrp
->
set_tx_gain
(
openair0_cfg
[
0
].
tx_gain
[
i
],
i
);
}
}
// display USRP settings
std
::
cout
<<
boost
::
format
(
"Actual master clock: %fMHz..."
)
%
(
s
->
usrp
->
get_master_clock_rate
()
/
1e6
)
<<
std
::
endl
;
sleep
(
1
);
// create tx & rx streamer
uhd
::
stream_args_t
stream_args_rx
(
"sc16"
,
"sc16"
);
int
samples
=
openair0_cfg
[
0
].
sample_rate
;
samples
/=
24000
;
// stream_args_rx.args["spp"] = str(boost::format("%d") % samples);
for
(
i
=
0
;
i
<
openair0_cfg
[
0
].
rx_num_channels
;
i
++
)
stream_args_rx
.
channels
.
push_back
(
i
);
s
->
rx_stream
=
s
->
usrp
->
get_rx_stream
(
stream_args_rx
);
std
::
cout
<<
boost
::
format
(
"rx_max_num_samps %u"
)
%
(
s
->
rx_stream
->
get_max_num_samps
())
<<
std
::
endl
;
//openair0_cfg[0].samples_per_packet = s->rx_stream->get_max_num_samps();
uhd
::
stream_args_t
stream_args_tx
(
"sc16"
,
"sc16"
);
//stream_args_tx.args["spp"] = str(boost::format("%d") % 2048);//(openair0_cfg[0].tx_num_channels*openair0_cfg[0].samples_per_packet));
for
(
i
=
0
;
i
<
openair0_cfg
[
0
].
tx_num_channels
;
i
++
)
stream_args_tx
.
channels
.
push_back
(
i
);
s
->
tx_stream
=
s
->
usrp
->
get_tx_stream
(
stream_args_tx
);
std
::
cout
<<
boost
::
format
(
"tx_max_num_samps %u"
)
%
(
s
->
tx_stream
->
get_max_num_samps
())
<<
std
::
endl
;
/* Setting TX/RX BW after streamers are created due to USRP calibration issue */
for
(
i
=
0
;
i
<
s
->
usrp
->
get_tx_num_channels
();
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
tx_num_channels
)
{
s
->
usrp
->
set_tx_bandwidth
(
openair0_cfg
[
0
].
tx_bw
,
i
);
printf
(
"Setting tx freq/gain on channel %lu/%lu: BW %f (readback %f)
\n
"
,
i
,
s
->
usrp
->
get_tx_num_channels
(),
openair0_cfg
[
0
].
tx_bw
/
1e6
,
s
->
usrp
->
get_tx_bandwidth
(
i
)
/
1e6
);
}
}
for
(
i
=
0
;
i
<
s
->
usrp
->
get_rx_num_channels
();
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
rx_num_channels
)
{
s
->
usrp
->
set_rx_bandwidth
(
openair0_cfg
[
0
].
rx_bw
,
i
);
printf
(
"Setting rx freq/gain on channel %lu/%lu : BW %f (readback %f)
\n
"
,
i
,
s
->
usrp
->
get_rx_num_channels
(),
openair0_cfg
[
0
].
rx_bw
/
1e6
,
s
->
usrp
->
get_rx_bandwidth
(
i
)
/
1e6
);
}
}
s
->
usrp
->
set_time_now
(
uhd
::
time_spec_t
(
0.0
));
for
(
i
=
0
;
i
<
openair0_cfg
[
0
].
rx_num_channels
;
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
rx_num_channels
)
{
printf
(
"RX Channel %lu
\n
"
,
i
);
std
::
cout
<<
boost
::
format
(
"Actual RX sample rate: %fMSps..."
)
%
(
s
->
usrp
->
get_rx_rate
(
i
)
/
1e6
)
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual RX frequency: %fGHz..."
)
%
(
s
->
usrp
->
get_rx_freq
(
i
)
/
1e9
)
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual RX gain: %f..."
)
%
(
s
->
usrp
->
get_rx_gain
(
i
))
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual RX bandwidth: %fM..."
)
%
(
s
->
usrp
->
get_rx_bandwidth
(
i
)
/
1e6
)
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual RX antenna: %s..."
)
%
(
s
->
usrp
->
get_rx_antenna
(
i
))
<<
std
::
endl
;
}
}
for
(
i
=
0
;
i
<
openair0_cfg
[
0
].
tx_num_channels
;
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
tx_num_channels
)
{
printf
(
"TX Channel %lu
\n
"
,
i
);
std
::
cout
<<
std
::
endl
<<
boost
::
format
(
"Actual TX sample rate: %fMSps..."
)
%
(
s
->
usrp
->
get_tx_rate
(
i
)
/
1e6
)
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual TX frequency: %fGHz..."
)
%
(
s
->
usrp
->
get_tx_freq
(
i
)
/
1e9
)
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual TX gain: %f..."
)
%
(
s
->
usrp
->
get_tx_gain
(
i
))
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual TX bandwidth: %fM..."
)
%
(
s
->
usrp
->
get_tx_bandwidth
(
i
)
/
1e6
)
<<
std
::
endl
;
std
::
cout
<<
boost
::
format
(
"Actual TX antenna: %s..."
)
%
(
s
->
usrp
->
get_tx_antenna
(
i
))
<<
std
::
endl
;
}
}
std
::
cout
<<
boost
::
format
(
"Device timestamp: %f..."
)
%
(
s
->
usrp
->
get_time_now
().
get_real_secs
())
<<
std
::
endl
;
// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096";
uhd
::
device_addrs_t
device_adds
=
uhd
::
device
::
find
(
args
);
if
(
device_adds
.
size
()
==
0
)
{
std
::
cerr
<<
"No USRP Device Found. "
<<
std
::
endl
;
free
(
s
);
return
-
1
;
}
LOG_I
(
PHY
,
"Found USRP X300
\n
"
);
s
->
usrp
=
uhd
::
usrp
::
multi_usrp
::
make
(
args
);
// lock mboard clocks
s
->
usrp
->
set_clock_source
(
"internal"
);
//Setting device type to USRP X300/X310
device
->
type
=
USRP_X300_DEV
;
// this is not working yet, master clock has to be set via constructor
// set master clock rate and sample rate for tx & rx for streaming
//s->usrp->set_master_clock_rate(usrp_master_clock);
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_x310
;
switch
((
int
)
openair0_cfg
[
0
].
sample_rate
)
{
case
30720000
:
// from usrp_time_offset
openair0_cfg
[
0
].
tx_sample_advance
=
15
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
case
15360000
:
openair0_cfg
[
0
].
tx_sample_advance
=
45
;
openair0_cfg
[
0
].
tx_bw
=
10e6
;
openair0_cfg
[
0
].
rx_bw
=
10e6
;
break
;
case
7680000
:
openair0_cfg
[
0
].
tx_sample_advance
=
50
;
openair0_cfg
[
0
].
tx_bw
=
5e6
;
openair0_cfg
[
0
].
rx_bw
=
5e6
;
break
;
case
1920000
:
openair0_cfg
[
0
].
tx_sample_advance
=
50
;
openair0_cfg
[
0
].
tx_bw
=
1.25e6
;
openair0_cfg
[
0
].
rx_bw
=
1.25e6
;
break
;
default:
LOG_E
(
PHY
,
"Error: unknown sampling rate %f
\n
"
,
openair0_cfg
[
0
].
sample_rate
);
exit
(
-
1
);
break
;
}
}
else
{
LOG_I
(
PHY
,
"Found USRP B200
\n
"
);
args
+=
",num_send_frames=256,num_recv_frames=256, send_frame_size=15360, recv_frame_size=15360"
;
s
->
usrp
=
uhd
::
usrp
::
multi_usrp
::
make
(
args
);
device
->
type
=
USRP_B200_DEV
;
if
((
vers
==
3
)
&&
(
subvers
==
9
)
&&
(
subsubvers
>=
2
))
{
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_b210
;
bw_gain_adjust
=
0
;
}
else
{
openair0_cfg
[
0
].
rx_gain_calib_table
=
calib_table_b210_38
;
bw_gain_adjust
=
1
;
}
switch
((
int
)
openair0_cfg
[
0
].
sample_rate
)
{
case
30720000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
openair0_cfg
[
0
].
tx_sample_advance
=
115
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
case
23040000
:
s
->
usrp
->
set_master_clock_rate
(
23.04e6
);
//to be checked
openair0_cfg
[
0
].
tx_sample_advance
=
113
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
case
15360000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e06
);
openair0_cfg
[
0
].
tx_sample_advance
=
103
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
case
7680000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
openair0_cfg
[
0
].
tx_sample_advance
=
80
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
case
1920000
:
s
->
usrp
->
set_master_clock_rate
(
30.72e6
);
openair0_cfg
[
0
].
tx_sample_advance
=
40
;
openair0_cfg
[
0
].
tx_bw
=
20e6
;
openair0_cfg
[
0
].
rx_bw
=
20e6
;
break
;
default:
LOG_E
(
PHY
,
"Error: unknown sampling rate %f
\n
"
,
openair0_cfg
[
0
].
sample_rate
);
exit
(
-
1
);
break
;
}
}
openair0_cfg
[
0
].
iq_txshift
=
4
;
//shift
openair0_cfg
[
0
].
iq_rxrescale
=
15
;
//rescale iqs
for
(
int
i
=
0
;
i
<
s
->
usrp
->
get_rx_num_channels
();
i
++
)
{
if
(
i
<
openair0_cfg
[
0
].
rx_num_channels
)
{
s
->
usrp
->
set_rx_rate
(
openair0_cfg
[
0
].
sample_rate
,
i
);
...
...
@@ -870,6 +660,7 @@ extern "C" {
// display USRP settings
LOG_I
(
PHY
,
"Actual master clock: %fMHz...
\n
"
,
s
->
usrp
->
get_master_clock_rate
()
/
1e6
);
sleep
(
1
);
// create tx & rx streamer
uhd
::
stream_args_t
stream_args_rx
(
"sc16"
,
"sc16"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment