#include "exception.h" #include "system.h" #include "bsp_time.h" #include "nrf_delay.h" #include "hal_wearshoes.h" #include "hal_ble_host.h" #include "hal_ble_client.h" #include "hal_ble_host.h" #include "app_flash.h" #include "ble_comm.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(); DEBUG_LOG("fps=%dms,cnt=%d\n",fps_max,cnt_max); fps_max = 0; } tem1 = NRF_RTC0->COUNTER; #endif } //休眠时间 ms static 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(uint8_t 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++; // DEBUG_LOG("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(); // DEBUG_LOG("\n============ Tatol(%d process) : %d us ==========\n",process_dex,fps_max); // for(i=0;i500) // DEBUG_LOG("[%d]%s : %d us\n",i,mProcess[i].name,mProcess[i].useTime); // mProcess[i].useTime = 0; // } // DEBUG_LOG("\n",fps_max); // fps_max = 0; // } // tem1 = NRF_RTC0->COUNTER; #endif return ret; } //!!!!!!!!测试使用 //!!!!!!!!!!!!!!! //static void cb_Client_PROCESS_TIME(void* handle) //{ // char buf[100]={0}; // uint8_t i=0; // BLE_Client_Rx_t* target = handle; // DEBUG_LOG("cb_Client_PROCESS_TIME:%d,%d\n",target->pDat[0],mFlash.isHost); // if(0x00 == target->pDat[0] && mFlash.isHost){//获取左鞋线程耗时的情况 // memset(buf,0,sizeof(buf)); // sprintf(buf,"left sleep time : %d us\n",process_sleep_time); // send_bytes_client((uint8_t *)buf,strlen(buf)); // for(i=0;ipDat,target->datLen); // } // else if(0x01 == target->pDat[0] && !mFlash.isHost){//获取右鞋线程耗时的情况 // memset(buf,0,sizeof(buf)); // sprintf(buf,"Right sleep time : %d us\n",process_sleep_time); // BLE_Client_Tx_Send(0,BLE_PROCESS_TIME,(uint8_t *)buf,strlen(buf)); // for(i=0;ipDat[0]){//清除电量计算的信息 // extern battercb_t battery_record; // extern void cb_init(void); // extern void printbatter_cb(battercb_t *c,battercb_t *C_flash); // memset(&battery_record,0,sizeof(battercb_t)); // memset(&mFlash.mbattercb_t,0,sizeof(battercb_t)); // cb_init(); // BLE_Host_Tx_Send(0,BLE_PROCESS_TIME,target->pDat,target->datLen); // } // else BLE_Host_Tx_Send(0,BLE_PROCESS_TIME,target->pDat,target->datLen); // // if(0x02 == target->pDat[0]){ // for(i=0;ipDat,target->datLen); //} //大循环 void USR_Process(void) { //app进程调度 if(Process_App()==0){ //进入低功耗模式 Sleep_Event(); systermSleepTime = rtc_sleep(hal_wearshoes_is_wearshoes()); // DEBUG_LOG("process_sleep_time:%d\n",process_sleep_time); Wakeup_Event(); } FPS_process(); // static uint8_t state =0; // if(0 == state){state =1; // BLE_Client_Rx_Regist(BLE_PROCESS_TIME,cb_Client_PROCESS_TIME); // BLE_Host_Rx_Regist(BLE_PROCESS_TIME,cb_Host_PROCESS_TIME); // } }