#include "CommandsDefine.h"
#include "ProjectConfig.h"
#include "Probe_MSO7000X_2d5g.h"
#include "AnalogChannelCtrl_2d5g_base.h"
#include "delay.h"
#include "Helper.h"
void CMD0x42_Request_AnalogChannelGain_process(u8 *pData,u16 dataLen,u8 bIsContentBitInverted_Recv,u8 bIsContentBitInverted_SendBack)
{
#ifdef RUNNING_WHERE_AT_BOOT	
	Command_SendbackErrorMessage(Error0x02_CannotRunAtBoot,1);
#else
	u8 bDataOK=1;
	u8 validDataLength=dataLen;
	if (bIsContentBitInverted_Recv)
	{
		validDataLength=dataLen/2;
		if (!Helper_CheckInvertBytesIsRegist(pData,dataLen))
			bDataOK=0;
	}
	if (validDataLength<2)
		bDataOK=0;
	if (!bDataOK)
	{
		Command_SendbackErrorMessage(Error0x05_CMD_ParaLentghError,1);		
		return;
	}

	u8 PE43711_CMD=pData[1];// get DSA(PE43711) command code
	u8 ADDR_CMD=pData[0];//addr
 
	if(ADDR_CMD==1)//CH1 DSA
	{
			DSA_PE43711(LMH6401_ADDR_GAIN,PE43711_CMD,CH1_DSA_CS);
			//  printf("PE43711 data is legal\r\n");
	}
	else if(ADDR_CMD==2)//CH2 DSA
	{
			DSA_PE43711(LMH6401_ADDR_GAIN,PE43711_CMD,CH2_DSA_CS);
			// printf("PE43711 data is legal\r\n");
	}
	else if(ADDR_CMD==4)//CH3 DSA
	{
			DSA_PE43711(LMH6401_ADDR_GAIN,PE43711_CMD,CH3_DSA_CS);
			// printf("PE43711 data is legal\r\n");
	}
	else if(ADDR_CMD==8)//CH4 DSA
	{
			DSA_PE43711(LMH6401_ADDR_GAIN,PE43711_CMD,CH4_DSA_CS);
			// printf("PE43711 data is legal\r\n");
	}
	delay_us(20);
#endif		
}
