#include "exception.h" #include "system.h" #include "bsp_time.h" #include "nrf_delay.h" #include "hal_wearshoes.h" //系统函数 void FPS_process(void) { #if DEBUG_FPS static uint32_t tem1 = 0; static uint32_t tem2 = 0; static uint32_t fps_max=0; static uint32_t cnt_max=0; uint32_t fps; tem2 = NRF_RTC0->COUNTER; if(tem2=5000){ tim = TIME_GetTicks(); SEGGER_RTT_printf(0,"fps=%dms,cnt=%d\n",fps_max,cnt_max); fps_max = 0; } tem1 = NRF_RTC0->COUNTER; #endif } //休眠时间 ms uint32_t systermSleepTime = 1000; static uint8_t sleep_num = 0; static Sleep_cb sleep_cb[sleep_cb_max]={0}; int Sleep_Regist(Sleep_cb cb) { for(int i=0;i=process_max) return -1; mProcess[process_dex].cb = cb; mProcess[process_dex].enable =1; mProcess[process_dex].Peroid = peroid; mProcess[process_dex].tim = TIME_GetTicks(); #if ProcessTime_EN mProcess[process_dex].name = name; #endif process_dex++; // SEGGER_RTT_printf(0,"process num(%d)\n",process_dex); return 0; } void Process_Stop(PROCESS_cb cb) { for(uint8_t i=0;iCOUNTER; #endif if(mProcess[i].Peroid ==0) mProcess[i].cb(); else if(TIME_GetTicks()-mProcess[i].tim >= mProcess[i].Peroid ){ mProcess[i].tim = TIME_GetTicks(); mProcess[i].cb(); } #if ProcessTime_EN if(NRF_RTC0->COUNTERCOUNTER+16777216-useTime); else useTime = (NRF_RTC0->COUNTER-useTime); useTime = useTime*1000/32.768; if(mProcess[i].useTimeCOUNTER; if(tem2=DisInterval){ tim = TIME_GetTicks(); // SEGGER_RTT_printf(0,"\n========== infomation ==========\n"); SEGGER_RTT_printf(0,"\n============ Tatol(%d process) : %d us ==========\n",process_dex,fps_max); for(i=0;i500) SEGGER_RTT_printf(0,"[%d]%s : %d us\n",i,mProcess[i].name,mProcess[i].useTime); mProcess[i].useTime = 0; } SEGGER_RTT_printf(0,"\n",fps_max); fps_max = 0; } tem1 = NRF_RTC0->COUNTER; #endif return ret; } //大循环 void USR_Process(void) { //app进程调度 if(Process_App()==0){ //进入低功耗模式 Sleep_Event(); systermSleepTime = rtc_sleep(hal_wearshoes_is_wearshoes()); if(systermSleepTime==0){ systermSleepTime = 13; nrf_delay_ms(systermSleepTime); } Wakeup_Event(); } FPS_process(); }