#include "Page0.h"

extern BOOLEAN Ac97_bLoopTest;
extern BOOLEAN Ac97_bOutputOnly;

void UdpTestSend(PXCHAR pSrc, UCHAR iLength)
{
	p_memcpy_x2x((PXCHAR)Adapter_pSendUdpData, pSrc, iLength);
	UdpSend(iLength, UDP_TEST_SDRAM_LO);
}

void UdpTestRun()
{
	DCHAR iCommand, iSelection;

	if (XBYTE[Adapter_pReceiveUdpData] == '#' && XBYTE[Adapter_pReceiveUdpData+2] == '*')
	{
		iCommand = XBYTE[Adapter_pReceiveUdpData+1];
		iCommand -= '0';
		if (iCommand > 9) goto End;
		iSelection = XBYTE[Adapter_pReceiveUdpData+3];
		iSelection -= '0';
		if (iSelection > 9) goto End;
		switch (iCommand)
		{
		case 3:
		case 4:
			if (iSelection == 7)
			{
				Ac97Stop();
				Ac97_bOutputOnly = FALSE;
				SysSetMode(3);		// run in 22Mhz
			}
			else
			{
				UdpOpen(Adapter_pReceiveIPAddress, UDP_TEST_DST_PORT, UDP_TEST_SRC_PORT, UDP_TEST_SDRAM_LO);
				Ac97_bLoopTest = FALSE;
				Ac97_bOutputOnly = (iCommand == 4) ? TRUE : FALSE;
				Ac97SetInputSampleRate(TRUE);						//8K bps input
				SysSetMode(6);			// run in 36.75Mhz
//				Ac97Start(iSelection);
//				DspStart(iSelection);
			}
			return;
		default:
			break;
		}
	}

End:
	DspHandleDecodeData(Adapter_iReceiveLen, (PXCHAR)Adapter_pReceiveUdpData);
}

