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

📄 lib_host20.c

📁 GM8120 linux driver.
💻 C
📖 第 1 页 / 共 5 页
字号:
         wFrameNumber=wOriginalFrameNumber;            for (i=0;i<wiTDNum;i++)                   {              if (wFrameNumber>1023)                  wFrameNumber=wFrameNumber-1024;              psHost20_FramList->sCell[wFrameNumber].bTerminal=1;                           psHost20_FramList->sCell[wFrameNumber].bLinkPointer=0;                             wFrameNumber++;             }                  //<6>.Free the iTD         for (i=0;i<wiTDNum;i++)                   {              spTempiTD=psDevice_AP->wISOiTDAddress[i];              flib_Host20_ReleaseStructure(Host20_MEM_TYPE_iTD,psDevice_AP->wISOiTDAddress[i]);             } pwData=(UINT32*)0x90100080; *pwData=0X0000;}#if 1//====================================================================// * Function Name: flib_Host20_Issue_ISO_siTD                          // * Description: // * OutPut: //====================================================================void  flib_Host20_Issue_ISO_siTD(UINT8 bCheckResult,UINT32 wEndPt,UINT32 wMaxPacketSize,UINT32 wSize                            ,UINT32 *pwBufferArray,UINT32 wOffset,UINT8 bDirection,UINT8 bMult){   siTD_Structure  *spTempsiTD;   UINT32 wRemainSize,wCurrentOffset,wCurrentBufferNum,wCurrentLength,wsiTDNum,wFrameNumber,i,wOriginalFrameNumber,wDummyTemp;   UINT8  bExitFlag,bT_Count;   //UINT32 *pwLastTransaction;   UINT32 wCurrentBufferNum1,wCurrentBufferNum2;       //flib_Host20_Periodic_Setting(HOST20_Disable);//For Test;;Remove     //<1>.Allocate the siTD for the Data Buffer   wRemainSize=wSize;   wCurrentBufferNum=0;   wsiTDNum=0;   wCurrentOffset=wOffset;   while(wRemainSize) {      //<1.1>.Allocate siTD      psDevice_AP->wISOiTDAddress[wsiTDNum]=flib_Host20_GetStructure(Host20_MEM_TYPE_siTD);      spTempsiTD=psDevice_AP->wISOiTDAddress[wsiTDNum];      //<1.2>.Fill Word-1               spTempsiTD->bTerminate=1;                                          //<1.3>.Fill Word-2      spTempsiTD->bDeviceAddress=psDevice_AP->bAdd;      spTempsiTD->bEdNumber=wEndPt;      spTempsiTD->bHubAddr=sAttachDevice.bAdd;      spTempsiTD->bPortNumber=psDevice_AP->bOnHubPortNumber+1;      spTempsiTD->bInOut=bDirection;      //<1.4>.Fill Word-3      if (bDirection==OTGH_Dir_IN) {         spTempsiTD->bS_Mask=0x01;         spTempsiTD->bC_Mask=0xFc;               }      //<1.5>.Fill Word-4      spTempsiTD->bStatus=HOST20_siTD_Status_Active;       spTempsiTD->bPageSelect=0;       //<1.6>.Decide the Current Size for this siTD      if (wRemainSize>wMaxPacketSize)        	         wCurrentLength=wMaxPacketSize;      else 		 wCurrentLength=wRemainSize;         	   	  //<1.7>.Fill Word-4-Length      spTempsiTD->bTotalBytesToTransfer= wCurrentLength;                //<1.8>.Fill the Word-6      if (bDirection==OTGH_Dir_Out) {         //Fill T_Count         bT_Count=wCurrentLength/188;         if ((wCurrentLength%188)>0)            bT_Count++;         if (bT_Count<=6)            spTempsiTD->bT_Count=bT_Count;         else {          	printf("??? Error ...bT_Count>6...\n");           	while(1);		 }                         //Fill bTransactionPosition          if (wCurrentLength<188)            spTempsiTD->bTransactionPosition=HOST20_siTD_TP_All;         else			spTempsiTD->bTransactionPosition=HOST20_siTD_TP_Begin;         //Fill S-Mask/C-Mask         spTempsiTD->bS_Mask=(1<<bT_Count)-1;         spTempsiTD->bC_Mask=0x00;            		  }          //<1.8>.Fill the Buffer Pointer-0      spTempsiTD->bBufferPointer_Page0                      =((UINT32)*(pwBufferArray+wCurrentBufferNum)>>12);            	      spTempsiTD->bCurrentOffset=wCurrentOffset;               //<1.9>.Maintain wCurrentOffset / wRemainSize      wRemainSize=wRemainSize-wCurrentLength;       wCurrentOffset=wCurrentOffset+wCurrentLength;      if (wCurrentOffset>=4096)      {         wCurrentBufferNum++;                      //Cross Page Process         spTempsiTD->bBufferPointer_Page1                  =((UINT32)*(pwBufferArray+wCurrentBufferNum)>>12);                                          wCurrentOffset=wCurrentOffset-4096;		  }       if (wRemainSize==0) {         spTempsiTD->bInterruptOnComplete=1;	         // pwLastTransaction=&(spTempiTD->ArrayStatus_Word[bCurrentTransactionNum]);      }      wsiTDNum++;      if (wsiTDNum>512) {         printf(">>> Waring...iTD Number >512... \n"); 	         while(1);      }   }// while(wRemainSize)	         //<2>.Init the Global Variable          psDevice_AP->bSendStatusError=0;   gwLastiTDSendOK=0;   psDevice_AP->bISOTransferEnable=1;   wISOOTGIn_Counter++;   //<3>.Hang the qTD to the FrameList   //<2.1>.Read the Current Frame List   wCurrentBufferNum1=mwHost20_FrameIndex14Bit_Rd()>>3;   wOriginalFrameNumber=(mwHost20_FrameIndex_Rd()>>3);   wOriginalFrameNumber=wOriginalFrameNumber+10;//300            //<2.2>.Hang the qTD to the Current Frame + 100 ms   wCurrentBufferNum2=mwHost20_FrameIndex14Bit_Rd()>>3;           //wCurrentBufferNum2           wFrameNumber=wOriginalFrameNumber;            // wFrameNumber=1;//For Test;;Remove   // wOriginalFrameNumber=1;//For Test;;Remove            for (i=0;i<wsiTDNum;i++) {      if (wFrameNumber>1023)         wFrameNumber=wFrameNumber-1024;                   psHost20_FramList->sCell[wFrameNumber].bLinkPointer=(UINT32)(psDevice_AP->wISOiTDAddress[i])>>5;      psHost20_FramList->sCell[wFrameNumber].bTerminal=0;        psHost20_FramList->sCell[wFrameNumber].bType=2;                                wFrameNumber++;   }         // flib_Host20_Periodic_Setting(HOST20_Enable);//For Test;;Remove                  //<4>.Waiting for the Complete the processing iTDs   bExitFlag=0;     do {      wDummyTemp++;      if (wDummyTemp>1000) {         wDummyTemp=0;	         if (gwLastiTDSendOK==1)            bExitFlag=1;		  }       	   }   while(bExitFlag==0);   //  while(((*pwLastTransaction)&0x80000000)>0);   psDevice_AP->bISOTransferEnable=0;            if (psDevice_AP->bSendStatusError==1) {      psDevice_AP->bSendStatusError=0;	      printf("???USB Error... Halt the system...\n ");	      while(1);   }   //Critical Time Period End ---------------------------------------------------           //Check the result    for (i=0;i<wsiTDNum;i++) {      spTempsiTD=psDevice_AP->wISOiTDAddress[i];      if (spTempsiTD->bStatus==HOST20_iTD_Status_Active) {         printf("??? After Complete => Active Bit=1 ==> (i=%d)(Address=0x%x)\n",i,(UINT32)spTempsiTD);         while(1);      }      if (spTempsiTD->bTotalBytesToTransfer!= 0) {         printf("??? After Complete => Length>0 ==> (i=%d)(Address=0x%x)\n",i,(UINT32)spTempsiTD);         while(1);      }    	   }   //<5>.Retire the siTD   wFrameNumber=wOriginalFrameNumber;      for (i=0;i<wsiTDNum;i++) {      if (wFrameNumber>1023)         wFrameNumber=wFrameNumber-1024;      psHost20_FramList->sCell[wFrameNumber].bTerminal=1;                   psHost20_FramList->sCell[wFrameNumber].bLinkPointer=0;                     psHost20_FramList->sCell[wFrameNumber].bType=HOST20_HD_Type_siTD;         wFrameNumber++;   }         //<6>.Free the iTD   for (i=0;i<wsiTDNum;i++) {      spTempsiTD=psDevice_AP->wISOiTDAddress[i];      flib_Host20_ReleaseStructure(Host20_MEM_TYPE_iTD,psDevice_AP->wISOiTDAddress[i]);   }}#else //====================> Old Sitd//====================================================================// * Function Name: flib_Host20_Issue_ISO_siTD                          // * Description: // * OutPut: //====================================================================void  flib_Host20_Issue_ISO_siTD(UINT8 bCheckResult,UINT32 wEndPt,UINT32 wMaxPacketSize,UINT32 wSize                            ,UINT32 *pwBufferArray,UINT32 wOffset,UINT8 bDirection,UINT8 bMult){   siTD_Structure  *spTempsiTD;   UINT32 wRemainSize,wCurrentOffset,wCurrentBufferNum,wCurrentLength,wsiTDNum,wFrameNumber,i,wOriginalFrameNumber,wDummyTemp;   UINT8  bExitFlag;   //UINT32 *pwLastTransaction;   UINT32 wCurrentBufferNum1,wCurrentBufferNum2;            //<1>.Allocate the siTD for the Data Buffer   wRemainSize=wSize;   wCurrentBufferNum=0;   wsiTDNum=0;   wCurrentOffset=wOffset;   while(wRemainSize) {      //<1.1>.Allocate siTD      psDevice_AP->wISOiTDAddress[wsiTDNum]=flib_Host20_GetStructure(Host20_MEM_TYPE_siTD);      spTempsiTD=psDevice_AP->wISOiTDAddress[wsiTDNum];      //<1.2>.Fill Word-1               spTempsiTD->bTerminate=1;                                         //<1.3>.Fill Word-2      spTempsiTD->bDeviceAddress=psDevice_AP->bAdd;      spTempsiTD->bEdNumber=wEndPt;      spTempsiTD->bHubAddr=sAttachDevice.bAdd;      spTempsiTD->bPortNumber=psDevice_AP->bOnHubPortNumber;      spTempsiTD->bInOut=bDirection;      //<1.4>.Fill Word-3      spTempsiTD->bS_Mask=0x01;      spTempsiTD->bC_Mask=0xFc;               //<1.5>.Fill Word-4      spTempsiTD->bStatus=HOST20_iTD_Status_Active;       spTempsiTD->bPageSelect=0;       //<1.6>.Decide the Current Size for this siTD      if (wRemainSize>wMaxPacketSize)        	     	 wCurrentLength=wMaxPacketSize;      else 		 wCurrentLength=wRemainSize;    	      //<1.7>.Fill Word-4-Length      spTempsiTD->bTotalBytesToTransfer= wCurrentLength;                //<1.8>.Fill the Buffer Pointer-0      spTempsiTD->bBufferPointer_Page0                      =((UINT32)*(pwBufferArray+wCurrentBufferNum)>>12);            	      spTempsiTD->bCurrentOffset=wCurrentOffset;               //<1.9>.Maintain wCurrentOffset / wRemainSize      wRemainSize=wRemainSize-wCurrentLength;       wCurrentOffset=wCurrentOffset+wCurrentLength;      if (wCurrentOffset>=4096) {         wCurrentBufferNum++;                      //Cross Page Process         spTempsiTD->bBufferPointer_Page1                     =((UINT32)*(pwBufferArray+wCurrentBufferNum)>>12);                                 wCurrentOffset=wCurrentOffset-4096;		  }       if (wRemainSize==0) {	     spTempsiTD->bInterruptOnComplete=1;	         // pwLastTransaction=&(spTempiTD->ArrayStatus_Word[bCurrentTransactionNum]);      }      wsiTDNum++;      if (wsiTDNum>512) {         printf(">>> Waring...iTD Number >512... \n"); 	         while(1);	  }   }// while(wRemainSize)	   //<2>.Hang the qTD to the FrameList   //<2.1>.Read the Current Frame List   psDevice_AP->bSendStatusError=0;   wCurrentBufferNum1=mwHost20_FrameIndex14Bit_Rd()>>3;   wOriginalFrameNumber=(mwHost20_FrameIndex_Rd()>>3);   wOriginalFrameNumber=wOriginalFrameNumber+10;//300            //<2.2>.Hang the qTD to the Current Frame + 100 ms   wCurrentBufferNum2=mwHost20_FrameIndex14Bit_Rd()>>3;           //wCurrentBufferNum2                wFrameNumber=wOriginalFrameNumber;   for (i=0;i<wsiTDNum;i++) {      if (wFrameNumber>1023)         wFrameNumber=wFrameNumber-1024;                   psHost20_FramList->sCell[wFrameNumber].bLinkPointer=(UINT32)(psDevice_AP->wISOiTDAddress[i])>>5;      psHost20_FramList->sCell[wFrameNumber].bTerminal=0;                   wFrameNumber++;   }                 //<4>.Waiting for the Complete the processing iTDs   gwLastiTDSendOK=0;   psDevice_AP->bISOTransferEnable=1;   wISOOTGIn_Counter++;   bExitFlag=0;     do {      wDummyTemp++;      if (wDummyTemp>1000)          		  {         wDummyTemp=0;	         if (gwLastiTDSendOK==1)            bExitFlag=1;	      }       	   } while(bExitFlag==0);   //  while(((*pwLastTransaction)&0x80000000)>0);   psDevice_AP->bISOTransferEnable=0;            if (psDevice_AP->bSendStatusError==1) {      psDevice_AP->bSendStatusError=0;	      printf("???USB Error... Halt the system...\n ");	      while(1);   }   //Critical Time Period End ---------------------------------------------------           //<5>.Retire the siTD   wFrameNumber=wOriginalFrameNumber;      for (i=0;i<wsiTDNum;i++) {      if (wFrameNumber>1023)         wFrameNumber=wFrameNumber-1024;      psHost20_FramList->sCell[wFrameNumber].bTerminal=1;                   psHost20_FramList->sCell[wFrameNumber].bLinkPointer=0;                     psHost20_FramList->sCell[wFrameNumber].bType=HOST20_HD_Type_siTD;         wFrameNumber++;   }           //<6>.Free the iTD   for (i=0;i<wsiTDNum;i++) {      spTempsiTD=psDevice_AP->wISOiTDAddress[i];      flib_Host20_ReleaseStructure(Host20_MEM_TYPE_iTD,psDevice_AP->wISOiTDAddress[i]);   }}#endif//====================================================================// * Function Name: flib_Host20_Issue_ISO_

⌨️ 快捷键说明

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