#include "system.h" #include "bsp_time.h" #include "nrf_delay.h" #include "hal_wearshoes.h" #include "tool.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=1000){ 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 sprintf(mProcess[process_dex].name_t,"%s",name); #endif process_dex++; SEGGER_RTT_printf(0,"process num(%d):%s\n",process_dex-1,name); return 0; } void Process_Stop(PROCESS_cb cb) { for(uint8_t i=0;icnt1_rtc = NRF_RTC0->COUNTER; #endif uint32_t cnt1 = 0, cnt2 = 0; if(mProcess[i].Peroid ==0){ // cnt1 = NRF_RTC0->COUNTER; mProcess[i].cb(); // cnt2 = NRF_RTC0->COUNTER; // counters[i] = (cnt2-cnt1)/32.768 * 1000; } else if(TIME_GetTicks()-mProcess[i].tim >= mProcess[i].Peroid ){ mProcess[i].tim = TIME_GetTicks(); // cnt1 = NRF_RTC0->COUNTER; mProcess[i].cb(); // cnt2 = NRF_RTC0->COUNTER; // counters[i] = (cnt2-cnt1)/32.768 * 1000; } #if ProcessTime_EN target->cnt2_rtc = NRF_RTC0->COUNTER; #endif } if(mProcess[i].holdon) { ret = 1; //不能进入低功耗 static uint32_t tim =0; if(TIME_GetTicks()-tim>=1000){tim = TIME_GetTicks(); SEGGER_RTT_printf(0,"======>mProcess[%d].holdon\r\n",i); } } } // static uint32_t tim =0; // static uint32_t cur_task = 0; // if(TIME_GetTicks()-tim>=1000){tim = TIME_GetTicks(); // if(cur_task < process_dex){ // JS_RTT_Print_06(cur_task,counters[cur_task],process_dex,0,0,0); // cur_task++; // }else{ // cur_task = 0; // } // } #if ProcessTime_EN char Display[100]={0}; static uint32_t tim =0; if(TIME_GetTicks()-tim>=DisInterval){ tim = TIME_GetTicks(); for(target=head_handle;target;target=target->next){ if(target->cb && target->cnt2_rtc >= (target->cnt1_rtc +2)) { sprintf(Display,"%s, time:%02f us\n",target->name_t,(target->cnt2_rtc-target->cnt1_rtc)/32.768 * 1000); SEGGER_RTT_printf(0,"%s",Display); memset(Display,0,sizeof(Display)); } } } #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(); SEGGER_RTT_printf(0,"Wakeup(%d)...\n",systermSleepTime); } FPS_process(); }