Improved close call precision

This commit is contained in:
furrtek 2016-05-13 01:18:04 +02:00
parent 7d193c3445
commit 9149508c83
23 changed files with 184 additions and 44 deletions

View File

@ -65,7 +65,7 @@ modules: $(TARGET_BASEBAND).bin $(TARGET_BASEBAND_TX).bin
cp $(PATH_BASEBAND_TX).bin ../sdcard/$(PATH_BASEBAND_TX).bin
$(TARGET).bin: modules $(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX)_inc.bin $(TARGET_APPLICATION).bin
$(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin
$(MAKE_SPI_IMAGE) $(TARGET_BOOTSTRAP).bin $(TARGET_HACKRF_FIRMWARE).dfu $(TARGET_BASEBAND_TX)_inc.bin $(TARGET_APPLICATION).bin $(TARGET).bin
$(TARGET_BOOTSTRAP).bin: $(TARGET_BOOTSTRAP).elf
$(CP) -O binary $(TARGET_BOOTSTRAP).elf $(TARGET_BOOTSTRAP).bin

View File

@ -86,6 +86,15 @@ void shutdown() {
shared_memory.baseband_queue.push(shutdown_message);
}
void spectrum_streaming_start(size_t decimation_factor) {
shared_memory.baseband_queue.push_and_wait(
SpectrumStreamingConfigMessage {
SpectrumStreamingConfigMessage::Mode::Running,
decimation_factor
}
);
}
void spectrum_streaming_start() {
shared_memory.baseband_queue.push_and_wait(
SpectrumStreamingConfigMessage {

View File

@ -55,6 +55,7 @@ void stop();
void shutdown();
void spectrum_streaming_start(size_t decimation_factor);
void spectrum_streaming_start();
void spectrum_streaming_stop();

View File

@ -66,7 +66,7 @@ private:
uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum };
int32_t vga_gain_db_ { 8 };
BasebandConfiguration baseband_configuration {
.mode = 0, /* TODO: Enum! */
.mode = 0,
.sampling_rate = 3072000,
.decimation_factor = 1,
};

View File

@ -24,10 +24,9 @@
#include "ui_receiver.hpp"
#include "ch.h"
#include "evtimer.h"
#include "time.hpp"
#include "event_m0.hpp"
#include "ff.h"
#include "hackrf_gpio.hpp"
#include "portapack.hpp"
#include "radio.hpp"
@ -50,6 +49,7 @@ void CloseCallView::focus() {
CloseCallView::~CloseCallView() {
receiver_model.disable();
time::signal_tick_second -= signal_token_tick_second;
}
void CloseCallView::do_detection() {
@ -224,7 +224,7 @@ void CloseCallView::on_show() {
}
);
baseband::spectrum_streaming_start();
baseband::spectrum_streaming_start(1);
}
void CloseCallView::on_hide() {
@ -286,7 +286,7 @@ void CloseCallView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db);
}
void CloseCallView::update_rate() {
void CloseCallView::on_tick_second() {
text_rate.set(to_string_dec_uint(scan_counter, 3));
scan_counter = 0;
}
@ -343,8 +343,8 @@ CloseCallView::CloseCallView(
};
};
field_frequency_max.set_value(receiver_model.tuning_frequency() + 5000000);
field_frequency_max.set_step(200000);
field_frequency_max.set_value(receiver_model.tuning_frequency() + 2000000);
field_frequency_max.set_step(100000);
field_frequency_max.on_change = [this](rf::Frequency f) {
(void) f;
this->on_range_changed();
@ -373,6 +373,10 @@ CloseCallView::CloseCallView(
nav.pop();
};
signal_token_tick_second = time::signal_tick_second += [this]() {
this->on_tick_second();
};
//audio::output::mute();
receiver_model.set_baseband_configuration({
.mode = toUType(ReceiverModel::Mode::CloseCall),

View File

@ -43,7 +43,7 @@
namespace ui {
#define CC_SLICE_WIDTH 5000000 //10000000
#define CC_SLICE_WIDTH 3000000 //10000000
#define CC_BIN_NB 236
#define CC_BIN_WIDTH CC_SLICE_WIDTH/CC_BIN_NB
@ -74,6 +74,7 @@ private:
uint8_t slicemax_db[32]; // Todo: Cap max slices !
uint8_t slicemax_idx[32];
uint8_t scan_counter;
SignalToken signal_token_tick_second;
bool ignore = true;
bool slicing;
bool locked = false;
@ -82,7 +83,7 @@ private:
void do_detection();
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void update_rate();
void on_tick_second();
/* |012345678901234567890123456789|
* | Min: Max: LNA VGA |

View File

@ -270,7 +270,7 @@ XylosView::XylosView(
receiver_code.set_value(1);
header_code_a.set_value(0);
header_code_b.set_value(0);
options_freq.set_selected_index(5);
options_freq.set_selected_index(6); // 5 ! DEBUG
checkbox_wcsubfamily.set_value(true);
checkbox_wcid.set_value(true);
@ -331,13 +331,15 @@ XylosView::XylosView(
button_transmit.set_style(&style_val);
button_txtest.on_select = [this,&transmitter_model](Button&) {
XylosView::upd_message();
button_txtest.on_select = [this](Button&) {
const uint8_t ccirtest[21] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,13,12,11,0xFF };
if (txing == false) {
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this,&transmitter_model](Message* const p) {
[this](Message* const p) {
const auto message = static_cast<const TXDoneMessage*>(p);
if (message->n == 25) {
audio::headphone::set_volume(volume_t::decibel(0 - 99) + audio::headphone::volume_range().max);
@ -364,14 +366,14 @@ XylosView::XylosView(
}
};
button_transmit.on_select = [this,&transmitter_model](Button&) {
button_transmit.on_select = [this](Button&) {
if (txing == false) {
upd_message();
EventDispatcher::message_map().unregister_handler(Message::ID::TXDone);
EventDispatcher::message_map().register_handler(Message::ID::TXDone,
[this,&transmitter_model](Message* const p) {
[this](Message* const p) {
uint8_t c;
char progress[21];
const auto message = static_cast<const TXDoneMessage*>(p);
@ -390,7 +392,7 @@ XylosView::XylosView(
journuit();
}
} else {
for (c=0;c<message->n;c++)
for (c=0;c<message->n;c++) // Todo: Use progressbar !
progress[c] = ' ';
progress[c] = '.';
progress[++c] = 0;

Binary file not shown.

View File

@ -85,7 +85,7 @@ void BasebandThread::run() {
const auto baseband_buffer = std::make_unique<std::array<baseband::sample_t, 8192>>();
baseband::dma::configure(
baseband_buffer->data(),
direction()
baseband::Direction::Transmit
);
//baseband::dma::allocate(4, 2048);
@ -98,7 +98,7 @@ void BasebandThread::run() {
while(true) {
// TODO: Place correct sampling rate into buffer returned here:
const auto buffer_tmp = baseband::dma::wait_for_rx_buffer();
const auto buffer_tmp = baseband::dma::wait_for_tx_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, baseband_configuration.sampling_rate
@ -139,8 +139,8 @@ void BasebandThread::disable() {
void BasebandThread::enable() {
if( baseband_processor ) {
baseband_sgpio.configure(direction());
baseband::dma::enable(direction());
baseband_sgpio.configure(baseband::Direction::Transmit);
baseband::dma::enable(baseband::Direction::Transmit);
baseband_sgpio.streaming_enable();
}
}

View File

@ -34,12 +34,6 @@ public:
void on_message(const Message* const message);
// This getter should die, it's just here to leak information to code that
// isn't in the right place to begin with.
baseband::Direction direction() const {
return baseband::Direction::Transmit;
}
void wait_for_switch(void);
Thread* thread_main { nullptr };

View File

@ -30,16 +30,11 @@
#include <cstdint>
// 1990 1131 1201 1275 1357 ...
// 14 13 12 11:
// 2108 989 2259 931
void XylosProcessor::execute(const buffer_c8_t& buffer) {
// This is called at 1536000/2048 = 750Hz
ai = 0;
// ai = 0;
for (size_t i = 0; i<buffer.count; i++) {
@ -65,7 +60,7 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
sample_count++;
}
aphase += ccir_phases[digit];
aphase += ccir_phases[digit]; // DEBUG
} else {
s++;
}
@ -73,15 +68,15 @@ void XylosProcessor::execute(const buffer_c8_t& buffer) {
sample = (sine_table_f32[(aphase & 0x03FF0000)>>18]*255);
// Audio preview sample generation: 1536000/48000 = 32
if (as >= 31) {
/*if (as >= 31) {
as = 0;
audio[ai++] = sample * 128;
} else {
as++;
}
}*/
//FM
frq = sample * 300; // ~10kHz wide
frq = sample * 1000; // ~10kHz wide
phase = (phase + frq);
sphase = phase + (256<<16);

View File

@ -39,10 +39,10 @@ public:
void execute(const buffer_c8_t& buffer) override;
private:
int16_t audio_data[64];
/*int16_t audio_data[64];
std::array<int16_t, 64> audio;
/*const buffer_s16_t audio_buffer {
const buffer_s16_t audio_buffer {
audio.data(),
audio.size()
};*/
@ -75,7 +75,7 @@ private:
int32_t sample, frq;
TXDoneMessage message;
AudioOutput audio_output;
//AudioOutput audio_output;
};
#endif

Binary file not shown.

View File

@ -144,6 +144,7 @@ CPPSRC = main.cpp \
proc_wfm_audio.cpp \
proc_ais.cpp \
proc_wideband_spectrum.cpp \
proc_closecall.cpp \
proc_tpms.cpp \
proc_ert.cpp \
proc_capture.cpp \

View File

@ -36,6 +36,7 @@
#include "proc_wfm_audio.hpp"
#include "proc_ais.hpp"
#include "proc_wideband_spectrum.hpp"
#include "proc_closecall.hpp"
#include "proc_tpms.hpp"
#include "proc_ert.hpp"
#include "proc_capture.hpp"
@ -132,7 +133,7 @@ BasebandProcessor* BasebandThread::create_processor(const int32_t mode) {
case 5: return new TPMSProcessor();
case 6: return new ERTProcessor();
case 7: return new CaptureProcessor();
case 10: return new WidebandSpectrum(); // Close call
case 10: return new CloseCallProcessor();
default: return nullptr;
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
*
* 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) {
// 2048 complex8_t samples per buffer.
// 102.4us per buffer. 20480 instruction cycles per buffer.
if( phase == 0 ) {
std::fill(spectrum.begin(), spectrum.end(), 0);
}
for(size_t i=0; i<spectrum.size(); i++) {
// TODO: Removed window-presum windowing, due to lack of available code RAM.
// TODO: Apply window to improve spectrum bin sidelobes.
spectrum[i] += buffer.p[i + 0];
spectrum[i] += buffer.p[i + 1024];
}
if( phase == 127 ) {
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;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
*
* 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 "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:
SpectrumCollector channel_spectrum;
std::array<complex16_t, 256> spectrum;
size_t phase = 0;
};
#endif/*__PROC_CLOSECALLPROCESSOR_H__*/

View File

@ -47,6 +47,7 @@ void SpectrumCollector::on_message(const Message* const message) {
}
void SpectrumCollector::set_state(const SpectrumStreamingConfigMessage& message) {
set_decimation_factor(message.decimation_factor);
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
start();
} else {

View File

@ -241,11 +241,22 @@ public:
constexpr SpectrumStreamingConfigMessage(
Mode mode
) : Message { ID::SpectrumStreamingConfig },
mode { mode }
mode { mode },
decimation_factor { 1 }
{
}
constexpr SpectrumStreamingConfigMessage(
Mode mode,
size_t decimation_factor
) : Message { ID::SpectrumStreamingConfig },
mode { mode },
decimation_factor { decimation_factor }
{
}
Mode mode { Mode::Stopped };
size_t decimation_factor = 1;
};
struct ChannelSpectrum {

View File

@ -1,2 +1,2 @@
const char md5_baseband[16] = {0x1a,0x50,0xbc,0xc5,0xf4,0x5a,0x50,0x1b,0x3f,0x88,0x4c,0xb5,0xb3,0x95,0xa9,0x4d,};
const char md5_baseband_tx[16] = {0xf6,0x31,0x51,0xa5,0x0a,0xb1,0x36,0xf8,0xbe,0x4e,0xe2,0x7b,0x84,0xfc,0x62,0xac,};
const char md5_baseband[16] = {0x07,0xff,0xf6,0x7f,0x06,0x02,0xd1,0xd7,0x67,0x8f,0x67,0xdc,0xe8,0x36,0xa9,0xc0,};
const char md5_baseband_tx[16] = {0xe9,0xeb,0x30,0xea,0x3f,0xf5,0xea,0x93,0xf9,0x62,0x1e,0x9c,0x5f,0x29,0xa7,0x95,};

Binary file not shown.

Binary file not shown.

Binary file not shown.