2018-03-27 17:35:53 +00:00
|
|
|
/*!
|
|
|
|
* \file ad9361_manager.h
|
|
|
|
* \brief An Analog Devices AD9361 front-end configuration library wrapper for configure some functions via iiod link.
|
|
|
|
* \author Javier Arribas, jarribas(at)cttc.es
|
|
|
|
*
|
|
|
|
* This file contains information taken from librtlsdr:
|
2020-02-05 20:24:46 +00:00
|
|
|
* https://git.osmocom.org/rtl-sdr
|
2018-03-27 17:35:53 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2018-03-27 17:35:53 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2018-03-27 17:35:53 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2018-03-27 17:35:53 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2018-03-27 17:35:53 +00:00
|
|
|
*/
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_AD9361_MANAGER_H
|
|
|
|
#define GNSS_SDR_AD9361_MANAGER_H
|
2018-03-27 17:35:53 +00:00
|
|
|
|
2019-09-13 06:56:37 +00:00
|
|
|
#include <iio.h>
|
2018-08-11 12:31:35 +00:00
|
|
|
#include <cstdint>
|
2018-03-27 17:35:53 +00:00
|
|
|
#include <string>
|
|
|
|
|
2020-11-01 12:37:19 +00:00
|
|
|
/** \addtogroup Signal_Source
|
|
|
|
* \{ */
|
|
|
|
/** \addtogroup Signal_Source_libs signal_source_libs
|
|
|
|
* Library with utilities for signal sources.
|
|
|
|
* \{ */
|
|
|
|
|
2019-10-09 07:18:29 +00:00
|
|
|
#define FIR_BUF_SIZE 8192
|
2018-03-27 17:35:53 +00:00
|
|
|
|
|
|
|
/* RX is input, TX is output */
|
2018-03-27 19:10:31 +00:00
|
|
|
enum iodev
|
|
|
|
{
|
|
|
|
RX,
|
|
|
|
TX
|
|
|
|
};
|
2018-03-27 17:35:53 +00:00
|
|
|
|
|
|
|
/* common RX and TX streaming params */
|
2018-03-27 19:10:31 +00:00
|
|
|
struct stream_cfg
|
|
|
|
{
|
2019-10-09 07:18:29 +00:00
|
|
|
int64_t bw_hz; // Analog bandwidth in Hz
|
2018-08-11 12:31:35 +00:00
|
|
|
int64_t fs_hz; // Baseband sample rate in Hz
|
|
|
|
int64_t lo_hz; // Local oscillator frequency in Hz
|
2018-03-27 19:10:31 +00:00
|
|
|
const char *rfport; // Port name
|
2018-03-27 17:35:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* check return value of attr_write function */
|
2018-03-27 19:10:31 +00:00
|
|
|
void errchk(int v, const char *what);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
2018-08-11 12:31:35 +00:00
|
|
|
/* write attribute: int64_t int */
|
|
|
|
void wr_ch_lli(struct iio_channel *chn, const char *what, int64_t val);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
|
|
|
/* write attribute: string */
|
2018-03-27 19:10:31 +00:00
|
|
|
void wr_ch_str(struct iio_channel *chn, const char *what, const char *str);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
|
|
|
/* returns ad9361 phy device */
|
2018-03-27 19:10:31 +00:00
|
|
|
struct iio_device *get_ad9361_phy(struct iio_context *ctx);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
|
|
|
/* finds AD9361 streaming IIO devices */
|
|
|
|
bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_device **dev);
|
|
|
|
|
|
|
|
/* finds AD9361 streaming IIO channels */
|
|
|
|
bool get_ad9361_stream_ch(struct iio_context *ctx, enum iodev d, struct iio_device *dev, int chid, struct iio_channel **chn);
|
|
|
|
|
|
|
|
/* finds AD9361 phy IIO configuration channel with id chid */
|
|
|
|
bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_channel **chn);
|
|
|
|
|
|
|
|
/* finds AD9361 local oscillator IIO configuration channels */
|
|
|
|
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);
|
|
|
|
|
2018-08-11 12:31:35 +00:00
|
|
|
bool config_ad9361_rx_local(uint64_t bandwidth_,
|
|
|
|
uint64_t sample_rate_,
|
|
|
|
uint64_t freq_,
|
2018-12-11 00:56:25 +00:00
|
|
|
const std::string &rf_port_select_,
|
2019-10-13 21:38:06 +00:00
|
|
|
bool rx1_enable_,
|
|
|
|
bool rx2_enable_,
|
2018-12-11 00:56:25 +00:00
|
|
|
const std::string &gain_mode_rx1_,
|
|
|
|
const std::string &gain_mode_rx2_,
|
2018-03-27 19:10:31 +00:00
|
|
|
double rf_gain_rx1_,
|
2019-10-06 17:07:24 +00:00
|
|
|
double rf_gain_rx2_,
|
|
|
|
bool quadrature_,
|
|
|
|
bool rfdc_,
|
2019-10-09 18:50:06 +00:00
|
|
|
bool bbdc_,
|
2019-10-09 20:08:08 +00:00
|
|
|
std::string filter_source_,
|
2019-10-09 18:50:06 +00:00
|
|
|
std::string filter_filename_,
|
|
|
|
float Fpass_,
|
|
|
|
float Fstop_);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
2018-12-11 00:56:25 +00:00
|
|
|
bool config_ad9361_rx_remote(const std::string &remote_host,
|
2018-08-11 12:31:35 +00:00
|
|
|
uint64_t bandwidth_,
|
|
|
|
uint64_t sample_rate_,
|
|
|
|
uint64_t freq_,
|
2018-12-11 00:56:25 +00:00
|
|
|
const std::string &rf_port_select_,
|
2019-10-13 21:38:06 +00:00
|
|
|
bool rx1_enable_,
|
|
|
|
bool rx2_enable_,
|
2018-12-11 00:56:25 +00:00
|
|
|
const std::string &gain_mode_rx1_,
|
|
|
|
const std::string &gain_mode_rx2_,
|
2018-03-27 19:10:31 +00:00
|
|
|
double rf_gain_rx1_,
|
2019-10-06 17:07:24 +00:00
|
|
|
double rf_gain_rx2_,
|
|
|
|
bool quadrature_,
|
|
|
|
bool rfdc_,
|
2019-10-09 20:08:08 +00:00
|
|
|
bool bbdc_,
|
|
|
|
std::string filter_source_,
|
|
|
|
std::string filter_filename_,
|
|
|
|
float Fpass_,
|
|
|
|
float Fstop_);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
2018-08-11 12:31:35 +00:00
|
|
|
bool config_ad9361_lo_local(uint64_t bandwidth_,
|
|
|
|
uint64_t sample_rate_,
|
|
|
|
uint64_t freq_rf_tx_hz_,
|
2018-03-27 19:10:31 +00:00
|
|
|
double tx_attenuation_db_,
|
2018-08-11 12:31:35 +00:00
|
|
|
int64_t freq_dds_tx_hz_,
|
2019-10-08 10:57:37 +00:00
|
|
|
double scale_dds_dbfs_,
|
|
|
|
double phase_dds_deg_);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
2018-12-11 00:56:25 +00:00
|
|
|
bool config_ad9361_lo_remote(const std::string &remote_host,
|
2018-08-11 12:31:35 +00:00
|
|
|
uint64_t bandwidth_,
|
|
|
|
uint64_t sample_rate_,
|
|
|
|
uint64_t freq_rf_tx_hz_,
|
2018-03-27 19:10:31 +00:00
|
|
|
double tx_attenuation_db_,
|
2018-08-11 12:31:35 +00:00
|
|
|
int64_t freq_dds_tx_hz_,
|
2019-10-08 10:57:37 +00:00
|
|
|
double scale_dds_dbfs_,
|
|
|
|
double phase_dds_deg_);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
2018-12-11 00:56:25 +00:00
|
|
|
bool ad9361_disable_lo_remote(const std::string &remote_host);
|
2018-03-27 17:35:53 +00:00
|
|
|
|
|
|
|
bool ad9361_disable_lo_local();
|
|
|
|
|
2019-10-08 17:34:18 +00:00
|
|
|
bool load_fir_filter(std::string &filter, struct iio_device *phy);
|
|
|
|
|
2019-10-13 21:38:06 +00:00
|
|
|
bool disable_ad9361_rx_local();
|
|
|
|
|
|
|
|
bool disable_ad9361_rx_remote(const std::string &remote_host);
|
|
|
|
|
2020-11-01 12:37:19 +00:00
|
|
|
|
|
|
|
/** \} */
|
|
|
|
/** \} */
|
2020-02-08 09:10:46 +00:00
|
|
|
#endif // GNSS_SDR_AD9361_MANAGER_H
|