| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #ifndef _NV_Storage_H__
- #define _NV_Storage_H__
- #include "os/os_types.h"
- #include "foc/core/PMSM_FOC_Core.h"
- #include "foc/commands.h"
- #pragma pack (push,1)
- typedef struct {
- float s_PhaseCurrLim;
- float s_maxDCVol;
- float s_minDCVol;
- float s_maxRPM;
- float s_maxEpmRPM;
- float s_maxEpmTorqueLim;
- float s_maxTorque;
- float s_TorqueBrkLim;
- float s_iDCeBrkLim;
- float s_LimitiDC;
- float n_currentBand; //电流环带宽
- float n_startThroVol;
- float n_endThroVol;
- u8 n_brkShutPower;
- u8 n_autoHold;
- u32 n_acc_time;
- u32 n_dec_time;
- u32 n_ebrk_time;
- u8 n_FwEnable;
- pid_conf_t pid_conf[PID_Max_id];
- float f_minThroVol;
- float f_maxThroVol;
- u8 res[2048 - 161];
- u16 crc16;
- }foc_params_t;
- typedef struct {
- u8 mot_nr;
- u8 poles;
- float r;
- float ld;
- float lq;
- float flux_linkage;
- float back_emf;
- s32 hall_table[8];
- float offset;
- float est_pll_band; //normal工作模式下的pll带宽
- float pos_lock_pll_band; //电机锁定模式下的pll带宽
- u16 crc16;
- }motor_params_t;
- typedef struct {
- u16 u_maxRPM;
- u16 u_maxTorque;
- u16 u_maxIdc;
- u16 u_accTime;//加速曲线
- }mc_gear_t;
- #define CONFIG_MAX_GEAR_NUM 5
- typedef struct {
- mc_gear_t gears_48[CONFIG_MAX_GEAR_NUM];
- mc_gear_t gears_96[CONFIG_MAX_GEAR_NUM];
- u16 crc16;
- }mc_gear_config_t;
- #define MAX_TRQ_POINTS 20
- #define MAX_SPD_POINTS 40
- #define TBL_SPD_INTVAL 250
- typedef struct trq2dq {
- s16 torque;
- s16 d;
- s16 q;
- }trq2dq_t;
- typedef struct {
- struct trq2dq tdq[MAX_SPD_POINTS][MAX_TRQ_POINTS];
- u16 magic;
- u16 crc16;
- }trq2dq_table_t;
- #pragma pack(pop)
- typedef struct {
- u8 sn[32];
- u16 len;
- u16 crc;
- }mc_sn_t;
- #define motorParam_idx_0 3
- #define motorParam_idx_1 (motorParam_idx_0 + 1)
- #define focParam_idx_0 (motorParam_idx_1 + 1)
- #define focParam_idx_1 (focParam_idx_0 + 1)
- #define trq_Tbl_size (4)
- #define trq_Tbl_idx0 (focParam_idx_1 + 1)
- #define trq_Tbl_idx1 (trq_Tbl_idx0 + trq_Tbl_size)
- #define gear_config_idx_0 (trq_Tbl_idx1 + trq_Tbl_size)
- #define gear_config_idx_1 (gear_config_idx_0 + 1)
- #define sn_idx_back (gear_config_idx_1 + 1)
- void nv_storage_init(void);
- motor_params_t *nv_get_motor_params(void);
- foc_params_t *nv_get_foc_params(void);
- mc_gear_config_t *nv_get_gear_configs(void);
- void nv_save_angle_offset(float offset);
- void nv_save_motor_params(void);
- void nv_read_motor_params(void);
- void nv_save_foc_params(void);
- void nv_read_foc_params(void);
- void nv_save_hall_table(s32 *hall_table);
- void nv_set_pid(u8 id, pid_conf_t *pid);
- void nv_get_pid(u8 id, pid_conf_t *pid);
- void nv_set_hwbrake_mode(u8 mode);
- void nv_set_throttle_vol(float min, float max);
- bool nv_set_gear_config(u8 mode4896, u8 gear, u16 rpm, u16 torque, u16 idc, u16 acc);
- bool nv_get_gear_config(u8 mode4896, u8 gear, u16 *rpm, u16 *torque, u16 *idc, u16 *acc);
- trq2dq_table_t *nv_get_trq2dq_table(void);
- void nv_write_trq_table_begin(int index);
- int nv_write_trq_table_continue(uint8_t *data, int len);
- int nv_write_trq_table_check(u8 *data, int len, int index);
- int nv_write_sn(u8 *data, int len);
- int nv_read_sn(u8 *data, int len);
- #endif /* _NV_Storage_H__ */
|