exception.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef __EXCEPTION_H__
  2. #define __EXCEPTION_H__
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*Includes ------------------------------------------------------*/
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. /*STRUCTION -----------------------------------------------------*/
  10. typedef struct
  11. {
  12. float preBestResult_Voltage2power ;
  13. float preBestResult_chargeV2P_f ;
  14. float P_mAh ;
  15. float kg ;
  16. float P2 ;
  17. float P1 ;
  18. float Battery_capacity_mAh ;
  19. float adc_tp4056_power ;
  20. char init;
  21. char sta ;
  22. char chargeV2P_f_init;
  23. char Voltage2power_init;
  24. } battercb_t;
  25. //EXCEPT分级 : 0~100 正常通知;100~150 警告 150以上 错误{}错误会通过企业微信推送
  26. typedef enum {
  27. //数据异常
  28. EXCEPT_DATA_BACK_MAG =0, //异常 —— 后脚地磁数据
  29. EXCEPT_DATA_FRONT_ACC, //异常 —— 前脚加速度数据
  30. EXCEPT_DATA_FRONT_GRY, //异常 —— 前脚陀螺仪数据
  31. EXCEPT_DATA_FRONT_MAG, //异常 —— 前脚地磁数据
  32. EXCEPT_DATA_CHARGE, //异常 —— 充电数据
  33. EXCEPT_DATA_BATTERY, //异常 —— 电池数据
  34. EXCEPT_IMU_SUSPEND_OVERFLOW, //异常 —— 持续处于异常挂起模式
  35. EXCEPT_ANT_DAMAGE, //异常 —— 天线损坏
  36. EXCEPT_FLASH, //异常 —— FLASH错误
  37. EXCEPT_GAME, //异常 —— 游戏模式错误
  38. EXCEPT_RealStep, //异常 —— 实时脚步异常
  39. EXCEPT_DATEStep, //异常 —— 日常脚步异常
  40. EXCEPT_Pair, //异常 —— 配对异常
  41. EXCEPT_Power, //异常 —— 低功耗
  42. EXCEPT_DFU, //异常 —— 远程升级异常
  43. EXCEPT_CONNET, //异常 —— 连接右鞋错误
  44. EXCEPT_OVERTURAN, //异常 —— 翻转查看电量异常
  45. EXCEPT_UNKOWN_RESET, //异常 —— 未知重启
  46. EXCEPT_ADC_INIT, //异常 —— adc初始化失败
  47. EXCEPT_SPI_INIT, //异常 —— spi初始化失败
  48. EXCEPT_SPI_RW, //异常 —— spi读写失败
  49. EXCEPT_IIC_RW, //异常 —— IIC读写失败
  50. EXCEPT_FLASH_INIT, //异常 —— flash初始化失败
  51. EXCEPT_PWM_INIT, //异常 —— pwm初始化失败
  52. EXCEPT_WDT_INIT, //异常 —— wdt初始化失败
  53. EXCEPT_RTC_INIT, //异常 —— rtc初始化失败
  54. EXCEPT_RTC_CONFIG, //异常 —— rtc配置失败
  55. EXCEPT_EXCEPTION, //异常 —— 无异常
  56. EXCEPT_QMA7981, //异常 —— QMA7981
  57. EXCEPT_NUM, //异常 —— 异常类型数量
  58. }ExcepType_t;
  59. /*API -------------------------------------------------------*/
  60. void Exception_Init(void);
  61. void Except_SetExceptype(ExcepType_t excep_type);
  62. void Except_ClearExceptype(ExcepType_t excep_type);
  63. bool Except_IsError(ExcepType_t excep_type);
  64. int Except_TxError(ExcepType_t excep_type,const char *errstr);
  65. void Except_Get_Cur_Porcess_ID(uint32_t cur_process_id);
  66. void Except_Get_End_Porcess_ID(uint32_t end_process_id);
  67. void Except_Unkown_Reset_WDT_Set(void);
  68. int Except_Display(ExcepType_t excep_type,const char *errstr);
  69. /**
  70. @brief 获取电量记录缓存区地址
  71. @return 电量记录缓存区地址
  72. */
  73. battercb_t* Except_Get_Battery_Record_Buff(void);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif