class zcu111Device : public SoapySDR::Device
{
public:
XRFdc_Config myDevice_Config;
zcu111Device(void)
{
rfdc_inst_init(RFDC_DEVICE_ID);
return;
}
std::string getDriverKey(void) const
{
return "zcu111";
}
std::string getHardwareKey(void) const
{
return "XCZU28DR";
}
std::string getVendorInfo(void) const
{
return "IISc 5G Lab";
}
SoapySDR::Kwargs getHardwareInfo(void) const
{
//key/value pairs for any useful information
//this also gets printed in --probe
SoapySDR::Kwargs args;
args["Developer"] = "IISc 5G Lab";
args["Device ID"] = (std::to_string)(myDevice_Config.DeviceId); //"ZCU111 RFSoC";
args["RFDC Version"] = (std::to_string)(XRFdc_GetDriverVersion());
args["RFSoC Driver Ver"] = (std::to_string)(rfsocDriver_show_version());
return args;
}
/*******************************************************************
* Antenna API
******************************************************************/
std::vector<std::string> listAntennas(const int direction, const size_t channel) const
{
std::vector<std::string> antennas;
//std::ignore = direction;
//std::ignore = channel;
if (direction == SOAPY_SDR_RX) {
antennas.push_back("RX");
//return antennas;
}
if (direction == SOAPY_SDR_TX) {
antennas.push_back("TX");
//return antennas;
}
return antennas;
}
void setAntenna(const int direction, const size_t channel, const std::string &name)
{
std::ignore = direction;
std::ignore = channel;
std::ignore = name;
if (direction != (SOAPY_SDR_RX || SOAPY_SDR_TX))
{
throw std::runtime_error("ZCU111 Device - setAntena failed: Only RX and TX are supported");
}
}
std::string getAntenna(const int direction, const size_t channel) const
{
//std::ignore = direction;
std::ignore = channel;
if(direction == SOAPY_SDR_RX)
return "RX";
if(direction == SOAPY_SDR_TX)
return "TX";
}
/*******************************************************************
* Gain API
******************************************************************/
std::vector<std::string> listGains(const int direction, const size_t channel) const
{
//list available gain elements,
//the functions below have a "name" parameter
std::vector<std::string> results;
std::ignore = direction;
std::ignore = channel;
results.push_back("zcu111GainList");
return results;
}
bool hasGainMode(const int direction, const size_t channel) const
{
//This part of the API is meant for AGC and the AGC is not supported in current FPGA design - Sudhakar
std::ignore = direction;
std::ignore = channel;
return false; //default is false
}
void setGain(const int direction, const size_t channel, const double value){
//Part of QMC settings.
u32 Type;
printf("\n-----------setGain API--------------\n My received direction: %d \n", direction);
printf("My received channel: %d \n", channel);
printf("My gain value: %f \n", value);
(direction == SOAPY_SDR_TX) ? (Type = 1) : (Type = 0); //0 = ADC, 1=DAC
changeGain(value, Type, 1, 1); //int changeGain(double new_gain_value, u32 Type, u32 Tile_Id, u32 Block_Id)
}
/*!
* Get the overall value of the gain elements in a chain.
* \param direction the channel direction RX or TX
* \param channel an available channel on the device
* \return the value of the gain in dB
*/
double getGain(const int direction, const size_t channel) const{
std::ignore = direction;
std::ignore = channel;
return 0.0;
}
/*!
* Get the overall range of possible gain values.
* \param direction the channel direction RX or TX
* \param channel an available channel on the device
* \return a list of gain ranges in dB
*/
SoapySDR::Range getGainRange(const int direction, const size_t channel) const{
//Part of QMC Settings.
std::ignore = direction;
std::ignore = channel;
SoapySDR::Range gainRange;
return gainRange;
}
/*******************************************************************
* Frequency API
******************************************************************/
double getFrequency(const int direction, const size_t channel) const
{
std::ignore = direction;
std::ignore = channel;
return 433e6;
}
void setFrequency(const int direction, const size_t channel, const double frequency, const SoapySDR::Kwargs &args = SoapySDR::Kwargs())
{
printf("\n-----------setFreq. API--------------\n My received direction: %d \n", direction);
printf("My received channel: %d \n", channel);
printf("My Center frequency value: %f \n", frequency);
//SetMixerSettings(frequency, 1, 1, 1);
}
std::vector<std::string> listFrequencies(const int direction, const size_t channel) const
{
std::vector<std::string> names;
std::ignore = direction;
std::ignore = channel;
names.push_back("zcu111FreqList");
return names;
}
SoapySDR::RangeList getFrequencyRange(const int direction, const size_t channel, const std::string &name) const
{
std::ignore = direction;
std::ignore = channel;
std::ignore = name;
SoapySDR::RangeList results;
results.push_back(SoapySDR::Range(0, 4e09));
return results;
}
/*******************************************************************
* Sample Rate API
******************************************************************/
double getSampleRate(const int direction, const size_t channel) const
{
std::ignore = direction;
std::ignore = channel;
return 433e6;
}
std::vector<double> listSampleRates(const int direction, const size_t channel) const
{
std::vector<double> results;
std::ignore = direction;
std::ignore = channel;
results.push_back(0.0);
return results;
}
void setSampleRate(const int direction, const size_t channel, const double rate)
{
printf("\n ------- setSampleRate. API -------- \n My received direction: %d \n", direction);
printf("My received channel: %u \n", channel);
printf("Recd Sampling Rate: %f \n\n", rate);
}
/************************************************************
* Sensor API
* **********************************************************/
size_t getNumChannels(const int direction) const
{
//ZCU111_Device only supports RX.
return (direction == SOAPY_SDR_RX) ? 1 : 0;
}
std::vector<std::string> listSensors(void) const
{
std::vector<std::string> listsensor;
listsensor.push_back("zcu111Device_Sensor");
return listsensor;
}
SoapySDR::ArgInfo getSensorInfo(const std::string &key) const
{
std::ignore = key;
SoapySDR::ArgInfo bufflenArg;
bufflenArg.key = "zcu111";
bufflenArg.value = std::to_string(0);
bufflenArg.name = "zcu111";
return bufflenArg;
}
std::string readSensor(const std::string &key) const
{
std::ignore = key;
return std::to_string(0);
}
/*******************************************************************
* Stream API
******************************************************************/
std::vector<std::string> getStreamFormats(const int direction, const size_t channel) const
{
std::vector<std::string> formats;
std::ignore = direction;
std::ignore = channel;
formats.push_back(SOAPY_SDR_CF32); //complex float32 (8 bytes per element)
formats.push_back(SOAPY_SDR_CS12); // complex int12 (3 bytes per element)
formats.push_back(SOAPY_SDR_CS16); //complex int16 (4 bytes per element)
return formats;
}
std::string getNativeStreamFormat(const int direction, const size_t channel, double &fullScale) const
{
//std::ignore = direction;
//std::ignore = channel;
fullScale = 128;
return "SOAPY_SDR_CS16";
}
SoapySDR::ArgInfoList getStreamArgsInfo(const int direction, const size_t channel) const
{
std::ignore = channel;
if (direction != SOAPY_SDR_RX) {
throw std::runtime_error("ZCU111 Device is RX only");
}
SoapySDR::ArgInfoList streamArgs;
SoapySDR::ArgInfo bufflenArg;
bufflenArg.key = "bufflen";
bufflenArg.value = std::to_string(1);
bufflenArg.name = "Buffer Size";
bufflenArg.units = "bytes";
bufflenArg.type = SoapySDR::ArgInfo::INT;
streamArgs.push_back(bufflenArg);
return streamArgs;