diff --git a/flight/OpenPilot/System/inc/FreeRTOSConfig.h b/flight/OpenPilot/System/inc/FreeRTOSConfig.h index 8027ecd0f..f82ab3875 100644 --- a/flight/OpenPilot/System/inc/FreeRTOSConfig.h +++ b/flight/OpenPilot/System/inc/FreeRTOSConfig.h @@ -71,6 +71,16 @@ configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest NVIC value of 255. */ #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 +/* Enable run time stats collection */ +#if defined(DEBUG) +#define configGENERATE_RUN_TIME_STATS 1 +#define INCLUDE_uxTaskGetRunTime 1 +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() +// Note: Using the tick count defeats the purpose here, need some timer on the scale of 10khz +#define portGET_RUN_TIME_COUNTER_VALUE() xTaskGetTickCount() +#endif + + /** * @} */ diff --git a/flight/OpenPilot/System/taskmonitor.c b/flight/OpenPilot/System/taskmonitor.c index 47f64f93b..b4dc65a68 100644 --- a/flight/OpenPilot/System/taskmonitor.c +++ b/flight/OpenPilot/System/taskmonitor.c @@ -39,7 +39,7 @@ static xTaskHandle handles[TASKINFO_RUNNING_NUMELEM]; // Private functions /** - * Initialize library + * Initialize library */ int32_t TaskMonitorInitialize(void) { @@ -49,7 +49,7 @@ int32_t TaskMonitorInitialize(void) } /** - * Register a task handle with the library + * Register a task handle with the library */ int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle) { @@ -85,7 +85,7 @@ int32_t TaskMonitorRemove(TaskInfoRunningElem task) } /** - * Update the status of all tasks + * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { @@ -105,7 +105,12 @@ void TaskMonitorUpdateAll(void) data.StackRemaining[n] = 10000; #else data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + /* Generate run time stats */ + data.RunningTime[n] = uxTaskGetRunTime(handles[n]); #endif +#endif + } else { diff --git a/shared/uavobjectdefinition/taskinfo.xml b/shared/uavobjectdefinition/taskinfo.xml index 4542e1b1c..4315c7c38 100644 --- a/shared/uavobjectdefinition/taskinfo.xml +++ b/shared/uavobjectdefinition/taskinfo.xml @@ -3,6 +3,7 @@ Task information +