PlutoSDR: set FIR filter (1)

This commit is contained in:
f4exb 2017-09-07 08:49:22 +02:00
parent 5a05cf14bb
commit 7acd2bb7ed
2 changed files with 42 additions and 1 deletions

View File

@ -15,6 +15,7 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <iostream> #include <iostream>
#include <sstream>
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <regex> #include <regex>
@ -396,5 +397,38 @@ bool DevicePlutoSDRBox::parseSampleRates(const std::string& rateStr, SampleRates
} }
} }
void DevicePlutoSDRBox::set_filterBW(DeviceUse use, uint32_t intdec, uint32_t bw)
{
SampleRates sampleRates;
std::ostringstream ostr;
uint32_t nbTaps;
float normalizedBW;
if (use == USE_RX)
{
if (!getRxSampleRates(sampleRates)) {
return;
}
uint32_t nbGroups = sampleRates.m_addaConnvRate / 16;
nbTaps = nbGroups*8 > 128 ? 128 : nbGroups*8;
normalizedBW = ((float) bw) / sampleRates.m_hb1Rate;
normalizedBW = normalizedBW < 0.1 ? 0.1 : normalizedBW > 0.9 ? 0.9 : normalizedBW;
}
else
{
if (!getTxSampleRates(sampleRates)) {
return;
}
uint32_t nbGroups = sampleRates.m_addaConnvRate / 16;
nbTaps = nbGroups*8 > 128 ? 128 : nbGroups*8;
nbTaps = intdec == 1 ? (nbTaps > 64 ? 64 : nbTaps) : nbTaps;
normalizedBW = ((float) bw) / sampleRates.m_hb1Rate;
normalizedBW = normalizedBW < 0.1 ? 0.1 : normalizedBW > 0.9 ? 0.9 : normalizedBW;
}
}

View File

@ -31,6 +31,12 @@ public:
DEVICE_TX DEVICE_TX
} DeviceType; } DeviceType;
typedef enum
{
USE_RX,
USE_TX
} DeviceUse;
struct Sample { struct Sample {
int16_t i; int16_t i;
int16_t q; int16_t q;
@ -51,7 +57,6 @@ public:
void set_params(DeviceType devType, const std::vector<std::string> &params); void set_params(DeviceType devType, const std::vector<std::string> &params);
bool get_param(DeviceType devType, const std::string &param, std::string &value); bool get_param(DeviceType devType, const std::string &param, std::string &value);
void set_filter(const std::string &filterConfigStr);
bool openRx(); bool openRx();
bool openTx(); bool openTx();
void closeRx(); void closeRx();
@ -74,6 +79,7 @@ public:
char* txBufferFirst(); char* txBufferFirst();
bool getRxSampleRates(SampleRates& sampleRates); bool getRxSampleRates(SampleRates& sampleRates);
bool getTxSampleRates(SampleRates& sampleRates); bool getTxSampleRates(SampleRates& sampleRates);
void set_filterBW(DeviceUse use, uint32_t intdec, uint32_t bw);
private: private:
struct iio_context *m_ctx; struct iio_context *m_ctx;
@ -87,6 +93,7 @@ private:
bool m_valid; bool m_valid;
bool parseSampleRates(const std::string& rateStr, SampleRates& sampleRates); bool parseSampleRates(const std::string& rateStr, SampleRates& sampleRates);
void set_filter(const std::string &filterConfigStr);
}; };
#endif /* DEVICES_PLUTOSDR_DEVICEPLUTOSDRBOX_H_ */ #endif /* DEVICES_PLUTOSDR_DEVICEPLUTOSDRBOX_H_ */