#include "IQmathLib.h"         // Include header for IQmath library
#include "abc_to_dq.h"









/////////////////////////////////////////////////


#pragma CODE_SECTION(abc_to_dq_calc,".fast_run");
void abc_to_dq_calc(ABC_TO_DQ *v)
{
	static _iq iq_two_third_pi = _IQ(6.283185307179586476925286766559/3.0);
	static _iq iq_two_third = _IQ(2.0/3.0);
	
	v->Id = _IQmpy(iq_two_third,_IQmpy(v->Ia, _IQsin(v->Tetta)) + _IQmpy(v->Ib, _IQsin(v->Tetta - iq_two_third_pi)) + _IQmpy(v->Ic, _IQsin(v->Tetta + iq_two_third_pi)));
	v->Iq = _IQmpy(iq_two_third,_IQmpy(v->Ia, _IQcos(v->Tetta)) + _IQmpy(v->Ib, _IQcos(v->Tetta - iq_two_third_pi)) + _IQmpy(v->Ic, _IQcos(v->Tetta + iq_two_third_pi)));  
}


#pragma CODE_SECTION(abc_to_dq_calc_v2,".fast_run");
void abc_to_dq_calc_v2(ABC_TO_DQ *v)
{
	static _iq iq_two_third_pi = _IQ(6.283185307179586476925286766559/3.0);
	static _iq iq_two_third = _IQ(2.0/3.0);
	
	v->Id = _IQmpy(iq_two_third,_IQmpy(v->Ia, _IQcos(v->Tetta)) + _IQmpy(v->Ib, _IQcos(v->Tetta - iq_two_third_pi)) + _IQmpy(v->Ic, _IQcos(v->Tetta + iq_two_third_pi)));
	v->Iq = _IQmpy(iq_two_third,_IQmpy(-v->Ia, _IQsin(v->Tetta)) - _IQmpy(v->Ib, _IQcos(v->Tetta - iq_two_third_pi)) - _IQmpy(v->Ic, _IQcos(v->Tetta + iq_two_third_pi)));  
}


/////////////////////////////////////////////////


