|
@@ -5,6 +5,17 @@
|
|
#include "hal_wearshoes.h"
|
|
#include "hal_wearshoes.h"
|
|
|
|
|
|
|
|
|
|
|
|
+typedef struct _Task_UseTime
|
|
|
|
+{
|
|
|
|
+ uint32_t task_id;
|
|
|
|
+ uint32_t task_us;
|
|
|
|
+ uint32_t total_us;
|
|
|
|
+} Task_UseTime_t;
|
|
|
|
+
|
|
|
|
+static int _report_task_useTime_code = 0;
|
|
|
|
+static bool is_report_task_useTime = false;
|
|
|
|
+static Task_UseTime_t last_round_task_max_useTime = {0xFFFFFFFF,0,0},cur_round_task_max_useTime = {0xFFFFFFFF,0,0},all_round_task_max_useTime = {0xFFFFFFFF,0,0};
|
|
|
|
+
|
|
//系统函数
|
|
//系统函数
|
|
void FPS_process(void)
|
|
void FPS_process(void)
|
|
{
|
|
{
|
|
@@ -159,6 +170,12 @@ int Process_App(void)
|
|
{
|
|
{
|
|
int ret = 0;
|
|
int ret = 0;
|
|
uint8_t i = 0;
|
|
uint8_t i = 0;
|
|
|
|
+ char buf[256];
|
|
|
|
+ uint32_t task_useTime = 0;
|
|
|
|
+
|
|
|
|
+ cur_round_task_max_useTime.task_id = 0xFFFFFFFF;
|
|
|
|
+ cur_round_task_max_useTime.task_us = 0;
|
|
|
|
+ cur_round_task_max_useTime.total_us = 0;
|
|
|
|
|
|
for(i=0;i<process_dex;i++){
|
|
for(i=0;i<process_dex;i++){
|
|
Except_Get_Cur_Porcess_ID(i);
|
|
Except_Get_Cur_Porcess_ID(i);
|
|
@@ -167,11 +184,31 @@ int Process_App(void)
|
|
#if ProcessTime_EN
|
|
#if ProcessTime_EN
|
|
uint32_t useTime = NRF_RTC0->COUNTER;
|
|
uint32_t useTime = NRF_RTC0->COUNTER;
|
|
#endif
|
|
#endif
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ uint32_t cnt1 = NRF_RTC0->COUNTER;
|
|
|
|
+
|
|
if(mProcess[i].Peroid ==0) mProcess[i].cb();
|
|
if(mProcess[i].Peroid ==0) mProcess[i].cb();
|
|
else if(TIME_GetTicks()-mProcess[i].tim >= mProcess[i].Peroid ){
|
|
else if(TIME_GetTicks()-mProcess[i].tim >= mProcess[i].Peroid ){
|
|
mProcess[i].tim = TIME_GetTicks();
|
|
mProcess[i].tim = TIME_GetTicks();
|
|
mProcess[i].cb();
|
|
mProcess[i].cb();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ uint32_t cnt2 = NRF_RTC0->COUNTER;
|
|
|
|
+
|
|
|
|
+ if(cnt2<cnt1) cnt2 += 16777216;
|
|
|
|
+
|
|
|
|
+ task_useTime = (cnt2-cnt1)/32.768 * 1000;
|
|
|
|
+
|
|
|
|
+ cur_round_task_max_useTime.total_us += task_useTime;
|
|
|
|
+
|
|
|
|
+ if(task_useTime > cur_round_task_max_useTime.task_us)
|
|
|
|
+ {
|
|
|
|
+ cur_round_task_max_useTime.task_us = task_useTime;
|
|
|
|
+ cur_round_task_max_useTime.task_id = i;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
#if ProcessTime_EN
|
|
#if ProcessTime_EN
|
|
if(NRF_RTC0->COUNTER<useTime) useTime = (NRF_RTC0->COUNTER+16777216-useTime);
|
|
if(NRF_RTC0->COUNTER<useTime) useTime = (NRF_RTC0->COUNTER+16777216-useTime);
|
|
else useTime = (NRF_RTC0->COUNTER-useTime);
|
|
else useTime = (NRF_RTC0->COUNTER-useTime);
|
|
@@ -180,6 +217,34 @@ int Process_App(void)
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if(cur_round_task_max_useTime.task_us > all_round_task_max_useTime.task_us)
|
|
|
|
+ {
|
|
|
|
+ all_round_task_max_useTime.task_us = cur_round_task_max_useTime.task_us;
|
|
|
|
+ all_round_task_max_useTime.task_id = cur_round_task_max_useTime.task_id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(is_report_task_useTime)
|
|
|
|
+ {
|
|
|
|
+ sprintf(buf,"code:%d,report useTime:%d,%d,%d,%d,%d,%d,%d,%d\r\n",_report_task_useTime_code, \
|
|
|
|
+ last_round_task_max_useTime.task_id, \
|
|
|
|
+ last_round_task_max_useTime.task_us, \
|
|
|
|
+ last_round_task_max_useTime.total_us, \
|
|
|
|
+ cur_round_task_max_useTime.task_id, \
|
|
|
|
+ cur_round_task_max_useTime.task_us, \
|
|
|
|
+ cur_round_task_max_useTime.total_us, \
|
|
|
|
+ all_round_task_max_useTime.task_id, \
|
|
|
|
+ all_round_task_max_useTime.task_us);
|
|
|
|
+ Except_TxError(EXCEPT_EXCEPTION,buf);
|
|
|
|
+
|
|
|
|
+ is_report_task_useTime = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ last_round_task_max_useTime.task_us = cur_round_task_max_useTime.task_us;
|
|
|
|
+ last_round_task_max_useTime.total_us = cur_round_task_max_useTime.total_us;
|
|
|
|
+ last_round_task_max_useTime.task_id = cur_round_task_max_useTime.task_id;
|
|
|
|
+
|
|
|
|
+
|
|
for(i=0;i<process_dex;i++){
|
|
for(i=0;i<process_dex;i++){
|
|
if(mProcess[i].holdon){
|
|
if(mProcess[i].holdon){
|
|
ret = 1; //不能进入低功耗
|
|
ret = 1; //不能进入低功耗
|
|
@@ -216,6 +281,13 @@ int Process_App(void)
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//触发上报上一轮、当前轮、所有轮任务中最大的耗时任务和ID,因为实时性的原因,所以不作保证性发送。
|
|
|
|
+void Process_report_task_useTime(int report_task_useTime_code)
|
|
|
|
+{
|
|
|
|
+ _report_task_useTime_code = report_task_useTime_code;
|
|
|
|
+ is_report_task_useTime = true;
|
|
|
|
+}
|
|
|
|
+
|
|
//大循环
|
|
//大循环
|
|
void USR_Process(void)
|
|
void USR_Process(void)
|
|
{
|
|
{
|