Fixed rest of examples for new UHD driver

master
ismagom 9 years ago
parent efb331439e
commit a5b52179fa

@ -34,7 +34,6 @@
#include <sys/time.h>
#include <unistd.h>
#include <assert.h>
#include <signal.h>
#include "srslte/srslte.h"
#include "srslte/cuhd/cuhd.h"
@ -168,6 +167,8 @@ int main(int argc, char **argv) {
cuhd_set_rx_gain(uhd, 50);
}
cuhd_set_master_clock_rate(uhd, 30.72e6);
/* set receiver frequency */
cuhd_set_rx_freq(uhd, (double) prog_args.uhd_freq);
cuhd_rx_wait_lo_locked(uhd);
@ -183,17 +184,23 @@ int main(int argc, char **argv) {
}
/* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
/* Modify master clock rate for 15 Mhz */
if (cell.nof_prb == 75) {
cuhd_set_master_clock_rate(uhd, 23.04e6);
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate);
} else {
cuhd_set_master_clock_rate(uhd, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
}
} else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
exit(-1);
}
cuhd_set_rx_srate(uhd, (double) srate);
} else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
return SRSLTE_ERROR;
}
INFO("Stopping UHD and flushing buffer...\n",0);
cuhd_stop_rx_stream(uhd);

@ -165,6 +165,9 @@ int main(int argc, char **argv) {
}
cuhd_set_rx_gain(uhd, 50);
}
cuhd_set_master_clock_rate(uhd, 30.72e6);
// Supress UHD messages
cuhd_supress_stdout();

@ -490,6 +490,9 @@ int main(int argc, char **argv) {
}
#ifndef DISABLE_UHD
cuhd_set_master_clock_rate(uhd, 30.72e6);
if (!output_file_name) {
printf("Set TX rate: %.2f MHz\n",
cuhd_set_tx_srate(uhd, srslte_sampling_freq_hz(cell.nof_prb)) / 1000000);

@ -324,8 +324,7 @@ int main(int argc, char **argv) {
} while (ret == 0);
/* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb);
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate);

@ -312,6 +312,8 @@ int main(int argc, char **argv) {
exit(-1);
}
cuhd_set_master_clock_rate(uhd, 30.72e6);
/* Set receiver gain */
float x = cuhd_set_rx_gain(uhd, prog_args.uhd_rx_gain);
printf("Set RX gain to %.1f dB\n", x);
@ -342,18 +344,23 @@ cell.id = 1;
cell.nof_ports = 1;
/* set sampling frequency */
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
/* Modify master clock rate for 15 Mhz */
if (cell.nof_prb == 75) {
cuhd_set_master_clock_rate(uhd, 23.04e6);
int srate = srslte_sampling_freq_hz(cell.nof_prb);
if (srate != -1) {
if (srate < 10e6) {
cuhd_set_master_clock_rate(uhd, 4*srate);
} else {
cuhd_set_master_clock_rate(uhd, srate);
}
printf("Setting sampling rate %.2f MHz\n", (float) srate/1000000);
float srate_uhd = cuhd_set_rx_srate(uhd, (double) srate);
if (srate_uhd != srate) {
fprintf(stderr, "Could not set sampling rate\n");
exit(-1);
}
} else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
exit(-1);
}
cuhd_set_rx_srate(uhd, (double) srate);
cuhd_set_tx_srate(uhd, (double) srate);
} else {
fprintf(stderr, "Invalid number of PRB %d\n", cell.nof_prb);
exit(-1);
}
INFO("Stopping UHD and flushing buffer...\r",0);
cuhd_stop_rx_stream(uhd);

@ -122,6 +122,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening uhd\n");
exit(-1);
}
cuhd_set_master_clock_rate(uhd, 30.72e6);
printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
printf("Set RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, uhd_rate*1e6) / 1000000);

@ -123,6 +123,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening uhd\n");
exit(-1);
}
cuhd_set_master_clock_rate(uhd, 30.72e6);
printf("Set RX freq: %.6f MHz\n", cuhd_set_rx_freq(uhd, uhd_freq) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_gain));
printf("Set RX rate: %.6f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);

@ -126,6 +126,8 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error opening uhd\n");
exit(-1);
}
cuhd_set_master_clock_rate(uhd, 30.72e6);
printf("Subframe len: %d samples\n", flen);
printf("Set TX/RX rate: %.2f MHz\n", cuhd_set_rx_srate(uhd, srslte_sampling_freq_hz(nof_prb)) / 1000000);
printf("Set RX gain: %.1f dB\n", cuhd_set_rx_gain(uhd, uhd_rx_gain));

Loading…
Cancel
Save