#include "app_err.h" #include "usr_config.h" #include "bsp_time.h" #include "system.h" #include "hal_ble_client.h" #include "hal_ble_host.h" #include "nrf_delay.h" #include "hal_flash.h" #include "hal_imu.h" #include "ble_comm.h" #include "app_error.h" #include "app_client_infomation.h" #include "app_util_platform.h" #include "nrf_strerror.h" #include "hal_flash.h" /********************** 函数声明区 *************************/ static uint8_t errDex = 0; static uint8_t errTab[ERR_NUM_OF_T]; //错误回调 void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) { Flash_SaveLog(id,pc,info); SEGGER_RTT_printf(0,"app_error_fault_handler,System reset\n"); __disable_irq(); NVIC_SystemReset(); } void app_err_Set(uint8_t errNum,uint8_t errTimes) { if(errNum>=ERR_NUM_OF_T) return; errTab[errNum] = errTimes; } void app_err_Process(void) { for(int i=0;i0){ errTab[i]--; uint8_t buf[16]; uint8_t L=0; L=0; buf[L++] = errDex; //0左鞋1右鞋 buf[L++] = i; //错误编号 BLE_Client_Tx_Send(0,BLE_Client_T_ERR,buf,L); } } static uint8_t timflag=0; timflag++; if(timflag>=5){ timflag =0; if(1 == mFlash.mFlashLog.Errorflag)app_client_infomation_Send_defineName(mFlash.mFlashLog.logData,strlen((const char *)mFlash.mFlashLog.logData)); } } void cb_BLE_Host_R_ERR(void* handle) { BLE_Host_Rx_t* target = handle; BLE_Client_Tx_Send(0,BLE_Client_T_ERR,target->pDat,target->datLen); } void app_err_Init(void) { if(mFlash.isHost==0) errDex = 1; memset(errTab,0,sizeof(errTab)); Process_Start(3000,"app_err",app_err_Process); BLE_Host_Rx_Regist(BLE_Host_R_ERR,cb_BLE_Host_R_ERR); }