// USER CODE BEGIN (MAIN_General,1)

// USER CODE END


// USER CODE BEGIN (MAIN_General,2)

// USER CODE END


// USER CODE BEGIN (MAIN_General,3)

// USER CODE END


// USER CODE BEGIN (MAIN_General,4)

// USER CODE END


// USER CODE BEGIN (MAIN_General,5)

// USER CODE END


// USER CODE BEGIN (MAIN_General,6)

// MAIN_General_6_IAF_CODE_BEGIN

// MAIN_General_6_IAF_CODE_END
// USER CODE END


// USER CODE BEGIN (MAIN_General,7)
// MAIN_General_7_IAF_CODE_BEGIN

#if DAVECG_ControlAlgoKBS.SDCC
		bit  			gb_Off;
		bit 			gb_On;
		bit 			gb_time_out;
		bit  			gb_ctrap;
		bit 			gb_hs_error;
		bit				gb_overcurrent;
	 	bit 			bitNewCMD0;
	 	bit 			bitNewCMD1;

data	at 0x0020	unsigned char	Status_word;
idata	at 0x008E	int   		    Rampup_Counter;
data	at 0x002E	unsigned int	g_direction;	

#if DAVECG_ControlAlgoKBS.VOLTAGE_CTRL
data	at  0x0028	unsigned int 	g_nv_start_ref;	
idata	at 0x008C	unsigned int  	g_nv_end_ref;
idata	at 0x0090	int 			g_speed_CC60 ;
#endif

#if DAVECG_ControlAlgoKBS.SPEED_CTRL
data	at 0x0028	unsigned int 	g_speed_start_ref ;	
idata	at 0x008C	unsigned int  	g_speed_end_ref; 	 		
idata	at 0x0092	unsigned int  	speed_kp;
idata	at 0x0094	unsigned int  	speed_ki;
idata	at 0x0090	int 			g_speed_CC60 ;
#endif

#if DAVECG_ControlAlgoKBS.BEMF
 idata 	at 0x0080	unsigned int 	g_start_freq;
 idata  at 0x0082	int 			g_freq_increment;	
 idata  at 0x0084	int 			g_volt_increment;
 idata	at 0x0086	unsigned int 	g_start_duty_c;

 idata 	at 0x0088	unsigned int 	g_bemf_check_freq ;					   
 idata 	at 0x008A	unsigned int  	g_bemf_end_freq;
 
#endif

#endif
#if DAVECG_ControlAlgoKBS.KEIL
 bdata 	unsigned char 	Status_word;
		sbit			gb_overcurrent = Status_word^5;
		sbit 			gb_hs_error      = Status_word^4;
		sbit 			gb_ctrap      = Status_word^3;
		sbit 			gb_time_out = Status_word^2;
		sbit 			gb_On        = Status_word^1;
		sbit 			gb_Off       = Status_word^0;

idata	int   		    Rampup_Counter 		_at_(0x008E);
data	unsigned int	g_direction 		_at_(0x2E);	

#if DAVECG_ControlAlgoKBS.VOLTAGE_CTRL
data	unsigned int 	g_nv_start_ref 		_at_(0x0028);	
idata	unsigned int  	g_nv_end_ref  		_at_(0x008C); 
idata	int 			g_speed_CC60 		_at_(0x90);
#endif

#if DAVECG_ControlAlgoKBS.SPEED_CTRL
data	unsigned int 	g_speed_start_ref 	_at_(0x0028);	
idata	unsigned int  	g_speed_end_ref  	_at_(0x008C); 	 		
idata 	unsigned int   	speed_kp  			_at_(0x0092);
idata	unsigned int   	speed_ki  			_at_(0x0094);
idata	int 			g_speed_CC60 		_at_(0x90);
#endif

#if DAVECG_ControlAlgoKBS.BEMF
 idata 	unsigned int 	g_start_freq 		_at_(0x0080);
 idata  int 			g_freq_increment 	_at_(0x0082);	
 idata  int 			g_volt_increment 	_at_(0x0084);
 idata	unsigned int 	g_start_duty_c 		_at_(0x0086);

 idata 	unsigned int 	g_bemf_check_freq 	_at_(0x0088);					   
 idata 	unsigned int  	g_bemf_end_freq 	_at_(0x008A);

#endif
#endif
int API_Ref=0;
 
// MAIN_General_7_IAF_CODE_END
 // USER CODE END

 // USER CODE BEGIN (MAIN_General,8)
  
// MAIN_General_8_IAF_CODE_BEGIN
 extern void MotorControl_vInit( void );
// MAIN_General_8_IAF_CODE_END
// USER CODE END


// USER CODE BEGIN (MAIN_General,9)

// USER CODE END


// USER CODE BEGIN (MAIN_Init,1)

// USER CODE END

  // USER CODE BEGIN (MAIN_Init,2)

  // USER CODE END


// USER CODE BEGIN (MAIN_Main,1)

// USER CODE END


  // USER CODE BEGIN (MAIN_Main,2)
  
  // USER CODE END

  // USER CODE BEGIN (MAIN_Main,3)
	// Main_3_IAF_CODE_BEGIN
	MotorControl_vInit();

	API_Ref=0;
		// Main_3_IAF_CODE_END		
  // USER CODE END

  // USER CODE BEGIN (MAIN_Main,4)

  // USER CODE END

// USER CODE BEGIN (MAIN_General,10)

// USER CODE END

