📄 host20_ap.c
字号:
//*************************************************************************************************************
//************************************************************************************************************
//====================================================================
// * Function Name: OTGH_PT_Emulation_Again
// * Description:
// <1>.Step1:flib_Host20_Close
// <2>.Step2:flib_Host20_Enumerate(1,X)
// <3>.Step3:Goto step1
//
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_PT_Emulation_Again(void)
{
//<1>.Step1:flib_Host20_Close
flib_Host20_Close(0);
flib_OTGH_Init(10000,1,0); //john 0,0);
//<2>.Step2:flib_Host20_Enumerate(1,X)
flib_Host20_Enumerate(1,3);
OTGH_PT_Init();
}
//====================================================================
// * Function Name: OTGH_AP_Suspend_Resume_Test
// * Description:
// <1>.Step1:flib_Host20_Close
// <2>.Step2:flib_Host20_Enumerate(1,X)
// <3>.Step3:Goto step1
//
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_AP_Suspend_Resume_Test(void)
{
UINT8 bCounter=0;
do{
bCounter++;
//<1>.Suspend System
printf(">>> Step1:Suspend System\n");
flib_Host20_Suspend();
mwHost20_Misc_Physuspend_Set();//08242005;;For Austin Phy Suspend
//Delay 100 ms
flib_Host20_TimerEnable(100);
mwHost20_Misc_Physuspend_Clr();//08242005;;For Austin Phy Suspend
//<2>.Resume
printf(">>> Step2:Issue resume signal...\n");
flib_Host20_Resume();
//<Step5>.Get Device Descriptor 10 times
printf(">>> Step5:Get Device Descriptors 10 times\n");
OTGH_PT_GetDescriptor (10);
//<Step6>.Finish...
printf(">>> Suspend/Resume Test Finish...%d\n",bCounter);
}while(bCounter<100);
}
//====================================================================
// * Function Name: OTGH_AP_RemoteWakeUp_Test
// * Description:
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_AP_RemoteWakeUp_Test(void)
{
UINT8 bExitFlag,bItem;
UINT8 bCounter=0;
do{
bCounter++;
//<1>.Enable Remote Wakeup
printf(">>> Step1:Enable Remote Wakeup \n");
flib_OTGH_RemoteWakeEnable();
//<2>.Suspend System
printf(">>> Step2:Suspend System\n");
flib_Host20_Suspend();
mwHost20_Misc_Physuspend_Set();//08242005;;For Austin Phy Suspend
//<Step3>.Waiting for Remote WakeUp Signal & Issue resume signal...
printf(">>> Step3:Waiting for Remote WakeUp Signal & Issue resume signal...\n");
bExitFlag=0;
sAttachDevice.bRemoteWakeUpDetected=0;
while(sAttachDevice.bRemoteWakeUpDetected==0);
mwHost20_Misc_Physuspend_Clr();//08242005;;For Austin Phy Suspend
//<Step4>.Call flib_Host20_RemoteWakeUp_Processing
flib_Host20_RemoteWakeUp_Processing();
printf(">>> Step4:<1>.Detected Remote WakeUp Signal...\n");
printf(">>> <2>.Issue Resume Finihs...\n");
//Bruce;;08032005 ==> Enable the Asynchronous
flib_Host20_Asynchronous_Setting(HOST20_Enable);
//<Step5>.Get Device Descriptor 10 times
printf(">>> Step5:Get Device Descriptors 10 times\n");
OTGH_PT_GetDescriptor (10);
//<Step6>.Finish...
printf(">>> Remote Wake Up Test PASS...%d\n",bCounter);
if (bCounter<10)
{ printf("*** press Enter'1' to retest...");
scanf("%d",&bItem);
printf("\n");
}
}while((bCounter<10)&(bItem==1));
}
//====================================================================
// * Function Name: OTGH_AP_Plug_in_Test
// * Description: bMode=0 =>Cold Plug (Remove USB Device)
// bMode=1 =>Hot Plug (Without Remove USB Device)
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_AP_Plug_in_Test(UINT8 bMode)
{
UINT32 wCounter=0;
do {
wCounter++;
printf("@@@ Waiting for Device Disconnect...\n");
while(mwHost20_PORTSC_ConnectStatus_Rd()>0);
printf("@@@ Device already disconnect...\n");
if (bMode==0)
{
//For Cold Plug
OTGC_A_Bus_Drop();
printf("@@@ Drop VBUS ok...\n");
OTGC_A_Bus_Drive();
}
else
flib_Host20_Close(0);
//<2>.Waiting for Connect
printf("@@@ Enter DRD Host Mode...(Counter=%d)\n",(int)(wCounter));
printf("@@@ Waiting for Device Connect...\n");
while(mwHost20_PORTSC_ConnectStatus_Rd()==0);
if (flib_OTGH_Init(10000,1,0)==1) //john 0,0)==1)
{
if (flib_Host20_Enumerate(0,wCounter)==0)
printf("??? Enumerate Fail...\n");
}
else {
printf("??? Host Init Fail...\n");
}
}while(wCounter<10);
if (bMode==1)
printf(">>> Hot Plug 10 times test finish...\n");
else
printf(">>> Cold Plug 10 times test finish...\n");
}
//====================================================================
// * Function Name: OTGH_PT_CV_Like
// * Description:
// <1>.Step1:flib_Host20_Close
// <2>.Step2:flib_Host20_Enumerate(1,X)
// <3>.Step3:Goto step1
//
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_PT_CV_Like(void)
{
UINT32 wAddress;
UINT8 bResult,bExit,bFailCounter;
wAddress=1;
bResult=1;
bExit=0;
do {
//<1>.Step1:flib_Host20_Close
flib_Host20_Close(0);
//OTGC_A_Bus_Drop();
//printf("@@@ Drop VBUS ok...\n");
// OTGC_A_Bus_Drive();
//<2>.Step2:flib_Host20_Enumerate(1,X)
printf("*********************** Address=%d ******************* \n",wAddress);
flib_Host20_TimerEnable(100); //john reduce delay time 500
flib_OTGH_Init(10000,1,0); //john 0,0);
bFailCounter=0;
while(flib_Host20_Enumerate(0,wAddress)==0)
{
bFailCounter++;
if (bFailCounter<4)
{
flib_Host20_Close(0);
printf("*********************** Address=%d Retry******************* \n",wAddress);
flib_Host20_TimerEnable(500);
flib_OTGH_Init(10000,1,0); //john 0,0);
}
else {
printf("?????????????????????????? Enumerate Fail...\n");
bExit=1;
OTGH_Error_Handle();
}
}
wAddress++;
if (wAddress==128)
bExit=1;
}while( bExit==0);
//<1>.Step1:flib_Host20_Close
flib_Host20_Close(0);
flib_OTGH_Init(10000,1,0); //john 0,0);
//<2>.Step2:flib_Host20_Enumerate(1,X)
flib_Host20_Enumerate(1,3);
}
//====================================================================
// * Function Name: OTGH_PT_FrameNumber
// * Description:
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_PT_FrameNumber(void)
{
UINT32 *pwData;
UINT32 wCounter,wPreData;
UINT8 bTemp,bTestFlag;
pwData=malloc(1000*2);
wCounter=0;
bTemp=0;
bTestFlag=1;
do{
*(pwData+wCounter)=mwHost20_FrameIndex14Bit_Rd()>>3;
flib_Host20_TimerEnable(1);
wCounter++;
}while(wCounter<(2*1000));
wCounter=0;
wPreData=*(pwData+wCounter);
printf("Counter=%d ===> FrameNumber=%d \n",wCounter,*(pwData+wCounter));
do{
wCounter++;
printf("Counter=%d ===> FrameNumber=%d \n",wCounter,*(pwData+wCounter));
if (*(pwData+wCounter)>(wPreData+3))
{
printf("Waring............\n");
bTestFlag=0;
}
if (*(pwData+wCounter)==(wPreData))
{
printf("Waring............\n");
bTestFlag=0;
}
wPreData=*(pwData+wCounter);
}while(wCounter<(2*1000-1));
free(pwData);
if (bTestFlag==0)
printf(">>> Test Fail...\n");
else printf(">>> Frame Counter Test PASS...\n");
}
//************************************************************************************************************
//************************************************************************************************************
// *** Group-3:Main Function ***
//*************************************************************************************************************
//************************************************************************************************************
//====================================================================
// * Function Name: OTGH_PT_Init
// * Description: This function will init the variables.
// <1>.Variable init - INT
// <2>.Variable init - ISO
// <3>.Variable init - Bulk
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_PT_Init(void)
{
//<1>.Variable init - Control
sOTGH_PT_Control.bDataCounter_IN=0;
sOTGH_PT_Control.bDataCounter_OUT=0;
//<2>.Variable init - INT
sOTGH_PT_INT.bDataCounterIn=0;
sOTGH_PT_INT.bDataCounterOut=0;
sOTGH_PT_INT.bMaxSize=13;
sOTGH_PT_INT.bINT_Dir=0;
//<3>.Variable init - ISO
sOTGH_PT_ISO.bDataMax=255;
sOTGH_PT_ISO.bDataCounter=0;
//<4>.Variable init - Bulk
}
//====================================================================
// * Function Name: OTGH_AP_Faraday
// * Description: Main menu of path test
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_AP_Faraday(void)
{
UINT8 Item;
OTGH_PT_Init();
do{
printf("************* Host Mode Faraday Path Test AP ******************\n");
if (OTGC_Read_Current_ID()==0)
printf(" 1.Control => Control Command Test \n");
if (OTGC_Read_Current_ID()==0)
if (OTGH_PT_ADVANCE_TEST==1)
if (psDevice_AP->bSpeed!=HOST20_Attach_Device_Speed_Low)
printf(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -