Merge branch 'eried:next' into next

This commit is contained in:
Mark Thompson
2023-04-26 01:25:46 -05:00
committed by GitHub
21 changed files with 442 additions and 72 deletions

View File

@@ -139,6 +139,7 @@ set(CPPSRC
${COMMON}/chibios_cpp.cpp
debug.cpp
${COMMON}/gcc.cpp
${COMMON}/performance_counter.cpp
tone_gen.cpp
)

View File

@@ -508,6 +508,8 @@
}
#endif
/**
* @brief System tick event hook.
* @details This hook is invoked in the system tick handler immediately
@@ -516,6 +518,8 @@
#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
#define SYSTEM_TICK_EVENT_HOOK() { \
/* System tick event code here.*/ \
extern void update_performance_counters(); \
update_performance_counters(); \
}
#endif

View File

@@ -26,6 +26,7 @@
#include <hal.h>
#include "portapack_shared_memory.hpp"
#include "performance_counter.hpp"
void write_m4_panic_msg(const char *panic_message, struct extctx *ctxp) {
if (ctxp == nullptr) {
@@ -116,5 +117,28 @@ CH_IRQ_HANDLER(HardFaultVector) {
#endif
}
void update_performance_counters() {
auto performance_counter_active = shared_memory.request_m4_performance_counter;
if (performance_counter_active == 0x00)
return;
static bool last_paint_state = false;
if ((((chTimeNow()>>10) & 0x01) == 0x01) == last_paint_state)
return;
// Idle thread state is sometimes unuseable
if (chThdGetTicks(chSysGetIdleThread()) > 0x10000000)
return;
last_paint_state = !last_paint_state;
auto utilisation = get_cpu_utilisation_in_percent();
auto free_stack = (uint32_t)get_free_stack_space();
auto free_heap = chCoreStatus();
shared_memory.m4_cpu_usage = utilisation;
shared_memory.m4_stack_usage = free_stack;
shared_memory.m4_heap_usage = free_heap;
}
} /* extern "C" */

View File

@@ -20,6 +20,7 @@
*/
#include "event_m4.hpp"
#include "debug.hpp"
#include "portapack_shared_memory.hpp"
@@ -120,3 +121,4 @@ void EventDispatcher::handle_spectrum() {
const UpdateSpectrumMessage message;
baseband_processor->on_message(&message);
}

View File

@@ -45,3 +45,5 @@ int main() {
return 0;
}
void update_performance_counters() {}