mc_error.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _MC_ERROR_H__
  2. #define _MC_ERROR_H__
  3. #include "os/os_types.h"
  4. typedef struct {
  5. s16 err_value;
  6. u32 err_time;
  7. }err_record_t;
  8. #pragma pack (push,1)
  9. typedef struct {
  10. u8 idx;
  11. u8 err_code;
  12. s16 value1;
  13. s16 value2;
  14. }err_node_t;
  15. typedef struct {
  16. u8 idx;
  17. s16 vbus_x10;
  18. s16 ibus_x10;
  19. s16 vacc_x10;
  20. s16 id_x10;
  21. s16 iq_x10;
  22. s16 vd_x10;
  23. s16 vq_x10;
  24. s16 id_ref_x10;
  25. s16 iq_ref_x10;
  26. s16 torque_ref_x10;
  27. u8 run_mode;
  28. s16 rpm;
  29. u8 b_sensorless;
  30. u8 b_sensorless_stable;
  31. s16 sensorless_rpm;
  32. s16 mos_temp;
  33. s16 mot_temp;
  34. u8 enc_error;
  35. }runtime_node_t;
  36. #pragma pack(pop)
  37. typedef struct{
  38. u8 tail;
  39. u8 count;
  40. u16 crc;
  41. err_node_t node[0];
  42. }err_nv_t;
  43. typedef struct{
  44. u8 tail;
  45. u8 count;
  46. u16 crc;
  47. runtime_node_t node[0];
  48. }runtime_nv_t;
  49. void mc_crit_err_block_init(void);
  50. void mc_crit_err_add(u8 code, s16 value1, s16 value2);
  51. void mc_crit_err_add_s16(u8 code, s16 value);
  52. void mc_crit_err_save(void);
  53. int mc_crit_err_get(s16 offset, u8 *buff, int len);
  54. void mc_runtime_add(runtime_node_t *rt);
  55. int mc_runtime_get(s16 offset, u8 *buff, int len);
  56. #endif /*_MC_ERROR_H__ */