12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #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 "app_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");
- nrf_gpio_cfg_output(PIN_RESET_PIN); nrf_gpio_pin_write(PIN_RESET_PIN,0);
- }
- 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;i<ERR_NUM_OF_T;i++){
- if(errTab[i]>0){ 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_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_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_ERR,cb_BLE_Host_R_ERR);
- }
|