nv_storage.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_maxIdq;
  7. float s_minIdq;
  8. float s_maxiDC;
  9. float s_maxvDC;
  10. float s_maxRPM;
  11. float s_maxTorque;
  12. float n_modulation;
  13. float n_PhaseFilterCeof;
  14. float n_currentBand; //电流环带宽
  15. float spd_kp;
  16. float spd_ki;
  17. float trq_kp;
  18. float trq_ki;
  19. float fw_baseSpd; //弱磁基速
  20. float fw_kp;
  21. float fw_ki;
  22. u16 crc16;
  23. }foc_params_t;
  24. typedef struct {
  25. u8 poles;
  26. float r;
  27. float ld;
  28. float lq;
  29. float flux_linkage;
  30. float back_emf;
  31. s16 hall_offset;
  32. s32 hall_table[8];
  33. u16 encoder_cpr;
  34. float est_pll_band;
  35. u16 crc16;
  36. }motor_params_t;
  37. #define MAX_TRQ_POINTS 60
  38. #define MAX_SPD_POINTS 100
  39. typedef struct {
  40. s16 d[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  41. s16 q[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  42. u16 crc16;
  43. }torque_lut_t;
  44. #pragma pack(pop)
  45. #define motorParam_idx_0 3
  46. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  47. #define focParam_idx_0 (motorParam_idx_0 + 2)
  48. #define focParam_idx_1 (motorParam_idx_0 + 3)
  49. void nv_storage_init(void);
  50. motor_params_t *nv_get_motor_params(void);
  51. foc_params_t *nv_get_foc_params(void);
  52. void nv_save_hall_offset(s16 offset);
  53. void nv_save_motor_params(void);
  54. void nv_read_motor_params(void);
  55. void nv_save_foc_params(void);
  56. void nv_read_foc_params(void);
  57. void nv_save_hall_table(s32 *hall_table);
  58. #endif /* _NV_Storage_H__ */