diff --git a/firmware/Makefile b/firmware/Makefile index 5bce1a9f..0def504c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -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 diff --git a/firmware/application/baseband_api.cpp b/firmware/application/baseband_api.cpp index 3c87682b..cc9939dd 100644 --- a/firmware/application/baseband_api.cpp +++ b/firmware/application/baseband_api.cpp @@ -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 { diff --git a/firmware/application/baseband_api.hpp b/firmware/application/baseband_api.hpp index 15959142..3fc9115f 100644 --- a/firmware/application/baseband_api.hpp +++ b/firmware/application/baseband_api.hpp @@ -55,6 +55,7 @@ void stop(); void shutdown(); +void spectrum_streaming_start(size_t decimation_factor); void spectrum_streaming_start(); void spectrum_streaming_stop(); diff --git a/firmware/application/transmitter_model.hpp b/firmware/application/transmitter_model.hpp index 55d078ac..a4eae0f0 100644 --- a/firmware/application/transmitter_model.hpp +++ b/firmware/application/transmitter_model.hpp @@ -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, }; diff --git a/firmware/application/ui_closecall.cpp b/firmware/application/ui_closecall.cpp index 93ab314a..79e837e9 100644 --- a/firmware/application/ui_closecall.cpp +++ b/firmware/application/ui_closecall.cpp @@ -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), diff --git a/firmware/application/ui_closecall.hpp b/firmware/application/ui_closecall.hpp index 42e2ef4a..49a557b8 100644 --- a/firmware/application/ui_closecall.hpp +++ b/firmware/application/ui_closecall.hpp @@ -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 | diff --git a/firmware/application/ui_xylos.cpp b/firmware/application/ui_xylos.cpp index 56de2e67..f1c1d14a 100644 --- a/firmware/application/ui_xylos.cpp +++ b/firmware/application/ui_xylos.cpp @@ -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(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(p); @@ -390,7 +392,7 @@ XylosView::XylosView( journuit(); } } else { - for (c=0;cn;c++) + for (c=0;cn;c++) // Todo: Use progressbar ! progress[c] = ' '; progress[c] = '.'; progress[++c] = 0; diff --git a/firmware/baseband-tx.bin b/firmware/baseband-tx.bin index 7ee70f4d..002a8983 100644 Binary files a/firmware/baseband-tx.bin and b/firmware/baseband-tx.bin differ diff --git a/firmware/baseband-tx/baseband_thread.cpp b/firmware/baseband-tx/baseband_thread.cpp index 23cfa3bc..51c62caf 100644 --- a/firmware/baseband-tx/baseband_thread.cpp +++ b/firmware/baseband-tx/baseband_thread.cpp @@ -85,7 +85,7 @@ void BasebandThread::run() { const auto baseband_buffer = std::make_unique>(); 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(); } } diff --git a/firmware/baseband-tx/baseband_thread.hpp b/firmware/baseband-tx/baseband_thread.hpp index 5abb1ce1..bc3bf491 100644 --- a/firmware/baseband-tx/baseband_thread.hpp +++ b/firmware/baseband-tx/baseband_thread.hpp @@ -33,12 +33,6 @@ public: Thread* start(const tprio_t priority); 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); diff --git a/firmware/baseband-tx/proc_xylos.cpp b/firmware/baseband-tx/proc_xylos.cpp index 61cdd241..9caf1d19 100644 --- a/firmware/baseband-tx/proc_xylos.cpp +++ b/firmware/baseband-tx/proc_xylos.cpp @@ -30,16 +30,11 @@ #include -// 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>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); diff --git a/firmware/baseband-tx/proc_xylos.hpp b/firmware/baseband-tx/proc_xylos.hpp index 97695997..1de15d16 100644 --- a/firmware/baseband-tx/proc_xylos.hpp +++ b/firmware/baseband-tx/proc_xylos.hpp @@ -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 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 diff --git a/firmware/baseband.bin b/firmware/baseband.bin index 187b9c21..08ce9eee 100644 Binary files a/firmware/baseband.bin and b/firmware/baseband.bin differ diff --git a/firmware/baseband/Makefile b/firmware/baseband/Makefile index ffb80d85..6c4ec717 100755 --- a/firmware/baseband/Makefile +++ b/firmware/baseband/Makefile @@ -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 \ diff --git a/firmware/baseband/baseband_thread.cpp b/firmware/baseband/baseband_thread.cpp index 37f36275..54fda4fa 100644 --- a/firmware/baseband/baseband_thread.cpp +++ b/firmware/baseband/baseband_thread.cpp @@ -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; } } diff --git a/firmware/baseband/proc_closecall.cpp b/firmware/baseband/proc_closecall.cpp new file mode 100644 index 00000000..8d49aff0 --- /dev/null +++ b/firmware/baseband/proc_closecall.cpp @@ -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 +#include + +#include + +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; iid) { + case Message::ID::UpdateSpectrum: + case Message::ID::SpectrumStreamingConfig: + channel_spectrum.on_message(message); + break; + + default: + break; + } +} diff --git a/firmware/baseband/proc_closecall.hpp b/firmware/baseband/proc_closecall.hpp new file mode 100644 index 00000000..f00e6ff7 --- /dev/null +++ b/firmware/baseband/proc_closecall.hpp @@ -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 +#include +#include + +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 spectrum; + + size_t phase = 0; +}; + +#endif/*__PROC_CLOSECALLPROCESSOR_H__*/ diff --git a/firmware/baseband/spectrum_collector.cpp b/firmware/baseband/spectrum_collector.cpp index 0d288bee..564182e9 100644 --- a/firmware/baseband/spectrum_collector.cpp +++ b/firmware/baseband/spectrum_collector.cpp @@ -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 { diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index e4727502..92a7041c 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -237,15 +237,26 @@ public: Stopped = 0, Running = 1, }; - + 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 { diff --git a/firmware/common/modules.h b/firmware/common/modules.h index 38ca88d4..3f5e744c 100644 --- a/firmware/common/modules.h +++ b/firmware/common/modules.h @@ -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,}; diff --git a/firmware/portapack-h1-firmware.bin b/firmware/portapack-h1-firmware.bin index a6059fd9..f852f729 100644 Binary files a/firmware/portapack-h1-firmware.bin and b/firmware/portapack-h1-firmware.bin differ diff --git a/sdcard/baseband-tx.bin b/sdcard/baseband-tx.bin index 7ee70f4d..002a8983 100644 Binary files a/sdcard/baseband-tx.bin and b/sdcard/baseband-tx.bin differ diff --git a/sdcard/baseband.bin b/sdcard/baseband.bin index 187b9c21..08ce9eee 100644 Binary files a/sdcard/baseband.bin and b/sdcard/baseband.bin differ