mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
AP_HAL_ChibiOS: add support for idle-hook based true CPU load
allow idle stats to be turned off
This commit is contained in:
committed by
Andrew Tridgell
parent
2a9318fe58
commit
6e86351aeb
@@ -20,6 +20,7 @@
|
||||
#include <hal.h>
|
||||
#include "Util.h"
|
||||
#include <ch.h>
|
||||
#include <sysperf.h>
|
||||
#include "RCOutput.h"
|
||||
#include "UARTDriver.h"
|
||||
#include "hwdef/common/stm32_util.h"
|
||||
@@ -42,8 +43,8 @@
|
||||
#include <AP_Logger/AP_Logger.h>
|
||||
#endif
|
||||
|
||||
#if HAL_WITH_IO_MCU
|
||||
#include <AP_BoardConfig/AP_BoardConfig.h>
|
||||
#if HAL_WITH_IO_MCU
|
||||
#include <AP_IOMCU/AP_IOMCU.h>
|
||||
extern AP_IOMCU iomcu;
|
||||
#endif
|
||||
@@ -380,14 +381,20 @@ __RAMFUNC__ void Util::thread_info(ExpandingString &str)
|
||||
#endif
|
||||
// a header to allow for machine parsers to determine format
|
||||
const uint32_t isr_stack_size = uint32_t((const uint8_t *)&__main_stack_end__ - (const uint8_t *)&__main_stack_base__);
|
||||
#if AP_CPU_IDLE_STATS_ENABLED && HAL_USE_LOAD_MEASURE
|
||||
if (AP_BoardConfig::use_idle_stats()) {
|
||||
str.printf("%-13.13s LOAD=%4.1f%% PEAK=%4.1f%%\n", "ThreadsV3", (sysGetCPUAverageLoad() / 100.0f), (sysGetCPUPeakLoad() / 100.0f));
|
||||
} else
|
||||
#endif
|
||||
str.printf("ThreadsV2\n");
|
||||
#if HAL_ENABLE_THREAD_STATISTICS
|
||||
str.printf("ThreadsV2\nISR PRI=255 sp=%p STACK=%u/%u LOAD=%4.1f%%\n",
|
||||
str.printf("ISR PRI=255 sp=%p STACK=%u/%u LOAD=%4.1f%%\n",
|
||||
&__main_stack_base__,
|
||||
unsigned(stack_free(&__main_stack_base__)),
|
||||
unsigned(isr_stack_size), 100.0f * float(currcore->kernel_stats.m_crit_isr.cumulative) / float(cumulative_cycles));
|
||||
currcore->kernel_stats.m_crit_isr.cumulative = 0U;
|
||||
#else
|
||||
str.printf("ThreadsV2\nISR PRI=255 sp=%p STACK=%u/%u\n",
|
||||
str.printf("ISR PRI=255 sp=%p STACK=%u/%u\n",
|
||||
&__main_stack_base__,
|
||||
unsigned(stack_free(&__main_stack_base__)),
|
||||
unsigned(isr_stack_size));
|
||||
@@ -430,9 +437,30 @@ __RAMFUNC__ void Util::thread_info(ExpandingString &str)
|
||||
unsigned(stack_free(tp->wabase)), unsigned(total_stack));
|
||||
#endif
|
||||
}
|
||||
#if AP_CPU_IDLE_STATS_ENABLED && HAL_USE_LOAD_MEASURE
|
||||
if (AP_BoardConfig::use_idle_stats()) {
|
||||
sysStopLoadMeasure();
|
||||
sysStartLoadMeasure();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // CH_DBG_ENABLE_STACK_CHECK == TRUE
|
||||
|
||||
// get the system load
|
||||
bool Util::get_system_load(float& avg_load, float& peak_load) const
|
||||
{
|
||||
#if AP_CPU_IDLE_STATS_ENABLED && HAL_USE_LOAD_MEASURE
|
||||
if (AP_BoardConfig::use_idle_stats()) {
|
||||
avg_load = sysGetCPUAverageLoad() / 100.0f;
|
||||
peak_load = sysGetCPUPeakLoad() / 100.0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if CH_CFG_USE_SEMAPHORES
|
||||
// request information on dma contention
|
||||
void Util::dma_info(ExpandingString &str)
|
||||
|
||||
Reference in New Issue
Block a user