Files
BR_YKC/Core/User/Global/g_runtime.c

92 lines
1.9 KiB
C
Raw Normal View History

2026-03-31 15:46:04 +08:00
/**
2026-05-21 12:19:01 +08:00
******************************************************************************
* @file User\Global\g_runtime.c
* @author
* @version v0.1
* @date 2026-05-21
* @brief
******************************************************************************
*/
2026-03-31 15:46:04 +08:00
/* Includes -------------------------------------------------------------------*/
#include "g_runtime.h"
/* variables ------------------------------------------------------------------*/
TaskRunTimeTypeDef TaskRunTimeStat;
/* code -----------------------------------------------------------------------*/
/**
* @brief GetRunTime线
*
* @note none
*
* @param taskID : ID
*
* @retval runtime :
*/
uint32_t GetTask_RunTime(uint8_t taskID)
{
static uint32_t lasttime[Task_combined] = {0};
uint32_t runtime = 0;
uint32_t curtime = HAL_GetTick();
runtime = curtime - lasttime[taskID]; //计算线程运行间隔时间 runtime运行一次
lasttime[taskID] = curtime;
return runtime;
}
/**
* @brief GetTask_Beatcnt线,线
*
* @note none
*
* @param taskID : ID
*
* @retval beatcnt[taskID] : 线
*/
uint32_t GetTask_Beatcnt(uint8_t taskID)
{
static uint8_t beatcnt[Task_combined] = {0};
beatcnt[taskID]++;
if(beatcnt[taskID] >= 10)
{
beatcnt[taskID] = 0;
}
return beatcnt[taskID];
}
/**
* @brief Get_Free_Stack
*
* @note none
*
* @param taskID : ID
*
* @retval free_stack[taskID] :
*/
uint32_t Get_Free_Stack(uint8_t taskID)
{
static uint32_t free_stack[Task_combined] = {0};
free_stack[taskID] = uxTaskGetStackHighWaterMark(NULL);
return free_stack[taskID];
}