mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-25 09:01:12 -05:00
Add tick tracking for all baseband threads.
This commit is contained in:
parent
aa733b1b61
commit
7f46f0d071
@ -33,6 +33,18 @@
|
|||||||
|
|
||||||
class BasebandStatsCollector {
|
class BasebandStatsCollector {
|
||||||
public:
|
public:
|
||||||
|
BasebandStatsCollector(
|
||||||
|
const Thread* const thread_idle,
|
||||||
|
const Thread* const thread_main,
|
||||||
|
const Thread* const thread_rssi,
|
||||||
|
const Thread* const thread_baseband
|
||||||
|
) : thread_idle { thread_idle },
|
||||||
|
thread_main { thread_main },
|
||||||
|
thread_rssi { thread_rssi },
|
||||||
|
thread_baseband { thread_baseband }
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void process(buffer_c8_t buffer, Callback callback) {
|
void process(buffer_c8_t buffer, Callback callback) {
|
||||||
samples += buffer.count;
|
samples += buffer.count;
|
||||||
@ -40,11 +52,19 @@ public:
|
|||||||
const size_t report_samples = buffer.sampling_rate * report_interval;
|
const size_t report_samples = buffer.sampling_rate * report_interval;
|
||||||
const auto report_delta = samples - samples_last_report;
|
const auto report_delta = samples - samples_last_report;
|
||||||
if( report_delta >= report_samples ) {
|
if( report_delta >= report_samples ) {
|
||||||
const auto idle_ticks = chSysGetIdleThread()->total_ticks;
|
const auto idle_ticks = thread_idle->total_ticks;
|
||||||
statistics.idle_ticks = (idle_ticks - last_idle_ticks);
|
statistics.idle_ticks = (idle_ticks - last_idle_ticks);
|
||||||
last_idle_ticks = idle_ticks;
|
last_idle_ticks = idle_ticks;
|
||||||
|
|
||||||
const auto baseband_ticks = chThdSelf()->total_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);
|
statistics.baseband_ticks = (baseband_ticks - last_baseband_ticks);
|
||||||
last_baseband_ticks = baseband_ticks;
|
last_baseband_ticks = baseband_ticks;
|
||||||
|
|
||||||
@ -62,7 +82,13 @@ private:
|
|||||||
BasebandStatistics statistics;
|
BasebandStatistics statistics;
|
||||||
size_t samples { 0 };
|
size_t samples { 0 };
|
||||||
size_t samples_last_report { 0 };
|
size_t samples_last_report { 0 };
|
||||||
|
const Thread* const thread_idle;
|
||||||
uint32_t last_idle_ticks { 0 };
|
uint32_t last_idle_ticks { 0 };
|
||||||
|
const Thread* const thread_main;
|
||||||
|
uint32_t last_main_ticks { 0 };
|
||||||
|
const Thread* const thread_rssi;
|
||||||
|
uint32_t last_rssi_ticks { 0 };
|
||||||
|
const Thread* const thread_baseband;
|
||||||
uint32_t last_baseband_ticks { 0 };
|
uint32_t last_baseband_ticks { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,6 +82,9 @@
|
|||||||
constexpr auto baseband_thread_priority = NORMALPRIO + 20;
|
constexpr auto baseband_thread_priority = NORMALPRIO + 20;
|
||||||
constexpr auto rssi_thread_priority = NORMALPRIO + 10;
|
constexpr auto rssi_thread_priority = NORMALPRIO + 10;
|
||||||
|
|
||||||
|
const Thread* thread_main;
|
||||||
|
const Thread* thread_rssi;
|
||||||
|
|
||||||
static BasebandProcessor* baseband_processor { nullptr };
|
static BasebandProcessor* baseband_processor { nullptr };
|
||||||
static BasebandConfiguration baseband_configuration;
|
static BasebandConfiguration baseband_configuration;
|
||||||
|
|
||||||
@ -90,7 +93,12 @@ static __attribute__((noreturn)) msg_t baseband_fn(void *arg) {
|
|||||||
(void)arg;
|
(void)arg;
|
||||||
chRegSetThreadName("baseband");
|
chRegSetThreadName("baseband");
|
||||||
|
|
||||||
BasebandStatsCollector stats;
|
BasebandStatsCollector stats {
|
||||||
|
chSysGetIdleThread(),
|
||||||
|
thread_main,
|
||||||
|
thread_rssi,
|
||||||
|
chThdSelf()
|
||||||
|
};
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
// TODO: Place correct sampling rate into buffer returned here:
|
// TODO: Place correct sampling rate into buffer returned here:
|
||||||
@ -182,13 +190,15 @@ static void init() {
|
|||||||
rf::rssi::init();
|
rf::rssi::init();
|
||||||
touch::dma::init();
|
touch::dma::init();
|
||||||
|
|
||||||
chThdCreateStatic(baseband_thread_wa, sizeof(baseband_thread_wa),
|
thread_main = chThdSelf();
|
||||||
baseband_thread_priority, baseband_fn,
|
|
||||||
|
thread_rssi = chThdCreateStatic(rssi_thread_wa, sizeof(rssi_thread_wa),
|
||||||
|
rssi_thread_priority, rssi_fn,
|
||||||
nullptr
|
nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
chThdCreateStatic(rssi_thread_wa, sizeof(rssi_thread_wa),
|
chThdCreateStatic(baseband_thread_wa, sizeof(baseband_thread_wa),
|
||||||
rssi_thread_priority, rssi_fn,
|
baseband_thread_priority, baseband_fn,
|
||||||
nullptr
|
nullptr
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,8 @@ public:
|
|||||||
|
|
||||||
struct BasebandStatistics {
|
struct BasebandStatistics {
|
||||||
uint32_t idle_ticks { 0 };
|
uint32_t idle_ticks { 0 };
|
||||||
|
uint32_t main_ticks { 0 };
|
||||||
|
uint32_t rssi_ticks { 0 };
|
||||||
uint32_t baseband_ticks { 0 };
|
uint32_t baseband_ticks { 0 };
|
||||||
bool saturation { false };
|
bool saturation { false };
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user