nv_storage.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _NV_Storage_H__
  2. #define _NV_Storage_H__
  3. #include "os/os_types.h"
  4. #pragma pack (push,1)
  5. typedef struct {
  6. float s_PhaseCurrLim;
  7. float s_maxIdq;
  8. float s_minIdq;
  9. float s_maxiDC;
  10. float s_maxvDC;
  11. float s_maxRPM;
  12. float s_maxEpmRPM;
  13. float s_maxTorque;
  14. float s_maxBrkCurrent;
  15. float s_LimitiDC;
  16. float n_modulation;
  17. float n_PhaseFilterCeof;
  18. float n_currentBand; //电流环带宽
  19. float n_TrqVelLimGain;
  20. float spd_kp;
  21. float spd_ki;
  22. float trq_kp;
  23. float trq_ki;
  24. float fw_baseSpd; //弱磁基速
  25. float fw_kp;
  26. float fw_ki;
  27. u16 crc16;
  28. }foc_params_t;
  29. typedef struct {
  30. u8 poles;
  31. float r;
  32. float ld;
  33. float lq;
  34. float flux_linkage;
  35. float back_emf;
  36. s32 hall_table[8];
  37. float offset;
  38. float est_pll_band; //normal工作模式下的pll带宽
  39. float pos_lock_pll_band; //电机锁定模式下的pll带宽
  40. u16 crc16;
  41. }motor_params_t;
  42. #define MAX_TRQ_POINTS 60
  43. #define MAX_SPD_POINTS 100
  44. typedef struct {
  45. s16 d[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  46. s16 q[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  47. u16 crc16;
  48. }torque_lut_t;
  49. #pragma pack(pop)
  50. #define motorParam_idx_0 3
  51. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  52. #define focParam_idx_0 (motorParam_idx_0 + 2)
  53. #define focParam_idx_1 (motorParam_idx_0 + 3)
  54. void nv_storage_init(void);
  55. motor_params_t *nv_get_motor_params(void);
  56. foc_params_t *nv_get_foc_params(void);
  57. void nv_save_angle_offset(float offset);
  58. void nv_save_motor_params(void);
  59. void nv_read_motor_params(void);
  60. void nv_save_foc_params(void);
  61. void nv_read_foc_params(void);
  62. void nv_save_hall_table(s32 *hall_table);
  63. #endif /* _NV_Storage_H__ */