Sync with Sharebrained's fw, only Xylos TX works for now

This commit is contained in:
furrtek
2016-07-27 03:03:40 +02:00
parent fdfa7c9776
commit 739956b42b
150 changed files with 17236 additions and 7875 deletions

View File

@@ -326,6 +326,55 @@ set(MODE_CPPSRC
)
DeclareTargets(PSPE wideband_spectrum)
### Jammer
set(MODE_CPPSRC
proc_jammer.cpp
)
DeclareTargets(PJAM jammer)
### Audio transmit
set(MODE_CPPSRC
proc_audiotx.cpp
)
DeclareTargets(PATX audio_tx)
### FSK LCR
set(MODE_CPPSRC
proc_fsk_lcr.cpp
)
DeclareTargets(PLCR lcr)
### Epar
set(MODE_CPPSRC
proc_epar.cpp
)
DeclareTargets(PEPR epar)
### Play audio
set(MODE_CPPSRC
proc_playaudio.cpp
)
DeclareTargets(PPAU play_audio)
### Xylos
set(MODE_CPPSRC
proc_xylos.cpp
)
DeclareTargets(PXYL xylos)
### RDS
set(MODE_CPPSRC
proc_rds.cpp
)
DeclareTargets(PRDS rds)
### HackRF "factory" firmware
add_custom_command(

View File

@@ -115,16 +115,9 @@ static void dma_error() {
void init() {
gpdma_channel_sgpio.set_handlers(transfer_complete, dma_error);
#if defined(PORTAPACK_BASEBAND_DMA_NO_SYNC)
/* Disable synchronization logic to improve(?) DMA response time.
* SGPIO (peripheral) must be on same clock as GPDMA peripheral.
* SGPIO runs from BASE_PERIPH_CLK, which is set to PLL1 in normal
* operation, same as the M4 and M0 cores. Memory, of course, is
* running from the same clock as the cores.
*/
LPC_GPDMA->SYNC |= (1 << gpdma_src_peripheral);
LPC_GPDMA->SYNC |= (1 << gpdma_dest_peripheral);
#endif
// LPC_GPDMA->SYNC |= (1 << gpdma_src_peripheral);
// LPC_GPDMA->SYNC |= (1 << gpdma_dest_peripheral);
}
void configure(
@@ -167,5 +160,16 @@ baseband::buffer_t wait_for_rx_buffer() {
}
}
baseband::buffer_t wait_for_tx_buffer() {
const auto next_index = thread_wait.sleep();
if( next_index >= 0 ) {
const size_t free_index = (next_index + transfers_per_buffer - 2) & transfers_mask;
return { reinterpret_cast<sample_t*>(lli_loop[free_index].srcaddr), transfer_samples };
} else {
return { };
}
}
} /* namespace dma */
} /* namespace baseband */

View File

@@ -31,6 +31,8 @@
namespace baseband {
namespace dma {
using Handler = void (*)();
void init();
void configure(
baseband::sample_t* const buffer_base,
@@ -43,6 +45,7 @@ bool is_enabled();
void disable();
baseband::buffer_t wait_for_rx_buffer();
baseband::buffer_t wait_for_tx_buffer();
} /* namespace dma */
} /* namespace baseband */

View File

@@ -24,21 +24,12 @@
#include "dsp_types.hpp"
#include "baseband.hpp"
#include "baseband_stats_collector.hpp"
#include "baseband_sgpio.hpp"
#include "baseband_dma.hpp"
#include "rssi.hpp"
#include "i2s.hpp"
/*#include "proc_am_audio.hpp"
#include "proc_nfm_audio.hpp"
#include "proc_wfm_audio.hpp"
#include "proc_ais.hpp"
#include "proc_wideband_spectrum.hpp"
#include "proc_tpms.hpp"
#include "proc_ert.hpp"
#include "proc_capture.hpp"*/
using namespace lpc43xx;
#include "portapack_shared_memory.hpp"
@@ -53,10 +44,12 @@ Thread* BasebandThread::thread = nullptr;
BasebandThread::BasebandThread(
uint32_t sampling_rate,
BasebandProcessor* const baseband_processor,
const tprio_t priority
const tprio_t priority,
const baseband::Direction dir
) : baseband_processor { baseband_processor },
sampling_rate { sampling_rate }
{
direction = dir;
thread = chThdCreateStatic(baseband_thread_wa, sizeof(baseband_thread_wa),
priority, ThreadBase::fn,
this
@@ -76,24 +69,40 @@ void BasebandThread::run() {
const auto baseband_buffer = std::make_unique<std::array<baseband::sample_t, 8192>>();
baseband::dma::configure(
baseband_buffer->data(),
direction()
direction
);
//baseband::dma::allocate(4, 2048);
baseband_sgpio.configure(direction());
baseband::dma::enable(direction());
baseband_sgpio.configure(direction);
baseband::dma::enable(direction);
baseband_sgpio.streaming_enable();
if (direction == baseband::Direction::Transmit) {
while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here:
const baseband::buffer_t buffer_tmp = baseband::dma::wait_for_tx_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate
};
while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here:
const auto buffer_tmp = baseband::dma::wait_for_rx_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate
};
if( baseband_processor ) {
baseband_processor->execute(buffer);
}
}
}
} else {
while( !chThdShouldTerminate() ) {
// TODO: Place correct sampling rate into buffer returned here:
const baseband::buffer_t buffer_tmp = baseband::dma::wait_for_rx_buffer();
if( buffer_tmp ) {
buffer_c8_t buffer {
buffer_tmp.p, buffer_tmp.count, sampling_rate
};
if( baseband_processor ) {
baseband_processor->execute(buffer);
if( baseband_processor ) {
baseband_processor->execute(buffer);
}
}
}
}
@@ -102,38 +111,3 @@ void BasebandThread::run() {
baseband::dma::disable();
baseband_sgpio.streaming_disable();
}
/*
BasebandProcessor* BasebandThread::create_processor(const int32_t mode) {
switch(mode) {
case 0: return new NarrowbandAMAudio();
case 1: return new NarrowbandFMAudio();
case 2: return new WidebandFMAudio();
case 3: return new AISProcessor();
case 4: return new WidebandSpectrum();
case 5: return new TPMSProcessor();
case 6: return new ERTProcessor();
case 7: return new CaptureProcessor();
default: return nullptr;
}
}
void BasebandThread::disable() {
if( baseband_processor ) {
i2s::i2s0::tx_mute();
baseband::dma::disable();
baseband_sgpio.streaming_disable();
rf::rssi::stop();
}
}
void BasebandThread::enable() {
if( baseband_processor ) {
if( direction() == baseband::Direction::Receive ) {
rf::rssi::start();
}
baseband_sgpio.configure(direction());
baseband::dma::enable(direction());
baseband_sgpio.streaming_enable();
}
}
*/

View File

@@ -33,18 +33,14 @@ public:
BasebandThread(
uint32_t sampling_rate,
BasebandProcessor* const baseband_processor,
const tprio_t priority
const tprio_t priority,
const baseband::Direction dir
);
~BasebandThread();
// 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::Receive;
}
private:
static Thread* thread;
baseband::Direction direction;
BasebandProcessor* baseband_processor { nullptr };
uint32_t sampling_rate;

121
firmware/baseband/main.cpp Executable file
View File

@@ -0,0 +1,121 @@
/*
* 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.
*/
#include "ch.h"
#include "lpc43xx_cpp.hpp"
#include "portapack_shared_memory.hpp"
#include "portapack_dma.hpp"
#include "gpdma.hpp"
#include "event_m4.hpp"
#include "touch_dma.hpp"
#include "baseband_thread.hpp"
#include "rssi_thread.hpp"
#include "baseband_processor.hpp"
#include "message_queue.hpp"
#include "utility.hpp"
#include "debug.hpp"
#include "audio_dma.hpp"
#include "gcc.hpp"
#include <cstdint>
#include <cstddef>
#include <array>
extern "C" {
void __late_init(void) {
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
/* After this call, scheduler, systick, heap, etc. are available. */
/* By doing chSysInit() here, it runs before C++ constructors, which may
* require the heap.
*/
chSysInit();
}
}
static void init() {
audio::dma::init();
audio::dma::configure();
audio::dma::enable();
LPC_CREG->DMAMUX = portapack::gpdma_mux;
gpdma::controller.enable();
nvicEnableVector(DMA_IRQn, CORTEX_PRIORITY_MASK(LPC_DMA_IRQ_PRIORITY));
touch::dma::init();
touch::dma::allocate();
touch::dma::enable();
}
static void halt() {
port_disable();
while(true) {
port_wait_for_interrupt();
}
}
static void shutdown() {
// TODO: Is this complete?
nvicDisableVector(DMA_IRQn);
chSysDisable();
systick_stop();
ShutdownMessage shutdown_message;
shared_memory.application_queue.push(shutdown_message);
halt();
}
int main(void) {
init();
/* TODO: Ensure DMAs are configured to point at first LLI in chain. */
EventDispatcher event_dispatcher;
event_dispatcher.run();
shutdown();
return 0;
}

View File

@@ -0,0 +1,109 @@
/*
* 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_afskrx.hpp"
#include "sine_table.hpp"
#include "portapack_shared_memory.hpp"
using namespace lpc43xx;
void AFSKRXProcessor::execute(const buffer_c8_t& buffer) {
if( !configured ) {
return;
}
/* Called every 2048/3072000 second -- 1500Hz. */
const auto decim_0_out = decim_0.execute(buffer, dst_buffer);
const auto decim_1_out = decim_1.execute(decim_0_out, dst_buffer);
const auto channel_out = channel_filter.execute(decim_1_out, dst_buffer);
auto audio = demod.execute(channel_out, work_audio_buffer);
/*static uint64_t audio_present_history = 0;
const auto audio_present_now = squelch.execute(audio);
audio_present_history = (audio_present_history << 1) | (audio_present_now ? 1 : 0);
const bool audio_present = (audio_present_history != 0);
*/
//if( !audio_present ) {
// Zero audio buffer.
/*for(size_t i=0; i<audio.count; i++) {
if ((i % 3) > 1)
audio.p[i] = 4096;
else
audio.p[i] = -4096;
}*/
//}
//audio_hpf.execute_in_place(audio);
for(size_t i=0; i<audio.count; i++) {
if (spur > 10) {
if (audio.p[i] > 2000)
sign = 1;
if (audio.p[i] < -2000)
sign = 0;
spur = 0;
} else {
spur++;
}
if (sign != prev_sign) {
if (freq_timer < 15) // 48
bit = 0;
else
bit++;
freq_timer = 0;
}
prev_sign = sign;
if (freq_timer < 1000) freq_timer++; // TODO: Limit in a more intelligent way
}
if (bit_timer >= 40) {
bit_timer = 0;
// Check bit state here !
} else {
bit_timer++;
}
if (sc >= 600) {
sc = 0;
//AFSKDataMessage message;
//memcpy(message.data,aud,128*2);
//shared_memory.application_queue.push(message);
audc = 0;
} else {
sc++;
}
if (audc < 4) {
memcpy(aud+(audc*32),audio.p,32*2);
audc++;
}
audio_output.write(audio);
}
void AFSKRXProcessor::data_handler(
const double data
) {
/*AFSKDataMessage message;
message.data = 'T';
shared_memory.application_queue.push(message);*/
}

View File

@@ -0,0 +1,68 @@
/*
* 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_AFSKRX_H__
#define __PROC_AFSKRX_H__
#include "baseband_processor.hpp"
#include "dsp_decimate.hpp"
#include "dsp_demodulate.hpp"
#include "audio_output.hpp"
#include "message.hpp"
class AFSKRXProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
std::array<complex16_t, 512> dst;
const buffer_c16_t dst_buffer {
dst.data(),
dst.size()
};
const buffer_f32_t work_audio_buffer {
(float*)dst.data(),
sizeof(dst) / sizeof(float)
};
dsp::decimate::FIRAndDecimateComplex channel_filter;
dsp::demodulate::FM demod; // 48000 5000
dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0;
dsp::decimate::FIRC16xR16x32Decim8 decim_1;
AudioOutput audio_output;
uint16_t bit_timer = 0, freq_timer = 0;
uint16_t sc;
uint8_t audc, spur, sign, prev_sign, bit = 0;
int16_t aud[128];
void data_handler(const double data);
bool configured { false };
void configure(const NBFMConfigureMessage& message);
};
#endif/*__PROC_TPMS_H__*/

View File

@@ -50,7 +50,7 @@ public:
private:
static constexpr size_t baseband_fs = 2457600;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
std::array<complex16_t, 512> dst;
const buffer_c16_t dst_buffer {

View File

@@ -46,7 +46,7 @@ private:
static constexpr size_t decim_2_decimation_factor = 4;
static constexpr size_t channel_filter_decimation_factor = 1;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
std::array<complex16_t, 512> dst;

View File

@@ -0,0 +1,59 @@
/*
* 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_audiotx.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.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;
//FM
frq = sample * 1000;
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};
}
bc++;
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<AudioTXProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,44 @@
/*
* 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_AUDIOTX_H__
#define __PROC_AUDIOTX_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include <cstdint>
class AudioTXProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
int8_t re, im;
uint8_t s, as = 0, ai;
uint8_t byte_pos = 0;
uint8_t digit = 0;
uint32_t aphase, phase, sphase;
int32_t sample, frq, bc;
};
#endif

View File

@@ -48,7 +48,7 @@ private:
static constexpr size_t baseband_fs = 4000000;
static constexpr auto spectrum_rate_hz = 50.0f;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
std::array<complex16_t, 512> dst;

View File

@@ -65,3 +65,9 @@ void CloseCallProcessor::on_message(const Message* const message) {
break;
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<CloseCallProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,110 @@
/*
* 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_epar.hpp"
#include "dsp_iir_config.hpp"
#include "audio_output.hpp"
#include "event_m4.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
#include <cstdint>
void EPARProcessor::execute(const buffer_c8_t& buffer) {
// This is called at 1536000/2048 = 750Hz
for (size_t i = 0; i<buffer.count; i++) {
// Sample generation rate: 1536000/10 = 153kHz
if (s >= 9) {
s = 0;
if (sample_count >= EPAR_TU) {
if (state) {
// Send code
if (current_tu == 2) {
current_bit = shared_memory.epardata[bit_pos];
if (bit_pos == 12) {
bit_pos = 0;
current_tu = 0;
state = 0;
} else {
bit_pos++;
}
current_tu = 0;
} else {
current_tu++;
}
sample = bitdef[current_bit][current_tu];
} else {
// Pause
if (current_tu == EPAR_SPACE) {
if (repeat_count == EPAR_REPEAT) {
message.n = 100; // End of transmission code
transmit_done = true;
shared_memory.application_queue.push(message);
}
if (transmit_done == false) {
message.n = repeat_count; // Inform UI about progress (just as eye candy)
shared_memory.application_queue.push(message);
state = 1;
}
repeat_count++;
current_tu = 0;
} else {
current_tu++;
}
sample = -127;
}
sample_count = 0;
} else {
sample_count++;
}
} else {
s++;
}
//FM
frq = sample * shared_memory.excursion; // 500=~3kHz wide
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};
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<EPARProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,71 @@
/*
* 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_EPAR_H__
#define __PROC_EPAR_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
#include "dsp_decimate.hpp"
#include "dsp_demodulate.hpp"
#include "audio_output.hpp"
// One bit is 0.005119048s (~200bps ?)
// Time unit is 0.001706349s (586Hz)
#define EPAR_TU 262-1 // 1536000/10/586
#define EPAR_SPACE 33-1
#define EPAR_REPEAT 26*2 // DEBUG
// 0: 011
// 1: 001
// Good: 1001110111111
// Bad: 1100111011111
class EPARProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
bool transmit_done;
const int8_t bitdef[2][3] = {
{-127, 127, 127},
{-127, -127, 127}
};
int8_t re, im;
uint8_t s;
uint8_t state_length = 0;
uint8_t current_bit = 0;
uint8_t current_tu = 0;
uint8_t bit_pos = 0;
uint8_t repeat_count = 0;
uint32_t sample_count = 0;
uint32_t aphase, phase, sphase;
int32_t sample, frq;
uint8_t state = 1;
TXDoneMessage message;
};
#endif

View File

@@ -62,7 +62,7 @@ private:
const size_t samples_per_symbol = channel_sampling_rate / symbol_rate;
const float clock_recovery_rate = symbol_rate * 2;
BasebandThread baseband_thread { baseband_sampling_rate, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_sampling_rate, this, NORMALPRIO + 20, baseband::Direction::Receive };
clock_recovery::ClockRecovery<clock_recovery::FixedErrorFilter> clock_recovery {
clock_recovery_rate, symbol_rate, { 1.0f / 18.0f },

View File

@@ -0,0 +1,117 @@
/*
* 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.
*/
#include "proc_fsk_lcr.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
#include "event_m4.hpp"
#include <cstdint>
void LCRFSKProcessor::execute(const buffer_c8_t& buffer) {
for (size_t i = 0; i<buffer.count; i++) {
//Sample generation 2.28M/10 = 228kHz
if (s >= 9) {
s = 0;
if (sample_count >= shared_memory.afsk_samples_per_bit) {
if (shared_memory.afsk_transmit_done == false) {
cur_byte = shared_memory.radio_data[byte_pos];
ext_byte = shared_memory.radio_data[byte_pos + 1];
}
if (!cur_byte) {
if (shared_memory.afsk_repeat) {
shared_memory.afsk_repeat--;
bit_pos = 0;
byte_pos = 0;
cur_byte = shared_memory.radio_data[0];
ext_byte = shared_memory.radio_data[1];
message.n = shared_memory.afsk_repeat;
shared_memory.application_queue.push(message);
} else {
message.n = 0;
shared_memory.afsk_transmit_done = true;
shared_memory.application_queue.push(message);
cur_byte = 0;
ext_byte = 0;
}
}
if (shared_memory.afsk_alt_format) {
// 0bbbbbbbbp
// Start, 8-bit data, parity
gbyte = 0;
gbyte = cur_byte << 1;
gbyte |= (ext_byte & 1);
} else {
// 0bbbbbbbp1
// Start, 7-bit data, parity, stop
gbyte = 0;
gbyte = cur_byte << 1;
gbyte |= 1;
}
cur_bit = (gbyte >> (9 - bit_pos)) & 1;
if (bit_pos == 9) {
bit_pos = 0;
if (!shared_memory.afsk_alt_format)
byte_pos++;
else
byte_pos += 2;
} else {
bit_pos++;
}
sample_count = 0;
} else {
sample_count++;
}
if (cur_bit)
aphase += shared_memory.afsk_phase_inc_mark;
else
aphase += shared_memory.afsk_phase_inc_space;
} else {
s++;
}
sample = (sine_table_f32[(aphase & 0x03FF0000)>>18]*255);
//FM
frq = sample * shared_memory.afsk_fmmod;
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};
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<LCRFSKProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,48 @@
/*
* 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 __PROC_FSK_LCR_H__
#define __PROC_FSK_LCR_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
class LCRFSKProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
BasebandThread baseband_thread { 2280000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
int8_t re, im;
uint8_t s;
uint8_t bit_pos = 0, byte_pos = 0;
char cur_byte = 0;
char ext_byte = 0;
uint16_t gbyte;
uint8_t cur_bit = 0;
uint32_t sample_count;
uint32_t aphase, phase, sphase;
int32_t sample, sig, frq;
TXDoneMessage message;
};
#endif

View File

@@ -0,0 +1,88 @@
/*
* 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.
*/
#include "proc_jammer.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
#include "event_m4.hpp"
#include <cstdint>
#define POLY_MASK_32 0xB4BCD35C
void JammerProcessor::execute(const buffer_c8_t& buffer) {
for (size_t i = 0; i<buffer.count; i++) {
if (s >= 10000) { //shared_memory.jammer_ranges[ir].duration
s = 0;
for (;;) {
ir++;
if (ir > 15) ir = 0;
if (shared_memory.jammer_ranges[ir].active == true) break;
}
jammer_bw = shared_memory.jammer_ranges[ir].width / 2;
message.freq = shared_memory.jammer_ranges[ir].center;
shared_memory.application_queue.push(message);
} else {
s++;
}
// Ramp
/*if (r >= 10) {
if (sample < 128)
sample++;
else
sample = -127;
r = 0;
} else {
r++;
}*/
// Phase
if (r >= 70) {
aphase += ((aphase>>4) ^ 0x4573) << 14;
r = 0;
} else {
r++;
}
aphase += 8830;
sample = sine_table_f32[(aphase & 0x03FF0000)>>18]*256;
//FM
frq = sample * jammer_bw; // Bandwidth
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};
}
};
int main() {
EventDispatcher event_dispatcher { std::make_unique<JammerProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,45 @@
/*
* 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 __PROC_JAMMER_H__
#define __PROC_JAMMER_H__
#include "baseband_processor.hpp"
#include "baseband_thread.hpp"
class JammerProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
int32_t lfsr32 = 0xABCDE;
uint32_t s;
int8_t r, ir, re, im;
int64_t jammer_bw, jammer_center;
int feedback;
int32_t lfsr;
uint32_t sample_count;
uint32_t aphase, phase, sphase;
int32_t sample, frq;
RetuneMessage message;
};
#endif

View File

@@ -43,7 +43,7 @@ public:
private:
static constexpr size_t baseband_fs = 3072000;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
std::array<complex16_t, 512> dst;

View File

@@ -0,0 +1,83 @@
/*
* 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

@@ -0,0 +1,56 @@
/*
* 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

@@ -0,0 +1,102 @@
/*
* 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_rds.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
#include "event_m4.hpp"
#include <cstdint>
void RDSProcessor::execute(const buffer_c8_t& buffer) {
uint32_t * rdsdata;
rdsdata = (uint32_t *)shared_memory.radio_data;
for (size_t i = 0; i < buffer.count; i++) {
//Sample generation 2.28M/10=228kHz
if(s >= 9) {
s = 0;
if(sample_count >= SAMPLES_PER_BIT) {
cur_bit = (rdsdata[(bit_pos / 26) & 15] >> (25 - (bit_pos % 26))) & 1;
prev_output = cur_output;
cur_output = prev_output ^ cur_bit;
const int32_t *src = waveform_biphase; // const ok ?
int idx = in_sample_index;
for(int j = 0; j < FILTER_SIZE; j++) {
val = (*src++);
if (cur_output) val = -val;
sample_buffer[idx++] += val;
if (idx >= SAMPLE_BUFFER_SIZE) idx = 0;
}
in_sample_index += SAMPLES_PER_BIT;
if (in_sample_index >= SAMPLE_BUFFER_SIZE) in_sample_index -= SAMPLE_BUFFER_SIZE;
if (bit_pos < shared_memory.bit_length)
bit_pos++;
else
bit_pos = 0;
sample_count = 0;
}
sample = sample_buffer[out_sample_index];
sample_buffer[out_sample_index] = 0;
out_sample_index++;
if (out_sample_index >= SAMPLE_BUFFER_SIZE) out_sample_index = 0;
//AM @ 228k/4 = 57kHz
switch (mphase) {
case 0:
case 2: sample = 0; break;
case 1: break;
case 3: sample = -sample; break;
}
mphase++;
if (mphase >= 4) mphase = 0;
sample_count++;
} else {
s++;
}
//FM
frq = (sample>>16) * 386760;
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};
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<RDSProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,130 @@
/*
* 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_RDS_H__
#define __PROC_RDS_H__
#include "baseband_processor.hpp"
#define SAMPLES_PER_BIT 192
#define FILTER_SIZE 576
#define SAMPLE_BUFFER_SIZE SAMPLES_PER_BIT + FILTER_SIZE
class RDSProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
int8_t re, im;
uint8_t mphase, s;
uint32_t bit_pos;
int32_t sample_buffer[SAMPLE_BUFFER_SIZE] = {0};
int32_t val;
uint8_t prev_output = 0;
uint8_t cur_output = 0;
uint8_t cur_bit = 0;
int sample_count = SAMPLES_PER_BIT;
int in_sample_index = 0;
int32_t sample;
int out_sample_index = SAMPLE_BUFFER_SIZE - 1;
uint32_t phase, sphase;
int32_t sig, frq, frq_im, rdsc;
int32_t k;
const int32_t waveform_biphase[576] = {
165,167,168,168,167,166,163,160,
157,152,147,141,134,126,118,109,
99,88,77,66,53,41,27,14,
0,-14,-29,-44,-59,-74,-89,-105,
-120,-135,-150,-165,-179,-193,-206,-218,
-231,-242,-252,-262,-271,-279,-286,-291,
-296,-299,-301,-302,-302,-300,-297,-292,
-286,-278,-269,-259,-247,-233,-219,-202,
-185,-166,-145,-124,-101,-77,-52,-26,
0,27,56,85,114,144,175,205,
236,266,296,326,356,384,412,439,
465,490,513,535,555,574,590,604,
616,626,633,637,639,638,633,626,
616,602,586,565,542,515,485,451,
414,373,329,282,232,178,121,62,
0,-65,-132,-202,-274,-347,-423,-500,
-578,-656,-736,-815,-894,-973,-1051,-1128,
-1203,-1276,-1347,-1415,-1479,-1540,-1596,-1648,
-1695,-1736,-1771,-1799,-1820,-1833,-1838,-1835,
-1822,-1800,-1767,-1724,-1670,-1605,-1527,-1437,
-1334,-1217,-1087,-943,-785,-611,-423,-219,
0,235,487,755,1040,1341,1659,1994,
2346,2715,3101,3504,3923,4359,4811,5280,
5764,6264,6780,7310,7856,8415,8987,9573,
10172,10782,11404,12036,12678,13329,13989,14656,
15330,16009,16694,17382,18074,18767,19461,20155,
20848,21539,22226,22909,23586,24256,24918,25571,
26214,26845,27464,28068,28658,29231,29787,30325,
30842,31339,31814,32266,32694,33097,33473,33823,
34144,34437,34699,34931,35131,35299,35434,35535,
35602,35634,35630,35591,35515,35402,35252,35065,
34841,34579,34279,33941,33566,33153,32702,32214,
31689,31128,30530,29897,29228,28525,27788,27017,
26214,25379,24513,23617,22693,21740,20761,19755,
18725,17672,16597,15501,14385,13251,12101,10935,
9755,8563,7360,6148,4927,3701,2470,1235,
0,-1235,-2470,-3701,-4927,-6148,-7360,-8563,
-9755,-10935,-12101,-13251,-14385,-15501,-16597,-17672,
-18725,-19755,-20761,-21740,-22693,-23617,-24513,-25379,
-26214,-27017,-27788,-28525,-29228,-29897,-30530,-31128,
-31689,-32214,-32702,-33153,-33566,-33941,-34279,-34579,
-34841,-35065,-35252,-35402,-35515,-35591,-35630,-35634,
-35602,-35535,-35434,-35299,-35131,-34931,-34699,-34437,
-34144,-33823,-33473,-33097,-32694,-32266,-31814,-31339,
-30842,-30325,-29787,-29231,-28658,-28068,-27464,-26845,
-26214,-25571,-24918,-24256,-23586,-22909,-22226,-21539,
-20848,-20155,-19461,-18767,-18074,-17382,-16694,-16009,
-15330,-14656,-13989,-13329,-12678,-12036,-11404,-10782,
-10172,-9573,-8987,-8415,-7856,-7310,-6780,-6264,
-5764,-5280,-4811,-4359,-3923,-3504,-3101,-2715,
-2346,-1994,-1659,-1341,-1040,-755,-487,-235,
0,219,423,611,785,943,1087,1217,
1334,1437,1527,1605,1670,1724,1767,1800,
1822,1835,1838,1833,1820,1799,1771,1736,
1695,1648,1596,1540,1479,1415,1347,1276,
1203,1128,1051,973,894,815,736,656,
578,500,423,347,274,202,132,65,
0,-62,-121,-178,-232,-282,-329,-373,
-414,-451,-485,-515,-542,-565,-586,-602,
-616,-626,-633,-638,-639,-637,-633,-626,
-616,-604,-590,-574,-555,-535,-513,-490,
-465,-439,-412,-384,-356,-326,-296,-266,
-236,-205,-175,-144,-114,-85,-56,-27,
0,26,52,77,101,124,145,166,
185,202,219,233,247,259,269,278,
286,292,297,300,302,302,301,299,
296,291,286,279,271,262,252,242,
231,218,206,193,179,165,150,135,
120,105,89,74,59,44,29,14,
0,-14,-27,-41,-53,-66,-77,-88,
-99,-109,-118,-126,-134,-141,-147,-152,
-157,-160,-163,-166,-167,-168,-168,-167
};
};
#endif

View File

@@ -0,0 +1,29 @@
/*
* 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.
*/
#include "proc_sigfrx.hpp"
#include <cstdint>
#include <cstddef>
void SIGFRXProcessor::execute(const buffer_c8_t& buffer) {
/* Called every 2048/3072000 second -- 1500Hz. */
}

View File

@@ -0,0 +1,38 @@
/*
* 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 __PROC_SIGFRX_H__
#define __PROC_SIGFRX_H__
#include "baseband_processor.hpp"
#include "dsp_decimate.hpp"
#include "dsp_demodulate.hpp"
class SIGFRXProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
private:
};
#endif

View File

@@ -66,7 +66,7 @@ public:
private:
static constexpr size_t baseband_fs = 2457600;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
std::array<complex16_t, 512> dst;

View File

@@ -42,7 +42,7 @@ private:
static constexpr size_t baseband_fs = 3072000;
static constexpr auto spectrum_rate_hz = 50.0f;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
std::array<complex16_t, 512> dst;

View File

@@ -43,7 +43,7 @@ public:
private:
static constexpr size_t baseband_fs = 20000000;
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20 };
BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Receive };
RSSIThread rssi_thread { NORMALPRIO + 10 };
SpectrumCollector channel_spectrum;

View File

@@ -0,0 +1,127 @@
/*
* 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_xylos.hpp"
#include "dsp_iir_config.hpp"
#include "audio_output.hpp"
#include "portapack_shared_memory.hpp"
#include "sine_table.hpp"
#include "event_m4.hpp"
#include <cstdint>
void XylosProcessor::execute(const buffer_c8_t& buffer) {
// This is called at 1536000/2048 = 750Hz
if( !configured ) {
return;
}
for (size_t i = 0; i<buffer.count; i++) {
// Sample generation rate: 1536000/10 = 153kHz
if (s >= (5-1)) {
s = 0;
if (silence) {
if (sample_count >= SILENCE) {
silence = false;
sample_count = CCIR_TONELENGTH;
} else {
sample_count++;
}
} else {
if (sample_count >= CCIR_TONELENGTH) {
if (transmit_done == false) {
message.n = byte_pos; // Inform UI about progress (just as eye candy)
shared_memory.application_queue.push(message);
digit = xylosdata[byte_pos++];
}
if ((digit == 0xFF) || (byte_pos >= 21)) {
message.n = 25; // End of message code
transmit_done = true;
shared_memory.application_queue.push(message);
}
sample_count = 0;
} else {
sample_count++;
}
aphase += ccir_phases[digit];
}
} else {
s++;
}
if (silence) {
re = 0;
im = 0;
} else {
sample = (sine_table_f32[(aphase & 0x03FF0000)>>18]*127); // 255 here before
// Audio preview sample generation: 1536000/48000 = 32
/*if (as >= 31) {
as = 0;
audio[ai++] = sample * 128;
} else {
as++;
}*/
//FM
frq = sample * 1000; // 500 was here
phase = (phase + frq);
sphase = phase + (256<<16);
re = (sine_table_f32[(sphase & 0x03FF0000)>>18]*15);
im = (sine_table_f32[(phase & 0x03FF0000)>>18]*15);
}
buffer.p[i] = {(int8_t)re,(int8_t)im};
}
//audio_output.write(audio_buffer);
}
void XylosProcessor::on_message(const Message* const p) {
const auto message = *reinterpret_cast<const XylosConfigureMessage*>(p);
if (message.id == Message::ID::XylosConfigure) {
memcpy(xylosdata, message.ccir_message, 21);
byte_pos = 0;
digit = 0;
sample_count = CCIR_TONELENGTH;
as = 0;
transmit_done = false;
configured = true;
}
}
int main() {
EventDispatcher event_dispatcher { std::make_unique<XylosProcessor>() };
event_dispatcher.run();
return 0;
}

View File

@@ -0,0 +1,83 @@
/*
* 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_XYLOS_H__
#define __PROC_XYLOS_H__
#include "baseband_processor.hpp"
#include "dsp_decimate.hpp"
#include "dsp_demodulate.hpp"
#include "audio_output.hpp"
#include "baseband_thread.hpp"
#define CCIR_TONELENGTH (15360*2)-1 // 1536000/10/10
#define PHASEV (436.91/2) // (65536*1024)/1536000*10
#define SILENCE (46080*2)-1 // 400ms
class XylosProcessor : public BasebandProcessor {
public:
void execute(const buffer_c8_t& buffer) override;
void on_message(const Message* const p) override;
private:
bool configured = false;
bool transmit_done = false;
BasebandThread baseband_thread { 1536000, this, NORMALPRIO + 20, baseband::Direction::Transmit };
uint32_t ccir_phases[16] = {
(uint32_t)(1981*PHASEV),
(uint32_t)(1124*PHASEV),
(uint32_t)(1197*PHASEV),
(uint32_t)(1275*PHASEV),
(uint32_t)(1358*PHASEV),
(uint32_t)(1446*PHASEV),
(uint32_t)(1540*PHASEV),
(uint32_t)(1640*PHASEV),
(uint32_t)(1747*PHASEV),
(uint32_t)(1860*PHASEV),
(uint32_t)(2400*PHASEV),
(uint32_t)(930*PHASEV),
(uint32_t)(2247*PHASEV),
(uint32_t)(991*PHASEV),
(uint32_t)(2110*PHASEV),
(uint32_t)(1055*PHASEV)
};
char xylosdata[21];
int8_t re, im;
uint8_t s, as = 0, ai;
uint8_t byte_pos = 0;
uint8_t digit = 0;
uint32_t sample_count = CCIR_TONELENGTH;
uint32_t aphase, phase, sphase;
int32_t sample, frq;
bool silence = true;
TXDoneMessage message;
//AudioOutput audio_output;
};
#endif

View File

@@ -47,7 +47,6 @@ 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 {

Binary file not shown.