diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 432ed932..4239708e 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -28,6 +28,9 @@ //TEST: Check AFSK transmit end, skips last bits ? //TEST: Imperial in whipcalc +//BUG: CPLD-related rx ok, tx bad, see portapack.cpp lines 214+ to disable CPLD overlay +//BUG: REPLAY See what's wrong with quality (format, or need for interpolation filter ?) +//TODO: REPLAY Convert C16 to C8 on M0 core //BUG: SCANNER Lock on frequency, if frequency jump, still locked on first one //BUG: SCANNER Multiple slices //BUG: REPLAY freezes when SD card not present diff --git a/firmware/application/replay_thread.cpp b/firmware/application/replay_thread.cpp index 67fec113..0942a58d 100644 --- a/firmware/application/replay_thread.cpp +++ b/firmware/application/replay_thread.cpp @@ -25,10 +25,6 @@ #include "baseband_api.hpp" #include "buffer_exchange.hpp" -// DEBUG: -#include "hackrf_gpio.hpp" -using namespace hackrf::one; - struct BasebandReplay { BasebandReplay(ReplayConfig* const config) { baseband::replay_start(config); @@ -90,10 +86,7 @@ Optional ReplayThread::run() { return read_result.error(); } - if (!buffers.put(buffer)) - for(;;){}; // DEBUG - - led_tx.toggle(); // DEBUG + buffers.put(buffer); } return { }; diff --git a/firmware/application/ui_replay_view.cpp b/firmware/application/ui_replay_view.cpp index 1c274c08..87cc2218 100644 --- a/firmware/application/ui_replay_view.cpp +++ b/firmware/application/ui_replay_view.cpp @@ -91,7 +91,7 @@ void ReplayView::set_file_list(const std::vector& file_li for (const auto& file : file_list) { bbd_file.open("/" + file.string()); - duration = bbd_file.size() / (2 * 2 * (sampling_rate / 8)); + duration = bbd_file.size() / (2 * 2 * sampling_rate / 4); file_options.emplace_back(file.string().substr(0, 8), duration); } options_files.set_options(file_options); diff --git a/firmware/application/ui_replay_view.hpp b/firmware/application/ui_replay_view.hpp index 3f708a60..607ea862 100644 --- a/firmware/application/ui_replay_view.hpp +++ b/firmware/application/ui_replay_view.hpp @@ -59,7 +59,7 @@ private: using option_t = std::pair; using options_t = std::vector; - static constexpr uint32_t sampling_rate = 1000000; + static constexpr uint32_t sampling_rate = 4000000; void toggle(); diff --git a/firmware/baseband/proc_replay.cpp b/firmware/baseband/proc_replay.cpp index ce6e0315..601af9ac 100644 --- a/firmware/baseband/proc_replay.cpp +++ b/firmware/baseband/proc_replay.cpp @@ -27,26 +27,40 @@ #include "utility.hpp" ReplayProcessor::ReplayProcessor() { + // TODO: Interpolation filter needed ! + + /*spectrum_interval_samples = baseband_fs / spectrum_rate_hz; + spectrum_samples = 0; + channel_spectrum.set_decimation_factor(1);*/ + } void ReplayProcessor::execute(const buffer_c8_t& buffer) { - /* 2.4576MHz, 2048 samples */ + /* 4MHz, 2048 samples */ size_t pos = 0; - for (size_t c = 0; c < 4; c++) { - if( stream ) { - const size_t bytes_to_read = sizeof(*buffer.p) * buffer.count / 4; - const auto result = stream->read(iq_buffer.p, bytes_to_read); - } + // File data is in C16 format, we need C8 + // File samplerate is 500kHz, we're at 4MHz + // iq_buffer can only be 512 samples (RAM limitation) + // For a full 2048-sample C8 buffer, we need: + // 2048 samples * 2 bytes per sample = 4096 bytes + // Since we're oversampling by 4M/500k = 8, we only need 2048/8 = 256 samples from the file + // So 256 * 4 bytes per sample (C16) = 1024 bytes from the file + if( stream ) { + const size_t bytes_to_read = sizeof(*buffer.p) * 2 * (buffer.count / 8); // *2 (C16), /8 (oversampling) + const auto result = stream->read(iq_buffer.p, bytes_to_read); + } - //feed_channel_stats(channel); - - for (size_t i = 0; i < (buffer.count / 4); i++) { - buffer.p[pos] = { iq_buffer.p[i].real() >> 8, iq_buffer.p[i].imag() >> 8 }; - pos++; - } + //feed_channel_stats(channel); + + // Zero-stuff + for (size_t i = 0; i < buffer.count; i++) { + if (i & 3) + buffer.p[i] = { 0, 0 }; + else + buffer.p[i] = { iq_buffer.p[i >> 3].real() >> 8, iq_buffer.p[i >> 3].imag() >> 8 }; } /*spectrum_samples += channel.count; diff --git a/firmware/baseband/proc_replay.hpp b/firmware/baseband/proc_replay.hpp index 34c20d8b..ebf7e69f 100644 --- a/firmware/baseband/proc_replay.hpp +++ b/firmware/baseband/proc_replay.hpp @@ -26,6 +26,8 @@ #include "baseband_processor.hpp" #include "baseband_thread.hpp" +#include "spectrum_collector.hpp" + #include "stream_output.hpp" #include @@ -40,14 +42,12 @@ public: void on_message(const Message* const message) override; private: - // TODO: Repeated value needs to be transmitted from application side. - static constexpr size_t baseband_fs = 1000000; + static constexpr size_t baseband_fs = 4000000; //static constexpr auto spectrum_rate_hz = 50.0f; BasebandThread baseband_thread { baseband_fs, this, NORMALPRIO + 20, baseband::Direction::Transmit }; - //RSSIThread rssi_thread { NORMALPRIO + 10 }; - std::array iq { }; // 2048 doesn't fit in allocated RAM + std::array iq { }; // This fits in just right in allocated RAM const buffer_c16_t iq_buffer { iq.data(), iq.size()