1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-11-08 19:23:07 +00:00

Merge Next with FPGA. Adding software-defined emulation of the sample counter

This commit is contained in:
Javier Arribas
2018-04-06 17:03:20 +02:00
265 changed files with 21296 additions and 20425 deletions

View File

@@ -32,7 +32,9 @@
#include "fmcomms2_signal_source.h"
#include "configuration_interface.h"
#include "gnss_sdr_valve.h"
#include "ad9361_manager.h"
#include "GPS_L1_CA.h"
#include "GPS_L2C.h"
#include <glog/logging.h>
#include <iostream>
@@ -55,6 +57,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
quadrature_ = configuration->property(role + ".quadrature", true);
rf_dc_ = configuration->property(role + ".rf_dc", true);
bb_dc_ = configuration->property(role + ".bb_dc", true);
RF_channels_ = configuration->property(role + ".RF_channels", 1);
gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual"));
gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual"));
rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0);
@@ -67,6 +70,14 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
dump_ = configuration->property(role + ".dump", false);
dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file);
//AD9361 Local Oscillator generation for dual band operation
enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false);
freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000);
freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000);
scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0);
phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0);
tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0);
item_size_ = sizeof(gr_complex);
std::cout << "device address: " << uri_ << std::endl;
@@ -75,15 +86,73 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
if (item_type_.compare("gr_complex") == 0)
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
if (RF_channels_ == 1)
{
if (rx1_en_ and rx2_en_)
{
LOG(FATAL) << "Configuration error: both rx1 and rx2 are enabled but RF_channels=1 !";
}
else
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
if (enable_dds_lo_ == true)
{
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
}
}
}
else if (RF_channels_ == 2)
{
if (!(rx1_en_ and rx2_en_))
{
LOG(FATAL) << "Configuration error: RF_channels=2 but are not enabled both receivers in FMCOMMS2 !";
}
else
{
fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make(
uri_.c_str(), freq_, sample_rate_,
bandwidth_,
rx1_en_, rx2_en_,
buffer_size_, quadrature_, rf_dc_,
bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_,
gain_mode_rx2_.c_str(), rf_gain_rx2_,
rf_port_select_.c_str(), filter_file_.c_str(),
filter_auto_);
//configure LO
if (enable_dds_lo_ == true)
{
std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n";
config_ad9361_lo_remote(uri_,
bandwidth_,
sample_rate_,
freq_rf_tx_hz_,
tx_attenuation_db_,
freq_dds_tx_hz_,
scale_dds_dbfs_);
}
}
}
else
{
LOG(FATAL) << "Configuration error: Unsupported number of RF_channels !";
}
}
else
{
@@ -108,6 +177,10 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration
Fmcomms2SignalSource::~Fmcomms2SignalSource()
{
if (enable_dds_lo_ == true)
{
ad9361_disable_lo_remote(uri_);
}
}

View File

@@ -88,6 +88,7 @@ private:
bool quadrature_;
bool rf_dc_;
bool bb_dc_;
int RF_channels_;
std::string gain_mode_rx1_;
std::string gain_mode_rx2_;
double rf_gain_rx1_;
@@ -96,6 +97,14 @@ private:
std::string filter_file_;
bool filter_auto_;
//DDS configuration for LO generation for external mixer
bool enable_dds_lo_;
unsigned long freq_rf_tx_hz_;
unsigned long freq_dds_tx_hz_;
double scale_dds_dbfs_;
double phase_dds_deg_;
double tx_attenuation_db_;
unsigned int in_stream_;
unsigned int out_stream_;

View File

@@ -55,7 +55,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
dump_filename_ = configuration->property(role + ".dump_filename",
default_dump_file);
// rtl_tcp PARAMTERS
// rtl_tcp PARAMETERS
std::string default_address = "127.0.0.1";
short default_port = 1234;
AGC_enabled_ = configuration->property(role + ".AGC_enabled", true);

View File

@@ -121,7 +121,7 @@ unpack_2bit_samples::unpack_2bit_samples(bool big_endian_bytes,
bool big_endian_system = systemIsBigEndian();
// Only swap the item bytes if the item size > 1 byte and the system
// endianess is not the same as the item endianness:
// endianness is not the same as the item endianness:
swap_endian_items_ = (item_size_ > 1) &&
(big_endian_system != big_endian_items);

File diff suppressed because it is too large Load Diff

View File

@@ -30,8 +30,8 @@
* -------------------------------------------------------------------------
*/
#ifndef __AD9361_MANAGER__
#define __AD9361_MANAGER__
#ifndef GNSS_SDR_AD9361_MANAGER_H
#define GNSS_SDR_AD9361_MANAGER_H
#include <string>
@@ -42,31 +42,36 @@
#endif
/* RX is input, TX is output */
enum iodev { RX, TX };
enum iodev
{
RX,
TX
};
/* common RX and TX streaming params */
struct stream_cfg {
long long bw_hz; // Analog banwidth in Hz
long long fs_hz; // Baseband sample rate in Hz
long long lo_hz; // Local oscillator frequency in Hz
const char* rfport; // Port name
struct stream_cfg
{
long long bw_hz; // Analog banwidth in Hz
long long fs_hz; // Baseband sample rate in Hz
long long lo_hz; // Local oscillator frequency in Hz
const char *rfport; // Port name
};
/* check return value of attr_write function */
void errchk(int v, const char* what);
void errchk(int v, const char *what);
/* write attribute: long long int */
void wr_ch_lli(struct iio_channel *chn, const char* what, long long val);
void wr_ch_lli(struct iio_channel *chn, const char *what, long long val);
/* write attribute: string */
void wr_ch_str(struct iio_channel *chn, const char* what, const char* str);
void wr_ch_str(struct iio_channel *chn, const char *what, const char *str);
/* helper function generating channel names */
char* get_ch_name(const char* type, int id, char* tmpstr);
char *get_ch_name(const char *type, int id, char *tmpstr);
/* returns ad9361 phy device */
struct iio_device* get_ad9361_phy(struct iio_context *ctx);
struct iio_device *get_ad9361_phy(struct iio_context *ctx);
/* finds AD9361 streaming IIO devices */
bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_device **dev);
@@ -83,45 +88,43 @@ bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn
/* applies streaming configuration through IIO */
bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid);
bool config_ad9361_rx_local(unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
bool config_ad9361_rx_remote(std::string remote_host,
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_,
std::string rf_port_select_,
std::string gain_mode_rx1_,
std::string gain_mode_rx2_,
double rf_gain_rx1_,
double rf_gain_rx2_);
bool config_ad9361_lo_local(unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
bool config_ad9361_lo_remote(std::string remote_host,
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
unsigned long bandwidth_,
unsigned long sample_rate_,
unsigned long freq_rf_tx_hz_,
double tx_attenuation_db_,
long long freq_dds_tx_hz_,
double scale_dds_dbfs_);
bool ad9361_disable_lo_remote(std::string remote_host);
bool ad9361_disable_lo_local();
#endif