Close Call should be more accurate

Merged close call and wideband spectrum baseband processors
This commit is contained in:
furrtek
2017-02-01 08:53:26 +00:00
parent 064e097bc3
commit 8662ed4024
19 changed files with 143 additions and 254 deletions

View File

@@ -336,13 +336,6 @@ set(MODE_CPPSRC
)
DeclareTargets(PSPE wideband_spectrum)
### Close Call
set(MODE_CPPSRC
proc_closecall.cpp
)
DeclareTargets(PCLC closecall)
### OOK
set(MODE_CPPSRC

View File

@@ -64,6 +64,10 @@ BasebandThread::~BasebandThread() {
thread = nullptr;
}
void BasebandThread::set_sampling_rate(uint32_t new_sampling_rate) {
sampling_rate = new_sampling_rate;
}
void BasebandThread::run() {
baseband_sgpio.init();
baseband::dma::init();

View File

@@ -48,6 +48,8 @@ public:
baseband::Direction direction() const {
return _direction;
}
void set_sampling_rate(uint32_t new_sampling_rate);
private:
static Thread* thread;

View File

@@ -1,74 +0,0 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "proc_closecall.hpp"
#include "event_m4.hpp"
#include <cstdint>
#include <cstddef>
#include <array>
void CloseCallProcessor::execute(const buffer_c8_t& buffer) {
if( phase == 0 ) {
std::fill(spectrum.begin(), spectrum.end(), 0);
}
for(size_t i=0; i<spectrum.size(); i++) {
spectrum[i] += buffer.p[i + 0];
spectrum[i] += buffer.p[i + 1024];
}
if( phase == 20 ) {
const buffer_c16_t buffer_c16 {
spectrum.data(),
spectrum.size(),
buffer.sampling_rate
};
channel_spectrum.feed(
buffer_c16,
0, 0
);
phase = 0;
} else {
phase++;
}
}
void CloseCallProcessor::on_message(const Message* const message) {
switch(message->id) {
case Message::ID::UpdateSpectrum:
case Message::ID::SpectrumStreamingConfig:
channel_spectrum.on_message(message);
break;
default:
break;
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<CloseCallProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PROC_CLOSECALLPROCESSOR_H__
#define __PROC_CLOSECALLPROCESSOR_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include "spectrum_collector.hpp"
#include "message.hpp"
#include <cstddef>
#include <array>
#include <complex>
class CloseCallProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const message) override;
private:
BasebandThread baseband_thread { 3072000, this, NORMALPRIO + 20, baseband::Direction::Receive };
SpectrumCollector channel_spectrum { };
std::array<complex16_t, 256> spectrum { };
size_t phase = 0;
};
#endif/*__PROC_CLOSECALLPROCESSOR_H__*/

View File

@@ -69,7 +69,7 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
* -> FIR filter, <15kHz (0.156fs) pass, >19kHz (0.198fs) stop, gain of 1
* -> 48kHz int16_t[32] */
auto audio = audio_filter.execute(audio_2fs, work_audio_buffer);
/* -> 48kHz int16_t[32] */
audio_output.write(audio);
} else {

View File

@@ -80,7 +80,7 @@ private:
unsigned int c { 0 }, synth_acc { 0 };
uint32_t synth_div { 0 };
bool pwmrssi_enabled = false;
bool pwmrssi_enabled { false };
uint32_t pwmrssi_avg { 0 };
bool configured { false };

View File

@@ -33,6 +33,8 @@
void WidebandSpectrum::execute(const buffer_c8_t& buffer) {
// 2048 complex8_t samples per buffer.
// 102.4us per buffer. 20480 instruction cycles per buffer.
if (!configured) return;
if( phase == 0 ) {
std::fill(spectrum.begin(), spectrum.end(), 0);
@@ -45,7 +47,7 @@ void WidebandSpectrum::execute(const buffer_c8_t& buffer) {
spectrum[i] += buffer.p[i + 1024];
}
if( phase == 127 ) {
if( phase == trigger ) {
const buffer_c16_t buffer_c16 {
spectrum.data(),
spectrum.size(),
@@ -61,11 +63,20 @@ void WidebandSpectrum::execute(const buffer_c8_t& buffer) {
}
}
void WidebandSpectrum::on_message(const Message* const message) {
switch(message->id) {
void WidebandSpectrum::on_message(const Message* const msg) {
const WidebandSpectrumConfigMessage message = *reinterpret_cast<const WidebandSpectrumConfigMessage*>(msg);
switch(msg->id) {
case Message::ID::UpdateSpectrum:
case Message::ID::SpectrumStreamingConfig:
channel_spectrum.on_message(message);
channel_spectrum.on_message(msg);
break;
case Message::ID::WidebandSpectrumConfig:
baseband_fs = message.sampling_rate;
trigger = message.trigger;
baseband_thread.set_sampling_rate(baseband_fs);
configured = true;
break;
default:

View File

@@ -41,16 +41,18 @@ public:
void on_message(const Message* const message) override;
private:
static constexpr size_t baseband_fs = 20000000;
bool configured = false;
size_t baseband_fs = 20000000;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
RSSIThread rssi_thread { NORMALPRIO + 10 };
SpectrumCollector channel_spectrum { };
std::array<complex16_t, 256> spectrum { };
size_t phase = 0;
size_t phase = 0, trigger = 127;
};
#endif/*__PROC_WIDEBAND_SPECTRUM_H__*/