?? test_usb.c
字號(hào):
/*********************************************************************************
Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.
This software is proprietary and confidential. By using this software you agree
to the terms of the associated Analog Devices License Agreement.
*********************************************************************************/
#include "DSPIncludes.h"
#include "services.h" // system service includes
#include "adi_net2272.h" // NET2272 device driver includes
#include "plx\NcCommon.h"
#include "plx\NcFwApi.h"
#include "plx\Net2272.h"
#include "usbcmd.h"
#define SDMODIFY (BIT_17)
extern volatile bool g_bDeviceConfigured;
// firmware version string info
#pragma align 4
char FwVersionInfo[NUM_VERSION_STRINGS][MAX_VERSION_STRING_LEN] = { __DATE__, //build date
__TIME__, //build time
#ifdef __ADSP21262__
"SHARC - 21262",
#elif __ADSP21364__
"SHARC - 21364",
#elif __ADSP21369__
"SHARC - 21369",
#endif
"01.00.00", //version number
"Loopback"}; //application name
/*********************************************************************
Prototypes
*********************************************************************/
unsigned int QuerySupport( u32 u32Command );
unsigned int Loopback( u32 u32Count);
unsigned int ReadMemory( u8 *p8Address, u32 u32Count );
unsigned int WriteMemory( u8 *p8Address, u32 u32Count );
/*********************************************************************
Static data
*********************************************************************/
ADI_DEV_1D_BUFFER UsbcbBuffer;
/*********************************************************************
The loopback function. This test never returns.
*********************************************************************/
int TEST_USB(void)
{
unsigned int Result;
bool bKeepRunning = TRUE;
USBCB usbcb;
USBCB *pusbcb = &usbcb;
// initialize the buffer
UsbcbBuffer.Data = &usbcb;
UsbcbBuffer.ElementCount = sizeof(usbcb) * BYTES_IN_SHARC_BYTE;
UsbcbBuffer.ElementWidth = 1;
UsbcbBuffer.CallbackParameter = NULL;
UsbcbBuffer.ProcessedFlag = FALSE;
UsbcbBuffer.ProcessedElementCount = 0;
UsbcbBuffer.pNext = NULL;
#if ( defined(__ADSP21375__) || defined(__ADSP21369__) )
// make sure DMA is off and flushed
* (volatile int *)DMAC0 = (DFLSH | TFLSH);
#endif
Result = adi_dev_Open();
while (!g_bDeviceConfigured) // wait here until the device is configured
;
// while we should keep running
while( bKeepRunning )
{
// wait for a USB command block from the host indicating what function we should perform
Result = adi_dev_Read(ADI_DEV_1D, (ADI_DEV_BUFFER *)&UsbcbBuffer);
if ( ADI_DEV_RESULT_SUCCESS == Result )
{
// switch on the command we just received
switch( pusbcb->ulCommand )
{
// host is asking if we support a given command
case QUERY_SUPPORT:
Result = QuerySupport(pusbcb->ulData );
break;
// get the firmware version
case GET_FW_VERSION:
Result = ReadMemory((u8*)FwVersionInfo, pusbcb->ulCount );
break;
// run loopback
case LOOPBACK:
Result = Loopback(pusbcb->ulCount );
break; //return( ADI_DEV_RESULT_SUCCESS == Result );
// unsupported command
default:
break;
}
}
}
return 0;
}
#ifdef _STANDALONE_
void main(void)
{
TEST_USB();
}
#endif //_STANDALONE_
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -