mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Move BasebandStatsCollector code into .cpp, as much as possible.
Still have template for callback, but hopefully will mitigate bloat when BasebandStatsCollector is used in multiple places.
This commit is contained in:
parent
6d3cdb9bbf
commit
b42d3cc9d5
@ -130,6 +130,7 @@ CPPSRC = main.cpp \
|
|||||||
portapack_shared_memory.cpp \
|
portapack_shared_memory.cpp \
|
||||||
baseband_thread.cpp \
|
baseband_thread.cpp \
|
||||||
baseband_processor.cpp \
|
baseband_processor.cpp \
|
||||||
|
baseband_stats_collector.cpp \
|
||||||
dsp_decimate.cpp \
|
dsp_decimate.cpp \
|
||||||
dsp_demodulate.cpp \
|
dsp_demodulate.cpp \
|
||||||
matched_filter.cpp \
|
matched_filter.cpp \
|
||||||
|
59
firmware/baseband/baseband_stats_collector.cpp
Normal file
59
firmware/baseband/baseband_stats_collector.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* 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 "baseband_stats_collector.hpp"
|
||||||
|
|
||||||
|
#include "utility_m4.hpp"
|
||||||
|
|
||||||
|
bool BasebandStatsCollector::process(const buffer_c8_t& buffer) {
|
||||||
|
samples += buffer.count;
|
||||||
|
|
||||||
|
const size_t report_samples = buffer.sampling_rate * report_interval;
|
||||||
|
const auto report_delta = samples - samples_last_report;
|
||||||
|
return report_delta >= report_samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
BasebandStatistics BasebandStatsCollector::capture_statistics() {
|
||||||
|
BasebandStatistics statistics;
|
||||||
|
|
||||||
|
const auto idle_ticks = thread_idle->total_ticks;
|
||||||
|
statistics.idle_ticks = (idle_ticks - last_idle_ticks);
|
||||||
|
last_idle_ticks = idle_ticks;
|
||||||
|
|
||||||
|
const auto main_ticks = thread_main->total_ticks;
|
||||||
|
statistics.main_ticks = (main_ticks - last_main_ticks);
|
||||||
|
last_main_ticks = main_ticks;
|
||||||
|
|
||||||
|
const auto rssi_ticks = thread_rssi->total_ticks;
|
||||||
|
statistics.rssi_ticks = (rssi_ticks - last_rssi_ticks);
|
||||||
|
last_rssi_ticks = rssi_ticks;
|
||||||
|
|
||||||
|
const auto baseband_ticks = thread_baseband->total_ticks;
|
||||||
|
statistics.baseband_ticks = (baseband_ticks - last_baseband_ticks);
|
||||||
|
last_baseband_ticks = baseband_ticks;
|
||||||
|
|
||||||
|
statistics.saturation = m4_flag_saturation();
|
||||||
|
clear_m4_flag_saturation();
|
||||||
|
|
||||||
|
samples_last_report = samples;
|
||||||
|
|
||||||
|
return statistics;
|
||||||
|
}
|
@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include "dsp_types.hpp"
|
#include "dsp_types.hpp"
|
||||||
#include "message.hpp"
|
#include "message.hpp"
|
||||||
#include "utility_m4.hpp"
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
@ -47,35 +46,8 @@ public:
|
|||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void process(const buffer_c8_t& buffer, Callback callback) {
|
void process(const buffer_c8_t& buffer, Callback callback) {
|
||||||
samples += buffer.count;
|
if( process(buffer) ) {
|
||||||
|
callback(capture_statistics());
|
||||||
const size_t report_samples = buffer.sampling_rate * report_interval;
|
|
||||||
const auto report_delta = samples - samples_last_report;
|
|
||||||
if( report_delta >= report_samples ) {
|
|
||||||
BasebandStatistics statistics;
|
|
||||||
|
|
||||||
const auto idle_ticks = thread_idle->total_ticks;
|
|
||||||
statistics.idle_ticks = (idle_ticks - last_idle_ticks);
|
|
||||||
last_idle_ticks = idle_ticks;
|
|
||||||
|
|
||||||
const auto main_ticks = thread_main->total_ticks;
|
|
||||||
statistics.main_ticks = (main_ticks - last_main_ticks);
|
|
||||||
last_main_ticks = main_ticks;
|
|
||||||
|
|
||||||
const auto rssi_ticks = thread_rssi->total_ticks;
|
|
||||||
statistics.rssi_ticks = (rssi_ticks - last_rssi_ticks);
|
|
||||||
last_rssi_ticks = rssi_ticks;
|
|
||||||
|
|
||||||
const auto baseband_ticks = thread_baseband->total_ticks;
|
|
||||||
statistics.baseband_ticks = (baseband_ticks - last_baseband_ticks);
|
|
||||||
last_baseband_ticks = baseband_ticks;
|
|
||||||
|
|
||||||
statistics.saturation = m4_flag_saturation();
|
|
||||||
clear_m4_flag_saturation();
|
|
||||||
|
|
||||||
callback(statistics);
|
|
||||||
|
|
||||||
samples_last_report = samples;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +63,9 @@ private:
|
|||||||
uint32_t last_rssi_ticks { 0 };
|
uint32_t last_rssi_ticks { 0 };
|
||||||
const Thread* const thread_baseband;
|
const Thread* const thread_baseband;
|
||||||
uint32_t last_baseband_ticks { 0 };
|
uint32_t last_baseband_ticks { 0 };
|
||||||
|
|
||||||
|
bool process(const buffer_c8_t& buffer);
|
||||||
|
BasebandStatistics capture_statistics();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif/*__BASEBAND_STATS_COLLECTOR_H__*/
|
#endif/*__BASEBAND_STATS_COLLECTOR_H__*/
|
||||||
|
Loading…
Reference in New Issue
Block a user