kopia lustrzana https://github.com/f4exb/sdrangel
				
				
				
			PlutoSDR: set FIR filter (1)
							rodzic
							
								
									5a05cf14bb
								
							
						
					
					
						commit
						7acd2bb7ed
					
				| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
#include <cstdio>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
#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
 | 
			
		||||
    } 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<std::string> ¶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_ */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue