#ifndef __MYPROJECT_H_
#define __MYPROJECT_H_

#include <FU6522_72.h>
#include <FU6522_72_MDU.h>

#include <customer.h>
#include <protect.h>


#include <Definition.h>
#include <Parameter.h>


#include <peripheral.h>

#include <control.h>
#include <protect_def.h>

#include <led.h>
#include <pwm.h>
#include <protocol.h>


typedef struct
{
    int16   IuOffset;       //Iu的偏置电压
    int32   IuOffsetSum;    //Iu的偏置电压总和
    int16   IvOffset;       //Iv的偏置电压
    int32   IvOffsetSum;    //Iv的偏置电压总和
    int16   Iw_busOffset;   //Iw或Ibus的偏置电压
    int32   Iw_busOffsetSum;//Iw或Ibus的偏置电压总和
    
    int16   IbusOffset;   //Ibus的偏置电压
    int32   IbusOffsetSum;//IIbus的偏置电压总和
    int16   OffsetCount;    //偏置电压采集计数
    int8    OffsetFlag;     //偏置电压结束标志位
    
} CurrentOffset;

extern CurrentOffset xdata mcCurOffset;
extern int16 idata Power_Currt;

void GetCurrentOffset(void);

void FOC_Init(void);
void Motor_Charge(void);
void Motor_Static_Open(void);


void Motor_Align(void);


typedef union
{
    uint8 SetMode;
    struct
    {
        uint8 CalibFlag        : 1;
        uint8 ChargeSetFlag    : 1;
        uint8 AlignSetFlag     : 1;
		uint8 StartSetFlag     : 1;
	} SetFlag;
} MotStaM;


extern MotStaM    McStaSet;


typedef struct
{
    uint8  ChargeStep;
	uint8  Flg_ATORampEnd;

    uint16 State_Count;
    int16  mcPosCheckAngle; 
    uint8  CurrentAlignStatus;
    float AngleProcess;
    int16 AngleStart;
} FOCCTRL;


extern FOCCTRL xdata mcFocCtrl;

void ATORamp(void);

extern uint16 Abs_F16(int16 value);

void Config_Init(void);

	
#endif