#ifndef FUNCTION_H
#define FUNCTION_H

#define	LPF_GAIN_MACRO(v)		SFR_PAGE = 0; GEN_LPF = v
#define	LPF_IN_MACRO(v)			SFR_PAGE = 1; GEN_LPF = v
#define	GET_LPF_OUT(v)			SFR_PAGE = 2; v = GEN_LPF
#define	LPF_LAST_OUT_MACRO(v)	SFR_PAGE = 3; GEN_LPF = v
#define LPF_Active 				MOTOR_CONT1 |= 0x02;

#define DATA_FILTER(Data_I,Data_C,Data_O,Data_T,Data_F) (Data_C = Data_C + Data_I - Data_O, Data_O = (Data_T)(Data_C>>Data_F))
	//Latest output=DATA_ FILTER (input value, integral value, last output value, variable type, number of right shifts of integral quantity);
	//Continuous integral filter priority 8 times
	
	// uint16_t VSP_C,VSP_O;
	// VSP_O = DATA_FILTER(Adc_Cannel(V_BUS_CH), VSP_C, VSP_O, uint16, 5);
	// Vbus_avg = VSP_O;

extern signed int LPF_Function(signed int LPF_IN,signed int LPF_LAST_OUT,signed int Gain);
extern unsigned int LERP(unsigned int g,unsigned int a,unsigned int fa, unsigned int b,unsigned int fb);
extern short Ramp_Fun (short TargetValue,SetpointValue,HighLimit,LowLimit,SetpValue);
#endif
