#include "CommandsDefine.h"
#include "ProjectConfig.h"
#include "Probe_MSO7000X_2d5g.h"
#include "AnalogChannelCtrl_2d5g_base.h"
#include "Helper.h"
#include "delay.h"
//////////////////////////////////////////////////////////////////////////////
// 			2203/5/X GHz_ljw 合并版
// 			2203/6/9 GHz_ljw 优化OFFSET
//////////////////////////////////////////////////////////////////////////////

void CMD0x41_Request_AnalogChannelOffset_process(u8 *pData,u16 dataLen,u8 bIsContentBitInverted_Recv,u8 bIsContentBitInverted_SendBack)
{
	//delay_ms(10);
	//return;
#ifdef RUNNING_WHERE_AT_BOOT	
	Command_SendbackErrorMessage(Error0x02_CannotRunAtBoot);
#else
	u8 bDataOK=1;
	u8 validDataLength=dataLen;
	if (bIsContentBitInverted_Recv)
	{
		validDataLength=dataLen/2;
		if (!Helper_CheckInvertBytesIsRegist(pData,dataLen))
			bDataOK=0;
	}
	if (validDataLength<5)
		bDataOK=0;
	if (bDataOK)
	{
		u32 AD5668_CMD;
		for(u8 i=1; i<5; i++) {
				AD5668_CMD=(AD5668_CMD<<8)+pData[i];//get DAC(AD5628) command code
				//AD5668_CMD=(AD5668_CMD<<4); }
		}
		//u8 setPort = (AD5668_CMD>>16)&0xF - 1;
		u8 dacID = pData[0]-6;
		//u16 data = AD5668_CMD&0xFFFF;
		//u8 isOffset = 0xff;
		//if(DAC_CMDs[dacID][setPort] == data) return;
		if(dacID==0)//DAC1
		{		
				DAC_AD5675(AD5668_CMD,DAC1); 
		}
		else if(dacID==1)//DAC2
		{
	 
				DAC_AD5675(AD5668_CMD,DAC2);	 
		}
		if(dacID==2)//DAC3
		{			 
				DAC_AD5675(AD5668_CMD,DAC3);	 
		}
	}
	else
		Command_SendbackErrorMessage(Error0x05_CMD_ParaLentghError,1);			
 
#endif		
}
