#ifndef __CUSTOMER_H_
#define __CUSTOMER_H_

#define PWM_FREQUENCY                       (16.0)
#define PWM_DEADTIME                        (1.0)
#define MIN_WIND_TIME                       (PWM_DEADTIME + 0.9)
#define DLL_TIME                            (PWM_DEADTIME + 0.3)

#define PWM_LEVEL_MODE                      (HIGH_LEVEL)

#define Pole_Pairs                          (4.0)
#define RS                                  (0.135)
#define LD                                  (0.00004)
#define LQ                                  (0.00008)
#define MOTOR_SPEED_BASE                    (9000.0)
#define Ke                                  (1.8)

#define IR_MODE                             (CW)

#define HW_AMP_MODE                         (AMP_PGA_DUAL)

#define HW_RSHUNT                           (0.01)
#define HW_AMPGAIN                          (AMP4x)
#define HW_ADC_VREF                         (VREF5_0)

#define Shunt_Resistor_Mode                 (Single_Resistor)

#define VHALF_EN                            (1)


#define RV1                                 (47.0)
#define RV2                                 (3.3)

#define CHARGE_EN                           (0)
#define CHARGE_DUTY                         (0.1)
#define CHARGE_TIME                         (30)


#define ALIGN_MOME                          (ALIGN_NOMAL)


#define AlignRamp_Time                      (800)
#define Align_Time1                         (200)
#define Align_Time2                         (1000)
#define Align_Time3                         (200)
#define AlignAll_Time                       (AlignRamp_Time+Align_Time1+Align_Time2+Align_Time3)
#define Align_Angle1                        _Q15(90.0/180.0)                       // 第一次预定位角度
#define Align_Angle2                        _Q15(90.0/180.0)                        // 第二次预定位角度
#define Angle_ADD                           (int32)6*_Q15((float)-180.0/180.0)       //旋转角度
#define Angle_AngleK                        (float)Angle_ADD/Align_Time2            //旋转系数

#define DQKP_Alignment                      _Q12(2.0)
#define DQKI_Alignment                      _Q15(0.01)
#define ID_Align_CURRENT                    I_Value(0.0)
#define IQ_Align_CURRENT                    I_Value(2.0)

#define Open_Start_Mode                     (Omega_Start)
#define ID_Start_CURRENT                    I_Value(0.0)
#define IQ_Start_CURRENT                    I_Value(5.0)


#define ATO_BW_START                        (0.0)
#define ATO_BW_RUN1                         (150.0)
#define ATO_BW_RUN2                         (150.0)
#define ATO_BW_RUN3                         (150.0)
#define ATO_BW_RUN4                         (150.0)

#define ATO_START_HOLDTIME                  (10)             ///< (ms)观测器带宽的滤波值,启动第一拍ATO持续时间
#define ATO_RAMP_PERIOD                     (20)             ///< (ms)观测器带宽的滤波值,ATO爬坡递增 间隔时间

#define MOTOR_OMEGA_RAMP_ACC                (50)               ///< omega启动的增量（每个载波递增值） 
#define MOTOR_OMEGA_RAMP_MIN                S_Value(200.0)     ///< (RPM) omega启动的最小切换转速
#define MOTOR_OMEGA_RAMP_END                S_Value(300.0)     ///< (RPM) omega启动的限制转速
#define MOTOR_SPEED_SMOMIN_RPM              (600.0)            ///< (RPM) SMO运行最小转速影响启动

#define SPD_BW                              (20.0)            ///< 速度带宽的滤波值，经典值为5.0-40.0
#define MOTOR_LOOP_RPM                      S_Value(400.0)    ///< (RPM) 启动后电流环切入外部环路转速阈值

#define MOTOR_SPEED_MIN_RPM                 S_Value(1800.0)
#define MOTOR_SPEED_MAX_RPM                 S_Value(3500.0)
#define MOTOR_SPEED_STOP_RPM                S_Value(200.0)


#define DKPStart                            _Q12(4.5)
#define DKIStart                            _Q15(0.03)
#define QKPStart                            DKPStart
#define QKIStart                            DKIStart

#define DKP                                 _Q12(3.5)
#define DKI                                 _Q15(0.005)
#define QKP                                 DKP
#define QKI                                 DKI

// DQ轴输出限幅
#define DOUTMAX                             _Q15(0.99)
#define DOUTMIN                             _Q15(-0.99)
#define QOUTMAX                             _Q15(0.99)
#define QOUTMIN                             _Q15(-0.99)


#define SPEED_LOOP_TIME                     (1)

#define SKP                                 _Q12(2.5)
#define SKI                                 _Q15(0.01)
#define SOUTMAX                             I_Value(20.0)
#define SOUTMIN                             I_Value(0.01)

#define MOTOR_SPEED_INC                     (1) // 约为274RPM每秒
#define MOTOR_SPEED_DEC                     (1)


#define SPEED_MODE                          (NONEMODE)

#define EstimateAlgorithm                   (AO)
#define OverModulation                      (0)

#endif
