log_save.h 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef __LOG_SAVE_H
  2. #define __LOG_SAVE_H
  3. #include "stm32f1xx_hal.h"
  4. #include "motor_control.h"
  5. #include "eeprom_flash.h"
  6. #define LOG_ADDRESS_BEGIN 0x0801F800
  7. #define LOG_ADDRESS_END 0x0801FBFF
  8. //故障日志记录信息 60 bytes,最后4 bytes 为预留, 1K空间可以保存最近16条故障记录
  9. typedef struct
  10. {
  11. uint16_t Error_Index; //故障列表索引 2 bytes, 地址偏移 0
  12. uint16_t NotesInfo1; //备注信息1,地址偏移 2
  13. uint16_t NotesInfo2; //备注信息2,地址偏移 4
  14. uint16_t NotesInfo3; //备注信息3,地址偏移 6
  15. uint32_t ErrorCode; //故障码 4 bytes, 地址偏移 8
  16. uint32_t RunTime; //运行时间 4bytes, 地址偏移 12
  17. MC_RunInfo_Struct_t RunInfo; //运行信息 32bytes, 地址偏移 16
  18. MC_AttitudeAngle_Struct_t AttitudeAngle; //车辆姿态角度 8bytes, 地址偏移 48
  19. MC_CalParam_Struct_t MC_CalParam; //马达控制参数 8bytes , 地址偏移 56
  20. }MC_ErrorLogSaveInfo_Struct_t;
  21. extern MC_ErrorLogSaveInfo_Struct_t MC_ErrorLogSaveInfo; //故障发生时刻日志信息
  22. extern TrueOrFalse_Flag_Struct_t IsErrorLogSaveInfoUpdateFlag; //故障日志更新标志
  23. extern void ErrorLogSave_Update(MC_ErrorLogSaveInfo_Struct_t* p_ErrorLogSaveInfo);
  24. extern void ErrorLogSave_Process(MC_ErrorLogSaveInfo_Struct_t* p_ErrorLogSaveInfo, TrueOrFalse_Flag_Struct_t* IsUpdate);
  25. #endif