Merge remote-tracking branch 'upstream/master'

# Conflicts:
#	firmware/application/bitmap.hpp
#	firmware/application/receiver_model.cpp
#	firmware/application/receiver_model.hpp
#	firmware/application/touch.hpp
#	firmware/application/ui_setup.cpp
#	firmware/baseband/proc_ais.hpp
#	firmware/baseband/proc_ert.hpp
#	firmware/bootstrap/CMakeLists.txt
#	firmware/common/portapack_persistent_memory.cpp
#	firmware/common/portapack_persistent_memory.hpp
This commit is contained in:
furrtek
2016-08-17 02:55:34 +02:00
43 changed files with 1089 additions and 543 deletions

View File

@@ -29,7 +29,7 @@ enable_language(C CXX ASM)
project(baseband_shared)
# Compiler options here.
set(USE_OPT "-O3 -falign-functions=16 -fno-math-errno --specs=nano.specs")
set(USE_OPT "-O3 -g -falign-functions=16 -fno-math-errno --specs=nano.specs")
# C specific options here (added to USE_OPT).
set(USE_COPT "-std=gnu99")
@@ -342,10 +342,10 @@ DeclareTargets(POOK ook)
### Audio transmit
#set(MODE_CPPSRC
# proc_audiotx.cpp
#)
#DeclareTargets(PATX audio_tx)
set(MODE_CPPSRC
proc_audiotx.cpp
)
DeclareTargets(PATX audio_tx)
### AFSK
@@ -361,13 +361,6 @@ DeclareTargets(PAFS afsk)
#)
#DeclareTargets(PEPR epar)
### Play audio
#set(MODE_CPPSRC
# proc_playaudio.cpp
#)
#DeclareTargets(PPAU play_audio)
### Xylos
set(MODE_CPPSRC

View File

@@ -119,8 +119,8 @@ void AFSKProcessor::execute(const buffer_c8_t& buffer) {
}
}
void AFSKProcessor::on_message(const Message* const p) {
const auto message = *reinterpret_cast<const AFSKConfigureMessage*>(p);
void AFSKProcessor::on_message(const Message* const msg) {
const auto message = *reinterpret_cast<const AFSKConfigureMessage*>(msg);
if (message.id == Message::ID::AFSKConfigure) {
afsk_samples_per_bit = message.samples_per_bit;

View File

@@ -30,7 +30,7 @@ class AFSKProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const p) override;
void on_message(const Message* const msg) override;
private:
bool configured = false;

View File

@@ -24,6 +24,7 @@
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include "rssi_thread.hpp"
#include "channel_decimator.hpp"
#include "matched_filter.hpp"
@@ -51,6 +52,7 @@ private:
static constexpr size_t baseband_fs = 2457600;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
std::array<complex16_t, 512> dst;
const buffer_c16_t dst_buffer {

View File

@@ -23,33 +23,69 @@
#include "proc_audiotx.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
//#include "audio_output.hpp"
#include "event_m4.hpp"
#include <cstdint>
void AudioTXProcessor::execute(const buffer_c8_t& buffer){
for (size_t i = 0; i<buffer.count; i++) {
sample = (sine_table_f32[(aphase & 0x03FF0000)>>18]*127); //(int8_t)lfsr(sample + i);
if (bc & 0x40)
aphase += 60000;
else
aphase += 90000;
// This is called at 1536000/2048 = 750Hz
if (!configured) return;
ai = 0;
for (size_t i = 0; i<buffer.count; i++) {
//audio_fifo.out(&sample, 1);
// Audio preview sample generation: 1536000/48000 = 32
if (as >= 31) {
as = 0;
//audio_fifo.out(&sample, 1);
//preview_audio_buffer.p[ai++] = sample << 8;
//FM
frq = sample * 1000;
//if ((audio_fifo.len() < 1024) && (asked == false)) {
// Ask application to fill up fifo
sigmessage.signaltype = 1;
shared_memory.application_queue.push(sigmessage);
asked = true;
//}
} else {
as++;
}
// FM
frq = (int32_t)(sample) * 4 * 2000;
phase = (phase + frq);
sphase = phase + (256<<16);
sphase = phase + (256 << 16);
re = (sine_table_f32[(sphase & 0x03FF0000)>>18]*127);
im = (sine_table_f32[(phase & 0x03FF0000)>>18]*127);
buffer.p[i] = {(int8_t)re,(int8_t)im};
buffer.p[i] = { (int8_t)re, (int8_t)im };
}
bc++;
//AudioOutput::fill_audio_buffer(preview_audio_buffer, true);
}
void AudioTXProcessor::on_message(const Message* const msg) {
switch(msg->id) {
case Message::ID::AudioTXConfig:
//const auto message = static_cast<const AudioTXConfigMessage*>(msg);
configured = true;
break;
case Message::ID::FIFOData:
//audio_fifo.in(static_cast<const FIFODataMessage*>(msg)->data, 1024);
asked = false;
break;
default:
break;
}
}
int main() {

View File

@@ -23,22 +23,39 @@
#ifndef __PROC_AUDIOTX_H__
#define __PROC_AUDIOTX_H__
#include "fifo.hpp"
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include <cstdint>
class AudioTXProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const msg) override;
private:
bool configured = false;
//std::unique_ptr<int8_t[]> audio_fifo_data = std::make_unique<int8_t[]>(1UL << 11);
//FIFO<int8_t> audio_fifo = { audio_fifo_data.get(), 11 }; // 43ms @ 48000Hz
uint8_t as = 0, ai;
int8_t re, im;
uint8_t s, as = 0, ai;
uint8_t byte_pos = 0;
uint8_t digit = 0;
int8_t sample;
int16_t st;
bool asked = false;
//int16_t audio_data[64];
/*const buffer_s16_t preview_audio_buffer {
audio_data,
sizeof(int16_t)*64
};*/
FIFOSignalMessage sigmessage;
uint32_t aphase, phase, sphase;
int32_t sample, frq, bc;
int32_t frq;
};
#endif

View File

@@ -24,6 +24,7 @@
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include "rssi_thread.hpp"
#include "channel_decimator.hpp"
@@ -63,6 +64,7 @@ private:
const float clock_recovery_rate = symbol_rate * 2;
BasebandThread baseband_thread { baseband_sampling_rate, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery {
clock_recovery_rate, symbol_rate, { 1.0f / 18.0f },

View File

@@ -1,83 +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_playaudio.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
#include "audio_output.hpp"
#include "event_m4.hpp"
#include <cstdint>
void PlayAudioProcessor::on_message(const Message* const msg) {
if (msg->id == Message::ID::FIFOData) {
const auto message = static_cast<const FIFODataMessage*>(msg);
memcpy(&audio_fifo[fifo_put], message->data, 1024);
fifo_put = (fifo_put + 1024) & 0x0FFF;
asked = false;
}
}
void PlayAudioProcessor::execute(const buffer_c8_t& buffer){
// This is called at 1536000/2048 = 750Hz
ai = 0;
for (size_t i = 0; i<buffer.count; i++) {
// Audio preview sample generation: 1536000/48000 = 32
if (as >= 31) {
as = 0;
sample = audio_fifo[fifo_get];
preview_audio_buffer.p[ai++] = sample << 8;
fifo_get = (fifo_get + 1) & 0x0FFF;
if ((((fifo_put - fifo_get) & 0x0FFF) < 3072) && (asked == false)) {
// Ask application to fill up fifo
sigmessage.signaltype = 1;
shared_memory.application_queue.push(sigmessage);
asked = true;
}
} else {
as++;
}
sample = ((int8_t)audio_fifo[fifo_get] * 4);
//FM
frq = sample * 2000;
phase = (phase + frq);
sphase = phase + (256<<16);
re = (sine_table_f32[(sphase & 0x03FF0000)>>18]*127);
im = (sine_table_f32[(phase & 0x03FF0000)>>18]*127);
buffer.p[i] = {(int8_t)re,(int8_t)im};
}
//AudioOutput::fill_audio_buffer(preview_audio_buffer, true);
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<PlayAudioProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -1,56 +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_PLAYAUDIO_H__
#define __PROC_PLAYAUDIO_H__
#include "baseband_processor.hpp"
class PlayAudioProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const msg) override;
private:
int8_t audio_fifo[4096]; // Probably too much (=85ms @ 48000Hz)
uint16_t fifo_put, fifo_get;
uint8_t as = 0, ai;
int8_t re, im;
int16_t st;
int16_t audio_data[64];
bool asked = false;
const buffer_s16_t preview_audio_buffer {
audio_data,
sizeof(int16_t)*64
};
FIFOSignalMessage sigmessage;
uint32_t aphase, phase, sphase;
int32_t sample, frq;
};
#endif

View File

@@ -28,10 +28,6 @@
#include <cstdint>
void RDSProcessor::execute(const buffer_c8_t& buffer) {
uint32_t * rdsdata;
// TODO
//rdsdata = (uint32_t *)shared_memory.radio_data;
for (size_t i = 0; i < buffer.count; i++) {
@@ -96,6 +92,14 @@ void RDSProcessor::execute(const buffer_c8_t& buffer) {
}
}
void RDSProcessor::on_message(const Message* const msg) {
if (msg->id == Message::ID::RDSConfigure) {
//const auto message = *reinterpret_cast<const RDSConfigureMessage*>(p);
rdsdata = (uint32_t*)shared_memory.tx_data;
configured = true;
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<RDSProcessor>() };
event_dispatcher.run();

View File

@@ -24,6 +24,7 @@
#define __PROC_RDS_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#define SAMPLES_PER_BIT 192
#define FILTER_SIZE 576
@@ -32,8 +33,14 @@
class RDSProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const msg) override;
private:
uint32_t * rdsdata;
BasebandThread baseband_thread { 2280000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
int8_t re, im;
uint8_t mphase, s;
uint32_t bit_pos;
@@ -49,6 +56,8 @@ private:
uint32_t phase, sphase;
int32_t sig, frq, frq_im, rdsc;
int32_t k;
bool configured { false };
const int32_t waveform_biphase[576] = {
165,167,168,168,167,166,163,160,

View File

@@ -98,7 +98,7 @@ private:
};
static constexpr float channel_rate_in = 307200.0f;
static constexpr size_t channel_decimation = 8;
static constexpr size_t channel_decimation = 2;
static constexpr float channel_sample_rate = channel_rate_in / channel_decimation;
OOKSlicerMagSquaredInt ook_slicer_5sps { channel_sample_rate / 8400 + 1};
uint32_t slicer_history { 0 };

View File

@@ -1,43 +0,0 @@
/*
* Copyright (C) 2014 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 __THREAD_BASE_H__
#define __THREAD_BASE_H__
#include <ch.h>
class ThreadBase {
public:
virtual ~ThreadBase() = default;
protected:
static msg_t fn(void* arg) {
auto obj = static_cast<ThreadBase*>(arg);
obj->run();
return 0;
}
private:
virtual void run() = 0;
};
#endif/*__THREAD_BASE_H__*/