mc_error.h 1.1 KB

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