diff --git a/devices/plutosdr/deviceplutosdrbox.cpp b/devices/plutosdr/deviceplutosdrbox.cpp index 57dbcf640..92d48dc57 100644 --- a/devices/plutosdr/deviceplutosdrbox.cpp +++ b/devices/plutosdr/deviceplutosdrbox.cpp @@ -15,6 +15,7 @@ /////////////////////////////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -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; + } +} + diff --git a/devices/plutosdr/deviceplutosdrbox.h b/devices/plutosdr/deviceplutosdrbox.h index e9f0d65eb..d6922e3d4 100644 --- a/devices/plutosdr/deviceplutosdrbox.h +++ b/devices/plutosdr/deviceplutosdrbox.h @@ -31,6 +31,12 @@ public: DEVICE_TX } DeviceType; + typedef enum + { + USE_RX, + USE_TX + } DeviceUse; + struct Sample { int16_t i; int16_t q; @@ -51,7 +57,6 @@ public: void set_params(DeviceType devType, const std::vector ¶ms); bool get_param(DeviceType devType, const std::string ¶m, std::string &value); - void set_filter(const std::string &filterConfigStr); bool openRx(); bool openTx(); void closeRx(); @@ -74,6 +79,7 @@ public: char* txBufferFirst(); bool getRxSampleRates(SampleRates& sampleRates); bool getTxSampleRates(SampleRates& sampleRates); + void set_filterBW(DeviceUse use, uint32_t intdec, uint32_t bw); private: struct iio_context *m_ctx; @@ -87,6 +93,7 @@ private: bool m_valid; bool parseSampleRates(const std::string& rateStr, SampleRates& sampleRates); + void set_filter(const std::string &filterConfigStr); }; #endif /* DEVICES_PLUTOSDR_DEVICEPLUTOSDRBOX_H_ */