exception.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. /*Includes ----------------------------------------------*/
  2. #include "nrf_delay.h"
  3. #include "nrf_strerror.h"
  4. #include "ble_comm.h"
  5. #include "exception.h"
  6. #include "system.h"
  7. #include "bsp_time.h"
  8. #include "bsp_wdt.h"
  9. #include "hal_led.h"
  10. #include "hal_ble_client.h"
  11. #include "hal_ble_host.h"
  12. #include "app_flash.h"
  13. #include "app_error.h"
  14. #include "app_client.h"
  15. #include "app_flash.h"
  16. #include "app_util_platform.h"
  17. #include "bll_imu.h"
  18. #include "app_detectIsHost.h"
  19. /*Private macro ------------------------------------------------*/
  20. #define EXCEPT_LED_ON_ACC_Z 1500 //加速度Z轴触发异常灯开启
  21. #define EXCEPT_LED_OFF_ACC_Z -1500 //加速度Z轴触发异常灯关闭
  22. #define LED_PROCESS_CYCLE 200 //异常灯线程周期,ms为单位
  23. #define EXCEPT_LED_TOGGLE_TIME 200 //异常灯翻转周期,ms为单位
  24. #define EXCEPT_LED_DISPLAY_TIME 10000 //异常灯显示时长,ms为单位
  25. #define UNKOWN_RESET_INFO_SEND_CYCLE 100 //未知重启异常信息发送线程周期,ms为单位
  26. #define EXCEPT_NO_INIT_DATA_CHANGE_FLAG 0x01 //被更改标志位,每次修改结构体,都要加1
  27. #define __NO_INIT__ __attribute__((at(0x2000FFA0)))
  28. /*STRUCTION ----------------------------------------------------*/
  29. //原理如下:当异常时,硬件会将一些CPU的寄存器保存到栈中,通过在异常时获取堆栈指针SP的值,通过SP获取当前栈的位置,然后获取异常之前的PC指针的值,就知道异常的位置了。
  30. //这个就是CPU寄存器在栈中的排列
  31. //栈数据定义
  32. typedef struct
  33. {
  34. uint32_t R0;
  35. uint32_t R1;
  36. uint32_t R2;
  37. uint32_t R3;
  38. uint32_t R12;
  39. uint32_t LR;
  40. uint32_t PC;
  41. uint32_t xPSR;
  42. }STACK_DATA_TYPE;
  43. typedef struct
  44. {
  45. uint32_t wdt_remain_tim; //距离上次喂狗剩余时间,单位ms
  46. uint32_t thread_start_tim;
  47. uint32_t thread_end_tim;
  48. }WDT_INFO_TYPE;
  49. typedef struct
  50. {
  51. char buff[28];
  52. }APP_ERROR_CHECK_INFO_TYPE;
  53. typedef struct _process_info
  54. {
  55. STACK_DATA_TYPE stack;
  56. WDT_INFO_TYPE wdt_info;
  57. APP_ERROR_CHECK_INFO_TYPE app_error_check_info;
  58. }Process_Info_t;
  59. typedef enum{
  60. EXCEPT_LED_ON, //异常灯 - 开
  61. EXCEPT_LED_OFF, //异常灯 - 关
  62. } EXCEPT_LED_SWITCH_e;
  63. typedef enum{
  64. EXCEPT_UNKOWN_RESET_TRIGGER_WDT = 0, //异常——未知重启触发原因——看门狗
  65. EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT, //异常——未知重启触发原因——跑飞
  66. EXCEPT_UNKOWN_RESET_TRIGGER_APP_ERROR_CHECK, //异常——APP_ERROR_CHECK
  67. EXCEPT_UNKOWN_RESET_TRIGGER_NUMS, //异常——未知重启触发原因——数量
  68. } EXCEPT_UNKOWN_RESET_TRIGGER_e;
  69. typedef struct _except_unkown_reset_info
  70. {
  71. Process_Info_t process_info; //线程信息(堆栈信息和看门狗信息)
  72. uint32_t trigger; //导致未知重启触发的类型
  73. uint32_t cur_process_id; //当前正在处理的进程号
  74. uint32_t end_process_id; //处理完的进程号
  75. uint8_t is_upload; //是否正在上传
  76. } Except_Unkown_Reset_Info_t;
  77. typedef struct no_init
  78. {
  79. Except_Unkown_Reset_Info_t unkown_reset_info;
  80. uint32_t struct_change_flag; //被更改标志位
  81. } No_Init_t;
  82. typedef struct exception{
  83. /*private member*/
  84. EXCEPT_LED_SWITCH_e led_switch; //异常灯开关
  85. uint16_t led_display_time; //异常灯显示时长
  86. uint16_t led_toggle_time; //异常灯翻转时长
  87. uint8_t except_type[EXCEPT_NUM]; //异常类型
  88. uint16_t except_number_of_exist; //已存在的异常数量
  89. } Exception_t;
  90. /*Local Variable ----------------------------------------------*/
  91. static Exception_t ob_exception;
  92. static volatile __NO_INIT__ No_Init_t no_init_data;
  93. battercb_t battery_record={0};
  94. /*Local Functions ----------------------------------------------*/
  95. //没有操作系统时的异常处理
  96. static void Except_NotOSHardFault_Handler(uint32_t msp_addr)
  97. {
  98. STACK_DATA_TYPE *p; //堆栈中存储的数据
  99. msp_addr -= 4; //堆栈指针减去4,因为默认堆栈指针指向的是下一个空的地方-所以必须减去4
  100. DEBUG_LOG("\r\n-----------------ERROR -----------------\r\nHardFault_Handler\r\n");
  101. if((msp_addr >> 20) != 0x200) //判断地址范围,必须是0x200xxxxx 范围
  102. {
  103. DEBUG_LOG("Warning: stack pointer is damaged, unable to record the scene!\r\n");
  104. return;
  105. }
  106. msp_addr += 8; //进入中断后,堆栈又进入了2个u32数据,因此需要往后推
  107. no_init_data.unkown_reset_info.is_upload = 1;
  108. no_init_data.unkown_reset_info.trigger |= (1<<EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT);
  109. memcpy((void *)&no_init_data.unkown_reset_info.process_info.stack, (STACK_DATA_TYPE *)msp_addr, sizeof(STACK_DATA_TYPE));
  110. p = (STACK_DATA_TYPE *)msp_addr;
  111. p->PC -= 3; //PC指针要减去3
  112. }
  113. ////有操作系统时的异常处理
  114. //static void Except_OSHardFault_Handler(uint32_t psp_addr)
  115. //{
  116. // STACK_DATA_TYPE *p; //堆栈中存储的数据
  117. //
  118. // psp_addr -= 4; //堆栈指针减去4,因为默认堆栈指针指向的是下一个空的地方-所以必须减去4
  119. // DEBUG_LOG("\r\n-----------------ERROR -----------------\r\nHardFault_Handler\r\n");
  120. //
  121. //
  122. // if((psp_addr >> 20) != 0x200) //判断地址范围,必须是0x200xxxxx 范围
  123. // {
  124. // DEBUG_LOG("Warning: stack pointer is damaged, unable to record the scene!\r\n");
  125. // return;
  126. // }
  127. //
  128. // no_init_data.unkown_reset_info[EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT].is_upload = true;
  129. //
  130. // no_init_data.unkown_reset_info[EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT].trigger = EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT;
  131. //
  132. // memcpy(&no_init_data.unkown_reset_info[EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT].stack, (STACK_DATA_TYPE *)psp_addr, sizeof(STACK_DATA_TYPE));
  133. //
  134. // p = (STACK_DATA_TYPE *)psp_addr;
  135. // p->PC -= 3; //PC指针要减去3
  136. //
  137. //// DEBUG_LOG("R0:0x%08X\r\n", p->R0);
  138. //// DEBUG_LOG("R1:0x%08X\r\n", p->R1);
  139. //// DEBUG_LOG("R2:0x%08X\r\n", p->R2);
  140. //// DEBUG_LOG("R3:0x%08X\r\n", p->R3);
  141. //// DEBUG_LOG("R12:0x%08X\r\n", p->R12);
  142. //// DEBUG_LOG("LR:0x%08X\r\n", p->LR);
  143. //// DEBUG_LOG("PC:0x%08X\r\n", p->PC);
  144. //// DEBUG_LOG("xPSR:0x%08X\r\n", p->xPSR);
  145. //// DEBUG_LOG("system reset...\r\n");
  146. //}
  147. static void Exception_Led_Process(void);
  148. static void Except_Led_Close(void)
  149. {
  150. //全功率关闭
  151. Process_SetHoldOn(Exception_Led_Process,0);
  152. ob_exception.led_switch = EXCEPT_LED_OFF;
  153. ob_exception.led_display_time = EXCEPT_LED_DISPLAY_TIME/LED_PROCESS_CYCLE;
  154. ob_exception.led_toggle_time = EXCEPT_LED_TOGGLE_TIME/LED_PROCESS_CYCLE;
  155. LED_Stop(LED_EXCEPT);
  156. }
  157. static void Except_Led_OpenOnce(void)
  158. {
  159. //异常灯显示/关闭
  160. if(ob_exception.led_display_time != 0)
  161. {
  162. //全功率开启
  163. Process_SetHoldOn(Exception_Led_Process,1);
  164. if(ob_exception.led_toggle_time == 0)
  165. {
  166. if(ob_exception.led_switch == EXCEPT_LED_ON)ob_exception.led_switch = EXCEPT_LED_OFF;
  167. else ob_exception.led_switch = EXCEPT_LED_ON;
  168. ob_exception.led_toggle_time = EXCEPT_LED_TOGGLE_TIME/LED_PROCESS_CYCLE;
  169. }
  170. else
  171. {
  172. if(ob_exception.led_switch == EXCEPT_LED_ON)LED_Start(LED_EXCEPT,COLOR_ORANGE);
  173. if(ob_exception.led_switch == EXCEPT_LED_OFF)LED_Start(LED_EXCEPT,COLOR_BLACK);
  174. ob_exception.led_toggle_time--;
  175. }
  176. ob_exception.led_display_time--;
  177. }
  178. }
  179. static void Exception_Led_Process(void)
  180. {
  181. int16_t f_acc[3];
  182. bll_imu_data_t data;
  183. //读取ACC值
  184. if(bll_imu_get_data_num(BLL_IMU_DIR_FRONT) >= 1){
  185. bll_imu_get_data(BLL_IMU_DIR_FRONT, 0, &data);
  186. f_acc[0] = data.acc[0];f_acc[1] = data.acc[1];f_acc[2] = data.acc[2];
  187. }
  188. else return;
  189. //把鞋子倒转平放,且存在异常
  190. if(f_acc[2] >= EXCEPT_LED_ON_ACC_Z && ob_exception.except_number_of_exist > 0)
  191. {
  192. Except_Led_OpenOnce();
  193. }//把鞋子正放
  194. else if(f_acc[2] <= EXCEPT_LED_OFF_ACC_Z)
  195. {
  196. Except_Led_Close();
  197. }
  198. }
  199. static void Exception_UnkownReset_Info_Send_Process(void)
  200. {
  201. uint32_t tim;
  202. char buf[250]={0};
  203. memset(buf,0,sizeof(buf));
  204. if(no_init_data.unkown_reset_info.is_upload == 1)
  205. {
  206. if((no_init_data.unkown_reset_info.trigger & (1<<EXCEPT_UNKOWN_RESET_TRIGGER_WDT)) != 0)
  207. {
  208. tim = no_init_data.unkown_reset_info.process_info.wdt_info.thread_end_tim;
  209. if(tim < no_init_data.unkown_reset_info.process_info.wdt_info.thread_start_tim)tim += 16777216;
  210. sprintf(buf,"id:0x%x,0x%x,%d,%f\r\n",no_init_data.unkown_reset_info.cur_process_id,no_init_data.unkown_reset_info.end_process_id, \
  211. no_init_data.unkown_reset_info.process_info.wdt_info.wdt_remain_tim, \
  212. (tim-no_init_data.unkown_reset_info.process_info.wdt_info.thread_start_tim)/32.768);
  213. if(Except_TxError(EXCEPT_UNKOWN_RESET,buf) == 0)
  214. {
  215. no_init_data.unkown_reset_info.trigger &= ~(1<<EXCEPT_UNKOWN_RESET_TRIGGER_WDT);
  216. if(no_init_data.unkown_reset_info.trigger == 0)no_init_data.unkown_reset_info.is_upload = 0;
  217. }
  218. }
  219. else if((no_init_data.unkown_reset_info.trigger & (1<<EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT)) != 0)
  220. {
  221. sprintf(buf,"id:0x%x,0x%x,R:0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,H:0x%x,S:0x%x\r\n", no_init_data.unkown_reset_info.cur_process_id,no_init_data.unkown_reset_info.end_process_id, \
  222. no_init_data.unkown_reset_info.process_info.stack.R0, \
  223. no_init_data.unkown_reset_info.process_info.stack.R1, \
  224. no_init_data.unkown_reset_info.process_info.stack.R2, \
  225. no_init_data.unkown_reset_info.process_info.stack.R3, \
  226. no_init_data.unkown_reset_info.process_info.stack.R12, \
  227. no_init_data.unkown_reset_info.process_info.stack.LR, \
  228. no_init_data.unkown_reset_info.process_info.stack.PC - 3, \
  229. no_init_data.unkown_reset_info.process_info.stack.xPSR,
  230. HARDWARE_VERSION,SOFTWARE_VERSION);
  231. if(Except_TxError(EXCEPT_UNKOWN_RESET,buf) == 0)
  232. {
  233. no_init_data.unkown_reset_info.trigger &= ~(1<<EXCEPT_UNKOWN_RESET_TRIGGER_RUN_OUT);
  234. if(no_init_data.unkown_reset_info.trigger == 0)no_init_data.unkown_reset_info.is_upload = 0;
  235. }
  236. }
  237. else if((no_init_data.unkown_reset_info.trigger & (1<<EXCEPT_UNKOWN_RESET_TRIGGER_APP_ERROR_CHECK)) != 0)
  238. {
  239. sprintf(buf,"id:0x%x,0x%x,%s",no_init_data.unkown_reset_info.cur_process_id,no_init_data.unkown_reset_info.end_process_id,no_init_data.unkown_reset_info.process_info.app_error_check_info.buff);
  240. if(Except_TxError(EXCEPT_UNKOWN_RESET,buf) == 0)
  241. {
  242. no_init_data.unkown_reset_info.trigger &= ~(1<<EXCEPT_UNKOWN_RESET_TRIGGER_APP_ERROR_CHECK);
  243. if(no_init_data.unkown_reset_info.trigger == 0)no_init_data.unkown_reset_info.is_upload = 0;
  244. }
  245. }
  246. else
  247. {
  248. //跑飞数据被篡改了
  249. memset((void*)&no_init_data, 0 , sizeof(No_Init_t));
  250. no_init_data.struct_change_flag = EXCEPT_NO_INIT_DATA_CHANGE_FLAG;
  251. no_init_data.unkown_reset_info.is_upload = 0;
  252. }
  253. }
  254. }
  255. /*API ----------------------------------------------*/
  256. /**
  257. @brief 注册接收右鞋错误信息的回调
  258. @param Handle
  259. @return 无
  260. */
  261. void cb_BLE_Host_R_ERR(void* handle)
  262. {
  263. BLE_Host_Rx_t* target = handle;
  264. BLE_Client_Tx_Send(0,BLE_ERR,target->pDat,target->datLen);
  265. }
  266. void Exception_Init(void)
  267. {
  268. //若结构体被改动,则重置。
  269. if(no_init_data.struct_change_flag != EXCEPT_NO_INIT_DATA_CHANGE_FLAG)
  270. {
  271. memset((void*)&no_init_data, 0 , sizeof(No_Init_t));
  272. no_init_data.struct_change_flag = EXCEPT_NO_INIT_DATA_CHANGE_FLAG;
  273. no_init_data.unkown_reset_info.is_upload = 0;
  274. }
  275. memset(&ob_exception, 0 , sizeof(ob_exception));
  276. ob_exception.led_switch = EXCEPT_LED_OFF;
  277. ob_exception.led_display_time = EXCEPT_LED_DISPLAY_TIME/LED_PROCESS_CYCLE;
  278. ob_exception.led_toggle_time = EXCEPT_LED_TOGGLE_TIME/LED_PROCESS_CYCLE;
  279. Process_Start(LED_PROCESS_CYCLE,"Exception_Led",Exception_Led_Process);
  280. Process_Start(UNKOWN_RESET_INFO_SEND_CYCLE,"Exception_UnkownReset",Exception_UnkownReset_Info_Send_Process);
  281. BLE_Host_Rx_Regist(BLE_ERR,cb_BLE_Host_R_ERR);
  282. memcpy(&battery_record,&mFlash.mbattercb_t,sizeof(battercb_t));
  283. }
  284. /**
  285. @brief 系统错误回调
  286. @param id:
  287. @return 无
  288. */
  289. void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
  290. {
  291. char err_info[200];
  292. Flash_SaveLog(id,pc,info);
  293. DEBUG_LOG("app_error_fault_handler,System reset\n");
  294. no_init_data.unkown_reset_info.is_upload = 1;
  295. no_init_data.unkown_reset_info.trigger |= (1<<EXCEPT_UNKOWN_RESET_TRIGGER_APP_ERROR_CHECK);
  296. memset((void *)&no_init_data.unkown_reset_info.process_info.app_error_check_info, 0, sizeof(APP_ERROR_CHECK_INFO_TYPE));
  297. switch (id)
  298. {
  299. #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
  300. case NRF_FAULT_ID_SD_ASSERT:
  301. memcpy((void *)&no_init_data.unkown_reset_info.process_info.app_error_check_info,"SD: ASSERTION FAILED\r\n",sizeof(APP_ERROR_CHECK_INFO_TYPE));
  302. break;
  303. case NRF_FAULT_ID_APP_MEMACC:
  304. memcpy((void *)&no_init_data.unkown_reset_info.process_info.app_error_check_info,"SD: INVALID MEMORY ACCESS\r\n",sizeof(APP_ERROR_CHECK_INFO_TYPE));
  305. break;
  306. #endif
  307. case NRF_FAULT_ID_SDK_ASSERT:
  308. {
  309. assert_info_t * p_info = (assert_info_t *)info;
  310. sprintf((char *)err_info,"f:%s,l:%u\r\n",
  311. p_info->p_file_name+13,
  312. p_info->line_num);
  313. memcpy((void *)&no_init_data.unkown_reset_info.process_info.app_error_check_info,err_info,sizeof(APP_ERROR_CHECK_INFO_TYPE));
  314. break;
  315. }
  316. case NRF_FAULT_ID_SDK_ERROR:
  317. {
  318. error_info_t * p_info = (error_info_t *)info;
  319. sprintf((char *)err_info,"e:%u,f:%s,l:%u\r\n",
  320. p_info->err_code,
  321. p_info->p_file_name+13,
  322. p_info->line_num);
  323. memcpy((void *)&no_init_data.unkown_reset_info.process_info.app_error_check_info,err_info,sizeof(APP_ERROR_CHECK_INFO_TYPE));
  324. break;
  325. }
  326. default:
  327. sprintf((char *)err_info,"UNKNOWN FAULT 0x%08X\n", pc);
  328. memcpy((void *)&no_init_data.unkown_reset_info.process_info.app_error_check_info,err_info,sizeof(APP_ERROR_CHECK_INFO_TYPE));
  329. break;
  330. }
  331. NVIC_SystemReset(); //复位重启
  332. }
  333. int Except_TxError(ExcepType_t excep_type,const char *errstr){
  334. uint8_t buf[250];
  335. uint8_t L=0;
  336. uint16_t err_strlen =0;
  337. err_strlen = strlen(errstr);
  338. if(err_strlen > (sizeof(buf)-2))return -1;
  339. if(app_Get_isHost())buf[L++] =0;//0左鞋1右鞋
  340. else buf[L++] =1;
  341. buf[L++] = excep_type; //错误编号
  342. memcpy(&buf[L],errstr,err_strlen);
  343. L +=err_strlen;
  344. return BLE_Client_Send(BLE_ERR,buf,L);
  345. }
  346. void Except_SetExceptype(ExcepType_t excep_type)
  347. {
  348. if(ob_exception.except_type[excep_type] != 1)
  349. {
  350. ob_exception.except_type[excep_type] = 1;
  351. ob_exception.except_number_of_exist++;
  352. }
  353. }
  354. void Except_ClearExceptype(ExcepType_t excep_type)
  355. {
  356. if(ob_exception.except_type[excep_type] == 1)
  357. {
  358. ob_exception.except_type[excep_type] = 0;
  359. if(ob_exception.except_number_of_exist != 0)ob_exception.except_number_of_exist--;
  360. }
  361. }
  362. bool Except_IsError(ExcepType_t excep_type)
  363. {
  364. if(ob_exception.except_type[excep_type] == 1)
  365. {
  366. return true;
  367. }
  368. return false;
  369. }
  370. //硬件中断
  371. void HardFault_Handler (void)
  372. {
  373. uint32_t msp_addr = __get_MSP(); //获取线程模式下堆栈指针位置
  374. uint32_t psp_addr = __get_PSP(); //获取中断下的堆栈指针位置-用于OS启动后
  375. #if(UCOS_II_EN) //使能了操作系统的一个宏定义,自己去定义
  376. if(SYS_GetOsStartup()) //操作系统运行了-自己定义一个状态,可以获取操作系统是否启动
  377. {
  378. Except_OSHardFault_Handler(psp_addr);
  379. }
  380. else
  381. {
  382. Except_NotOSHardFault_Handler(msp_addr);
  383. }
  384. #else //没有使能操作系统
  385. Except_NotOSHardFault_Handler(msp_addr);
  386. #endif //UCOS_II_EN
  387. nrf_delay_ms(10); //延时一下,防止重启速度太快
  388. NVIC_SystemReset(); //复位重启
  389. }
  390. void Except_Get_Cur_Porcess_ID(uint32_t cur_process_id)
  391. {
  392. uint32_t cur_tim,feed_watchdogtim;
  393. if(no_init_data.unkown_reset_info.is_upload == 0)
  394. {
  395. no_init_data.unkown_reset_info.cur_process_id = cur_process_id;
  396. cur_tim = NRF_RTC0->COUNTER;
  397. feed_watchdogtim = Get_FeedWatchDogTime();
  398. if(cur_tim<feed_watchdogtim) cur_tim += 16777216;
  399. no_init_data.unkown_reset_info.process_info.wdt_info.wdt_remain_tim = WDT_RELOAD_VALUE - ((cur_tim-feed_watchdogtim)/32.768);
  400. no_init_data.unkown_reset_info.process_info.wdt_info.thread_start_tim = cur_tim;
  401. }
  402. }
  403. void Except_Get_End_Porcess_ID(uint32_t end_process_id)
  404. {
  405. if(no_init_data.unkown_reset_info.is_upload == 0)
  406. {
  407. no_init_data.unkown_reset_info.end_process_id = end_process_id;
  408. }
  409. }
  410. void Except_Unkown_Reset_WDT_Set(void)
  411. {
  412. no_init_data.unkown_reset_info.is_upload = 1;
  413. no_init_data.unkown_reset_info.trigger |= (1<<EXCEPT_UNKOWN_RESET_TRIGGER_WDT);
  414. no_init_data.unkown_reset_info.process_info.wdt_info.thread_end_tim = NRF_RTC0->COUNTER;
  415. }
  416. /**
  417. @brief 获取电量记录缓存区地址
  418. @return 电量记录缓存区地址
  419. */
  420. battercb_t* Except_Get_Battery_Record_Buff(void)
  421. {
  422. return &battery_record;
  423. }