mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
PlutoSDR: set FIR filter (1)
This commit is contained in:
parent
5a05cf14bb
commit
7acd2bb7ed
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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> ¶ms);
|
void set_params(DeviceType devType, const std::vector<std::string> ¶ms);
|
||||||
bool get_param(DeviceType devType, const std::string ¶m, std::string &value);
|
bool get_param(DeviceType devType, const std::string ¶m, 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_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user