#ifndef _BREAK_REGUL_H
#define _BREAK_REGUL_H

#ifdef __cplusplus
	extern "C" {  
#endif

typedef struct {
    unsigned int pwm_tics;
    unsigned int pwm_minimal_tics;
    unsigned int pwm_max_tics;
} BREAK_REGUL;

#define BREAK_REGUL_DEFAULTS {0,0,0}


#define BREAK_INSENSITIVE_LEVEL_MIN  279620	//50V
#define BREAK_INSENSITIVE_LEVEL_MAX  4194304//500V//5872025//700 V//2516582//300 V//4194304//500 V//2516582 // 838860 //100 V
#define PERCENT_BREAK_MAX 13421772//80 percent
#define PERCENT_BREAK_MIN 838860//5 percent
#define MAX_RECUP_LEVEL 5872025  //700 V
#define K_RECUP_LEVEL   56 //5.6 /// 838860 / 4697620  //700 V
#define MAX_BREAK_IMPULSE 9000

#define RECUP_PERCENT_MIN 10.0
#define RECUP_PERCENT_MAX 90.0
 
//#define IQ_RECUP_LEVEL_MIN_ACCUM 16777216 //3000V
//#define IQ_RECUP_LEVEL_MAX_ACCUM 17895697 //3200V

#define IQ_RECUP_LEVEL_MIN 15658734L	//2800V	//15099494L	//2700V //9507089L	//1700V	//8947848L	//1600V	//
#define IQ_RECUP_LEVEL_MAX 16777216L //3000V	//16777216L	//16217975L	//2900V	//11184810L	//2000V	//17895697 //3200V	10066329	//1800V	//

#define IQ_DELTA_U_START_RECUP          559240  //100V  //279620LL //50V
#define IQ_DELTA_U_MAX_OPEN_BREAK_KEYS  1677721LL//300 V


#define IQ_MIN_VOLTAGE_STOP_RUN 279620L	//50V
#define IQ_MAX_VOLTAGE_STOP_RUN 16777216L //3000V

#define BRK_STOP_RUN_PERCENT_MIN 5
#define BRK_STOP_RUN_PERCENT_MAX 50
 
//int break_resistor_managment_calc(int flag_on_off);
void break_resistor_managment_calc(void);
void break_resistor_managment_init(unsigned int freq_pwm);
void break_resistor_managment_update(void);
void break_resistor_recup_calc(_iq Uzpt_nominal);
void break_resistor_set_closed(void);
_iq calc_stop_run_recup(_iq voltage);


//extern PIDREG3 break_struct_1;
//extern PIDREG3 break_struct_2;




extern _iq break_result_1;
extern _iq break_result_2;
extern _iq break_result_3;
extern _iq break_result_4;

extern _iq kp_break;

#ifdef __cplusplus
	}
#endif

#endif /* _BREAK_REGUL_H */