mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-24 08:44:44 +01:00
Partial RX888 source module
This commit is contained in:
parent
02ae50905d
commit
de3b056133
@ -54,6 +54,7 @@ private:
|
|||||||
_this->bandWidth = 16000;
|
_this->bandWidth = 16000;
|
||||||
_this->bandWidthMin = 8000;
|
_this->bandWidthMin = 8000;
|
||||||
_this->bandWidthMax = 16000;
|
_this->bandWidthMax = 16000;
|
||||||
|
_this->snapInterval = 10000;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_NFM, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_NFM, _this->bandWidth);
|
||||||
}
|
}
|
||||||
if (ImGui::RadioButton(CONCAT("WFM##_", _this->name), _this->demod == 1) && _this->demod != 1) {
|
if (ImGui::RadioButton(CONCAT("WFM##_", _this->name), _this->demod == 1) && _this->demod != 1) {
|
||||||
@ -61,6 +62,7 @@ private:
|
|||||||
_this->bandWidth = 200000;
|
_this->bandWidth = 200000;
|
||||||
_this->bandWidthMin = 100000;
|
_this->bandWidthMin = 100000;
|
||||||
_this->bandWidthMax = 200000;
|
_this->bandWidthMax = 200000;
|
||||||
|
_this->snapInterval = 100000;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_FM, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_FM, _this->bandWidth);
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
@ -69,6 +71,7 @@ private:
|
|||||||
_this->bandWidth = 12500;
|
_this->bandWidth = 12500;
|
||||||
_this->bandWidthMin = 1500;
|
_this->bandWidthMin = 1500;
|
||||||
_this->bandWidthMax = 12500;
|
_this->bandWidthMax = 12500;
|
||||||
|
_this->snapInterval = 1000;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_AM, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_AM, _this->bandWidth);
|
||||||
}
|
}
|
||||||
if (ImGui::RadioButton(CONCAT("DSB##_", _this->name), _this->demod == 3) && _this->demod != 3) {
|
if (ImGui::RadioButton(CONCAT("DSB##_", _this->name), _this->demod == 3) && _this->demod != 3) {
|
||||||
@ -76,6 +79,7 @@ private:
|
|||||||
_this->bandWidth = 6000;
|
_this->bandWidth = 6000;
|
||||||
_this->bandWidthMin = 3000;
|
_this->bandWidthMin = 3000;
|
||||||
_this->bandWidthMax = 6000;
|
_this->bandWidthMax = 6000;
|
||||||
|
_this->snapInterval = 1000;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_DSB, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_DSB, _this->bandWidth);
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
@ -84,6 +88,7 @@ private:
|
|||||||
_this->bandWidth = 3000;
|
_this->bandWidth = 3000;
|
||||||
_this->bandWidthMin = 1500;
|
_this->bandWidthMin = 1500;
|
||||||
_this->bandWidthMax = 3000;
|
_this->bandWidthMax = 3000;
|
||||||
|
_this->snapInterval = 1000;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_USB, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_USB, _this->bandWidth);
|
||||||
}
|
}
|
||||||
if (ImGui::RadioButton(CONCAT("CW##_", _this->name), _this->demod == 5) && _this->demod != 5) { _this->demod = 5; };
|
if (ImGui::RadioButton(CONCAT("CW##_", _this->name), _this->demod == 5) && _this->demod != 5) { _this->demod = 5; };
|
||||||
@ -93,6 +98,7 @@ private:
|
|||||||
_this->bandWidth = 3000;
|
_this->bandWidth = 3000;
|
||||||
_this->bandWidthMin = 1500;
|
_this->bandWidthMin = 1500;
|
||||||
_this->bandWidthMax = 3000;
|
_this->bandWidthMax = 3000;
|
||||||
|
_this->snapInterval = 1000;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_LSB, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_LSB, _this->bandWidth);
|
||||||
}
|
}
|
||||||
if (ImGui::RadioButton(CONCAT("RAW##_", _this->name), _this->demod == 7) && _this->demod != 7) {
|
if (ImGui::RadioButton(CONCAT("RAW##_", _this->name), _this->demod == 7) && _this->demod != 7) {
|
||||||
@ -100,9 +106,11 @@ private:
|
|||||||
_this->bandWidth = 10000;
|
_this->bandWidth = 10000;
|
||||||
_this->bandWidthMin = 3000;
|
_this->bandWidthMin = 3000;
|
||||||
_this->bandWidthMax = 10000;
|
_this->bandWidthMax = 10000;
|
||||||
|
_this->snapInterval = 1;
|
||||||
_this->sigPath.setDemodulator(SigPath::DEMOD_RAW, _this->bandWidth);
|
_this->sigPath.setDemodulator(SigPath::DEMOD_RAW, _this->bandWidth);
|
||||||
};
|
};
|
||||||
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", _this->name), false);
|
ImGui::Columns(1, CONCAT("EndRadioModeColumns##_", _this->name), false);
|
||||||
|
_this->sigPath.vfo->setSnapInterval(_this->snapInterval);
|
||||||
|
|
||||||
ImGui::EndGroup();
|
ImGui::EndGroup();
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"Radio": {
|
"Radio": {
|
||||||
"device": "Speakers (Realtek High Definiti",
|
"device": "Speakers (Realtek High Definiti",
|
||||||
"sampleRate": 48000.0,
|
"sampleRate": 48000.0,
|
||||||
"volume": 0.4888888895511627
|
"volume": 0.385185182094574
|
||||||
},
|
},
|
||||||
"Radio 1": {
|
"Radio 1": {
|
||||||
"device": "Speakers (Realtek High Definition Audio)",
|
"device": "Speakers (Realtek High Definition Audio)",
|
||||||
@ -20,8 +20,8 @@
|
|||||||
"bandPlanEnabled": true,
|
"bandPlanEnabled": true,
|
||||||
"defaultSink": "Audio",
|
"defaultSink": "Audio",
|
||||||
"fftHeight": 296,
|
"fftHeight": 296,
|
||||||
"frequency": 144751270,
|
"frequency": 7375000,
|
||||||
"max": -5.14705753326416,
|
"max": 0.0,
|
||||||
"maximized": true,
|
"maximized": true,
|
||||||
"menuOrder": [
|
"menuOrder": [
|
||||||
"Source",
|
"Source",
|
||||||
@ -33,7 +33,7 @@
|
|||||||
"Display"
|
"Display"
|
||||||
],
|
],
|
||||||
"menuWidth": 300,
|
"menuWidth": 300,
|
||||||
"min": -63.97058868408203,
|
"min": -63.235294342041016,
|
||||||
"showWaterfall": true,
|
"showWaterfall": true,
|
||||||
"source": "",
|
"source": "",
|
||||||
"sourceSettings": {},
|
"sourceSettings": {},
|
||||||
|
BIN
root_dev/recordings/baseband_20-36-00_12-11-2020.wav
Normal file
BIN
root_dev/recordings/baseband_20-36-00_12-11-2020.wav
Normal file
Binary file not shown.
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||||
|
|
||||||
|
#define ADC_RATE 32000000
|
||||||
|
#define XFER_TIMEOUT 5000
|
||||||
|
|
||||||
#define SEL0 (8) // SEL0 GPIO26
|
#define SEL0 (8) // SEL0 GPIO26
|
||||||
#define SEL1 (16) // SEL1 GPIO27
|
#define SEL1 (16) // SEL1 GPIO27
|
||||||
|
|
||||||
@ -33,7 +36,10 @@ public:
|
|||||||
|
|
||||||
Si5351init();
|
Si5351init();
|
||||||
|
|
||||||
sampleRate = 8000000;
|
decimation = 5;
|
||||||
|
sampleRate = (ADC_RATE >> (decimation - 1));
|
||||||
|
freq = sampleRate / 2;
|
||||||
|
|
||||||
|
|
||||||
handler.ctx = this;
|
handler.ctx = this;
|
||||||
handler.selectHandler = menuSelected;
|
handler.selectHandler = menuSelected;
|
||||||
@ -79,7 +85,7 @@ private:
|
|||||||
Bgpio[0] = 0x17 | SEL0 & (~SEL1);
|
Bgpio[0] = 0x17 | SEL0 & (~SEL1);
|
||||||
Bgpio[1] = 0x00;
|
Bgpio[1] = 0x00;
|
||||||
|
|
||||||
si5351aSetFrequency(sampleRate * 2, 0);
|
si5351aSetFrequency(ADC_RATE, 0);
|
||||||
fx3Control(GPIOFX3, Bgpio);
|
fx3Control(GPIOFX3, Bgpio);
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
@ -103,52 +109,101 @@ private:
|
|||||||
|
|
||||||
static void menuHandler(void* ctx) {
|
static void menuHandler(void* ctx) {
|
||||||
RX888SourceModule* _this = (RX888SourceModule*)ctx;
|
RX888SourceModule* _this = (RX888SourceModule*)ctx;
|
||||||
|
if (ImGui::InputInt("Decimation", &_this->decimation)) {
|
||||||
ImGui::Text("RX888 source");
|
_this->sampleRate = (ADC_RATE >> (_this->decimation - 1));
|
||||||
|
core::setInputSampleRate(_this->sampleRate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _worker(RX888SourceModule* _this) {
|
static void _worker(RX888SourceModule* _this) {
|
||||||
int blockSize = _this->sampleRate / 200.0f;
|
// Calculate hardware block siz
|
||||||
if ((blockSize % 2) != 0) { blockSize++; }
|
int realBlockSize = ADC_RATE / 200;
|
||||||
int flags = 0;
|
int i;
|
||||||
long long timeMs = 0;
|
for (i = 1; i < realBlockSize; i = (i << 1));
|
||||||
|
realBlockSize = (i >> 1);
|
||||||
|
int realDataSize = realBlockSize * sizeof(int16_t);
|
||||||
|
|
||||||
int16_t* buffer = new int16_t[blockSize * 2];
|
spdlog::info("Real block size: {0}", realBlockSize);
|
||||||
|
|
||||||
|
// Calculate software block size based on decimation
|
||||||
|
int blockSize = realBlockSize;
|
||||||
|
|
||||||
|
// Allocate buffers and state variables
|
||||||
|
int16_t* buffer = new int16_t[realBlockSize];
|
||||||
|
dsp::complex_t* iqbuffer = new dsp::complex_t[realBlockSize * 2];
|
||||||
|
lv_32fc_t phase = lv_cmake(1.0f, 0.0f);
|
||||||
|
|
||||||
|
// Initialize transfer
|
||||||
long pktSize = EndPt->MaxPktSize;
|
long pktSize = EndPt->MaxPktSize;
|
||||||
EndPt->SetXferSize(blockSize * 2);
|
EndPt->SetXferSize(realDataSize);
|
||||||
long ppx = blockSize * 2 / pktSize;
|
long ppx = realDataSize / pktSize;
|
||||||
|
|
||||||
OVERLAPPED inOvLap;
|
OVERLAPPED inOvLap;
|
||||||
inOvLap.hEvent = CreateEvent(NULL, false, false, NULL);
|
inOvLap.hEvent = CreateEvent(NULL, false, false, NULL);
|
||||||
auto context = EndPt->BeginDataXfer((PUCHAR)buffer, blockSize, &inOvLap);
|
auto context = EndPt->BeginDataXfer((PUCHAR)buffer, realBlockSize * 2, &inOvLap);
|
||||||
|
|
||||||
|
// Check weather the transfer begin was successful
|
||||||
|
if (EndPt->NtStatus || EndPt->UsbdStatus) {
|
||||||
|
spdlog::error("Xfer request rejected. 1 STATUS = {0} {1}", EndPt->NtStatus, EndPt->UsbdStatus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the USB chip
|
||||||
fx3Control(STARTFX3);
|
fx3Control(STARTFX3);
|
||||||
|
|
||||||
|
// Data loop
|
||||||
while (_this->running) {
|
while (_this->running) {
|
||||||
//if (_this->stream.aquire() < 0) { break; }
|
// Wait for the transfer to begin and about if timeout
|
||||||
|
LONG rLen = realBlockSize * 2;
|
||||||
|
if (!EndPt->WaitForXfer(&inOvLap, XFER_TIMEOUT)) {
|
||||||
LONG rLen = blockSize * 2;
|
|
||||||
if (!EndPt->WaitForXfer(&inOvLap, 5000)) {
|
|
||||||
spdlog::error("Transfer aborted");
|
spdlog::error("Transfer aborted");
|
||||||
EndPt->Abort();
|
EndPt->Abort();
|
||||||
if (EndPt->LastError == ERROR_IO_PENDING) {
|
if (EndPt->LastError == ERROR_IO_PENDING) {
|
||||||
WaitForSingleObject(inOvLap.hEvent, 5000);
|
WaitForSingleObject(inOvLap.hEvent, XFER_TIMEOUT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the incomming data is bulk I/Q and end transfer
|
||||||
if (EndPt->Attributes == 2) {
|
if (EndPt->Attributes == 2) {
|
||||||
if (EndPt->FinishDataXfer((PUCHAR)buffer, rLen, &inOvLap, context)) {
|
if (EndPt->FinishDataXfer((PUCHAR)buffer, rLen, &inOvLap, context)) {
|
||||||
spdlog::warn("{0}", rLen);
|
// Convert real data to I/Q data
|
||||||
|
for (int i = 0; i < realBlockSize; i++) {
|
||||||
|
iqbuffer[i].q = (float)buffer[i] / 32768.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the traslation frequency based on the tuning
|
||||||
|
float delta = -(_this->freq / (float)ADC_RATE) * 2.0f * FL_M_PI;
|
||||||
|
lv_32fc_t phaseDelta = lv_cmake(std::cos(delta), std::sin(delta));
|
||||||
|
|
||||||
|
// Apply translation
|
||||||
|
if (_this->stream.aquire() < 0) { break; }
|
||||||
|
volk_32fc_s32fc_x2_rotator_32fc((lv_32fc_t*)_this->stream.data, (lv_32fc_t*)iqbuffer, phaseDelta, &phase, realBlockSize);
|
||||||
|
|
||||||
|
// Decimate
|
||||||
|
blockSize = realBlockSize;
|
||||||
|
for (int d = 0; d < (_this->decimation - 1); d++) {
|
||||||
|
blockSize = (blockSize >> 1);
|
||||||
|
for (int i = 0; i < blockSize; i++) {
|
||||||
|
_this->stream.data[i].i = (_this->stream.data[i*2].i + _this->stream.data[(i*2)+1].i) * 0.5f;
|
||||||
|
_this->stream.data[i].q = (_this->stream.data[i*2].q + _this->stream.data[(i*2)+1].q) * 0.5f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context = EndPt->BeginDataXfer((PUCHAR)buffer, blockSize, &inOvLap);
|
// Write to output stream
|
||||||
|
_this->stream.write(blockSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start next transfer
|
||||||
|
context = EndPt->BeginDataXfer((PUCHAR)buffer, realBlockSize * 2, &inOvLap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop FX3 chip
|
||||||
|
fx3Control(STOPFX3);
|
||||||
|
|
||||||
|
// Deallocate buffers
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
|
delete[] iqbuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
@ -157,6 +212,7 @@ private:
|
|||||||
std::thread workerThread;
|
std::thread workerThread;
|
||||||
double freq;
|
double freq;
|
||||||
double sampleRate;
|
double sampleRate;
|
||||||
|
int decimation;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user