⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 host20_ap.c

📁 FIC8120方案的 StartCell_Driver
💻 C
📖 第 1 页 / 共 5 页
字号:
           ,wSize,wOffset,wTotalSize_MByte,wTotalSize_Byte,wCounter);
     
       else
           printf(">>> High Speed ISO-Out data : (Size =%d / wOffset =%d)Total Size=%dMB + %dBytes =========> Counter=%d \n"
           ,wSize,wOffset,wTotalSize_MByte,wTotalSize_Byte,wCounter);
       
     }
    
   wOffset=wOffset + wOffsetIncrement;
  if (wOffset>=wOffsetMax)
     wOffset=0;
  
  wSize=wSize+wSizeIncrement;
  if (wSize>wSizeMax)
     wSize=wSizeIncrement;     
    
 //printf(">>> Wait for device compare data 500ms\n");    
  //flib_Host20_TimerEnable(500);//Wait for Device Compare Data    
    
    
    };	//while(wCounter<wInputCounter)

   printf(">>> ISO-Out data finish : %d \n" ,wCounter ); //<5>.Free the allocated Buffer
        for(i=0;i<OTGH_PT_ISO_DATABUFFER_NUM;i++)
            flib_Host20_ReleaseStructure(Host20_MEM_TYPE_4K_BUFFER,sOTGH_PT_ISO.aDataBufferArray[i]);
	
	        flib_Host20_Periodic_Setting(HOST20_Disable);
	
	
}

//====================================================================
// * Function Name: OTGH_PT_Interrupt_In_Out_RandomSize                          
// * Description: The Interrupt-In path test function call
//   <1>.Input the Test counter
//   <2>.Issue the INT-In command
//   <3>.Compare the receiving data
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_PT_Interrupt_In_Out_RandomSize(void)
{
   UINT32 wInputCounter,wCounter,j,wRandomSize_In,wRandomSize_Out,wForceInterval,wTempCurrentSize,wTempRemainSize;
   UINT8  bMode,bEdnum,i,bS_Mask,bMult,bTemp,bAuto,waIntervalMapConfig1,bTempCurrentPage;
   Host20_BufferPointerArray_Structure aTemp;
   UINT8 *pbData;
   UINT32 wStartSize,wMaxSize,wPrintCounter,wTotalLength_In,wTotalLength_Out,wMByte;
   UINT32 wIncrementSize;

   flib_Host20_Asynchronous_Setting(HOST20_Enable);

   wForceInterval=1;//(1ms)
   bS_Mask=1;
   bMult=1;
   bAuto=0;
 	   
   wStartSize=1;
   wRandomSize_In=wStartSize;
   wRandomSize_Out=wStartSize;

   if (OTGH_PT_ADVANCE_TEST==0) {   
      bMode=3;
      bAuto=0;

      if (psDevice_AP->bSpeed==HOST20_Attach_Device_Speed_Low) {
		 wMaxSize=1024;
         wIncrementSize=101;
         wPrintCounter=10;
	  } 
      else if (psDevice_AP->bSpeed==HOST20_Attach_Device_Speed_Full) {
		 wMaxSize=64;
         wIncrementSize=1;
         wPrintCounter=10;
      }
      else if (psDevice_AP->bSpeed==HOST20_Attach_Device_Speed_High) {
	     wMaxSize=64;  //1024;  //john modified from 64
         wIncrementSize=1;
         wPrintCounter=10;
      }

	  printf(">>> Please Input the Interrupt Counter:");  
      scanf("%d",&wInputCounter);         
	  printf("\n");

      printf(">>> wMaxSize = %d\n",wMaxSize);  
      printf(">>> wInputCounter = %d\n",wInputCounter);  
      printf(">>> wPrintCounter = %d\n",wPrintCounter);  
      printf(">>> wIncrementSize = %d\n",wIncrementSize);  
   }
   else { //if (AP_Auto_Test==1)
	  printf(">>> Please Input the 'wIncrementSize':");  
      scanf("%d",&wIncrementSize);         
      printf("\n");       
 
	  printf(">>> Please Input the 'wMaxSize'(FUSB200=>20*1024=20480)/(FOTG200=>MaxPacketSize):");  
      scanf("%d",&wMaxSize);         
      printf("\n");  
	 
      //<1>.Setting Configuration	
	  do {   
	     printf("****** Select Configuration Setting ******\n");  
	     printf(" <1>.Setting Interval(ms)(Now=%d)\n",wForceInterval);  	
	     printf(" <2>.Setting S_Mask(Now=%d)\n",bS_Mask);  	
	     printf(" <3>.Setting bMult(Now=%d)\n",bMult);  
	     printf(" <4>.Test Now... \n"); 	   
	     printf(" <5>.Auto Test...");
         scanf("%d",&bTemp);         
	     printf("\n");	   

	     switch (bTemp) {
	        case 1:
	           printf(">>> Please Input the Interval(ms):");  
               scanf("%d",&wForceInterval);         
	           printf("\n");	         
	           break;	 	
	        case 2:
	           printf(">>> Please Input the S_Mask(1~255):");  
               scanf("%d",&bS_Mask);         
	           printf("\n");		         
	           break;		         	
	        case 3:
	           printf(">>> Please Input the Interval(1~3):");  
               scanf("%d",&bMult);         
	           printf("\n");		         
	           break;		         	
	        case 5:
	           bAuto=1;
	           waIntervalMapConfig1=0;
	           break;		         	
		 }
	  } while((bTemp==1)|(bTemp==2)|(bTemp==3));
	
      if (bAuto==1)
         bMode=3;
      else {
	     //<2>.Input the Test counter & Condition
	     printf("****** Select Interrupt-IN/Out Mode (Random Size)******\n");  
	     printf(" <1>.Interrupt In Only.\n");  	
	     printf(" <2>.Interrupt Out Only.\n");  	
	     printf(" <3>.Interrupt In + Interrupt Out.\n");  
	     printf(">>> Please Input the Interrupt-IN/Out Mode:");  
         scanf("%d",&bMode);         
	     printf("\n");
	  }
	  
	  printf(">>> Please Input the Interrupt Counter:");  
      scanf("%d",&wInputCounter);         
	  printf("\n");

	  printf(">>> Please Input the 'Print Message'  counter:");  
      scanf("%d",&wPrintCounter);         
      printf("\n");       
   }  //if (AP_Auto_Test==1)
 
   flib_Host20_Interrupt_Init(wForceInterval,bS_Mask,bMult);//(ForceInterval,S-Mask,Mult)
	
   bEdnum=0;
   for (i=0;i<psDevice_AP->saCD[0].sInterface[0].bEP_NUMBER;i++) {
      if (psDevice_AP->saCD[0].sInterface[0].sED[i].bED_bmAttributes==OTGH_ED_INT) {
         if ((psDevice_AP->saCD[0].sInterface[0].sED[i].bED_EndpointAddress)&BIT7)
            sOTGH_PT_INT.bInQHDArrayNum=bEdnum++;
         else  
			sOTGH_PT_INT.bOutQHDArrayNum=bEdnum++;
	  }
   }
    
   wCounter=0;

   aTemp.BufferPointerArray[4]=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);
   aTemp.BufferPointerArray[3]=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);	
   aTemp.BufferPointerArray[2]=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);	
   aTemp.BufferPointerArray[1]=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);
   aTemp.BufferPointerArray[0]=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);		   

   wTotalLength_In=0;
   wTotalLength_Out=0;
   
   while (wCounter<wInputCounter) {  
      wCounter++;
      if (wCounter==bTemp)
         printf(">>> Counter = %d \n",wCounter);
      
      //<2>.Issue Interrupt-In 
      if ((bMode==1)|(bMode==3)) {
	     //<2.1>.Issue the INT-In command
	     flib_Host20_Issue_Interrupt(sOTGH_PT_INT.bInQHDArrayNum,wRandomSize_In
	                                      ,(&aTemp.BufferPointerArray[0]),0,OTGH_Dir_IN);
		 //printf("Issue INT_in traffic length = %d\n", wRandomSize_In);
         wTotalLength_In=wTotalLength_In+wRandomSize_In;

	     //<2.2>.Compare the receiving data
	     bTempCurrentPage=0;
	     wTempRemainSize=wRandomSize_In;
	     do {
	        //<1>.Decide the Compare Size & Current Page Buffer
	        if (wTempRemainSize>4*1024)
	           wTempCurrentSize=4*1024;
	        else   
			   wTempCurrentSize=wTempRemainSize;
			//printf("Current INT_in length =%d\n", wTempCurrentSize);  //john add

	        pbData=aTemp.BufferPointerArray[bTempCurrentPage];

	        //<2>.Compare Data
	        for (j=0;j<wTempCurrentSize;j++) {
			   if (sOTGH_PT_INT.bDataCounterIn!=*(pbData+j)) {
				  printf(">>> Total length = %d\n",wTempCurrentSize);
	              printf(">>> Error:INT-IN Fail (Expected data:0x%x/Received Data:0x%x\n",sOTGH_PT_INT.bDataCounterIn,*(pbData+j));	
	              printf(">>> Received Address:0x%x j=%d\n",(UINT32)(pbData+j),j);
	              OTGH_Error_Handle();  
			   }
			   //else john add 
			   //   printf(" %x", sOTGH_PT_INT.bDataCounterIn);
	           sOTGH_PT_INT.bDataCounterIn++;	
			}
			
	        //<3>.For Next compare     
            wTempRemainSize=wTempRemainSize-wTempCurrentSize;
            bTempCurrentPage++;
	                
		 } while(wTempRemainSize>0);
	  }

      //<3>.Issue Interrupt-Out 
      if ((bMode==2)|(bMode==3)) {
	     //<3.1>.Prepare the sending data
	     bTempCurrentPage=0;
	     wTotalLength_Out=wTotalLength_Out+wRandomSize_Out;
	     wTempRemainSize=wRandomSize_Out;
	     do {
	        //<1>.Decide the Compare Size & Current Page Buffer
	        if (wTempRemainSize>4*1024)
	           wTempCurrentSize=4*1024;
	        else   
			   wTempCurrentSize=wTempRemainSize;
			//printf("Current INT_out length =%d\n", wTempCurrentSize);  //john add
			
	        pbData=aTemp.BufferPointerArray[bTempCurrentPage];
	        
			//<2>.Prepare Data
	        for (j=0;j<wTempCurrentSize;j++) {
	           *(pbData+j)=sOTGH_PT_INT.bDataCounterOut++;
	        }		                 
	                 
	        //<3>.For Next compare     
            wTempRemainSize=wTempRemainSize-wTempCurrentSize;
            bTempCurrentPage++;
	                
		 } while(wTempRemainSize>0);

	     //<3.2>.Issue the INT-Out command
	     flib_Host20_Issue_Interrupt(sOTGH_PT_INT.bOutQHDArrayNum,wRandomSize_Out,(&aTemp.BufferPointerArray[0]),0,OTGH_Dir_Out);
		 //printf("Issue INT_out traffic length = %d\n", wRandomSize_Out);
	  }

      if ((wCounter%wPrintCounter)==0) {
         if (psDevice_AP->bSpeed==HOST20_Attach_Device_Speed_Low)
            printf(">>> Low Speed...\n");
         if (psDevice_AP->bSpeed==HOST20_Attach_Device_Speed_Full)
            printf(">>> Full Speed...\n");
         if (psDevice_AP->bSpeed==HOST20_Attach_Device_Speed_High)              
            printf(">>> High Speed...\n");

         if ((bMode==1)|(bMode==3)) {
            wMByte=wTotalLength_In/(1024*1024);

            printf(">>> INT In Test  (wForceInterval=%d / bS_Mask=%d / bMult=%d):PASS Counter(%d) \n",wForceInterval,bS_Mask,bMult,wCounter);
            printf(">>> Current Size = %d Total In Length=%d M Bytes (%d Bytes)\n",wRandomSize_In,wMByte,wTotalLength_In);
         }
         if ((bMode==2)|(bMode==3)) {
            wMByte=wTotalLength_Out/(1024*1024);

            printf(">>> INT Out Test  (wForceInterval=%d/bS_Mask=%d/bMult=%d):PASS Counter(%d) \n",wForceInterval,bS_Mask,bMult,wCounter);
            printf(">>> Current Size = %d  Total Out Length=%d M Bytes (%d Bytes)\n",wRandomSize_Out,wMByte,wTotalLength_Out);
         }      

      
         if (bAuto==1) {//Setting the Configuration
            //waIntervalMapConfig1++;
          	if (waIntervalMapConfig1>11)
          	    waIntervalMapConfig1=0;
          	wForceInterval=waIntervalMap[waIntervalMapConfig1];
          	
          	bS_Mask++;
          	if (bS_Mask==0)
          	    bS_Mask=1;
          	
          	bMult++;
          	if (bMult>3)    
          	    bMult=1;

            flib_Host20_Interrupt_Init(wForceInterval,bS_Mask,bMult);//(ForceInterval,S-Mask,Mult)
          	
		 }//if (bAuto==1)
	  }// if ((wCounter%10)==0)     
   
      if ((bMode==1)|(bMode==3)) {
	     wRandomSize_In=wRandomSize_In+wIncrementSize;
	     if (wRandomSize_In>(wMaxSize))
	        wRandomSize_In=wStartSize;
      }

      if ((bMode==2)|(bMode==3)) {
	     wRandomSize_Out=wRandomSize_Out+wIncrementSize;
	     if (wRandomSize_Out>(wMaxSize))
	        wRandomSize_Out=wStartSize;
      }
   }// while(wCounter<wInputCounter)

   printf(">>> Interupt Test Finish ... PASS (%d) \n",wInputCounter);   

   //Release all the Data Buffer
   for (i=0;i<5;i++)
       flib_Host20_ReleaseStructure(Host20_MEM_TYPE_4K_BUFFER,aTemp.BufferPointerArray[i]);

   flib_Host20_Asynchronous_Setting(HOST20_Disable);
}


//====================================================================>ok
// * Function Name: OTGH_PT_GetDescriptor                          
// * Description: The GetDescriptor function call
//   <1>.Input the Test counter
//   <2>.Issue the Control command
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_PT_GetDescriptor (UINT32 wCounterInput)
{
 UINT8 bCMD[8];
 UINT8 bFaradayAP[4]={0x10,0x23,0x78,0x56};
 UINT32 wInputCounter,wCounter,wPrintCounter;
 UINT8 bTempData[18];
	
	
	//<1>.Input the Test counter 
    if (wCounterInput>0)
       {
       	wInputCounter=wCounterInput;
        wPrintCounter=1;
       }
    else{   
       printf("*** Please Input Counter:");  
       scanf("%d",&wInputCounter);         
       printf("\n");

	   printf(">>> Please Input the 'Print Message'  counter:");  
       scanf("%d",&wPrintCounter);         
       printf("\n");       
      }

    wCounter=0;

     do{

	//<2>.Issue the Control command
        memcpy(bCMD,OTGH_GETDESCRIPTOR_DEVICE,8);
        flib_Host20_Issue_Control (1,bCMD,0x12,bTempData);
        if (memcmp(bFaradayAP,bTempData,4)>0)
           {//This is not the Faraday Test AP
           	printf(">>>Error:This is not the Faraday Test AP...");

           	}
       wCounter++;
      if ((wCounter%wPrintCounter)==0)
          printf(">>> Control Test: Out data = %d \n",wCounter);
	   }while(wCounter<wInputCounter);
	
	printf(">>> Issue GetDescriptor OK => Counter = %d \n",wInputCounter);
	
	
}
//************************************************************************************************************
//************************************************************************************************************
//                          *** Group-2:Other Function ***

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -