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

📄 host20_ap_hid.c

📁 FIC8120方案的 StartCell_Driver
💻 C
📖 第 1 页 / 共 2 页
字号:
                  printf("===> Input 'Home'\n");    
                  bFound=1;
             break;	
              case 0x4B:
                  printf("===> Input 'PgUp'\n");    
                  bFound=1;
             break;	
              case 0x4E:
                  printf("===> Input 'PgDn'\n");    
                  bFound=1;
             break;	
              case 0x4D:
                  printf("===> Input 'End'\n");    
                  bFound=1;
             break;	

              case 0x52:
                  printf("===> Input 'Up'\n");    
                  bFound=1;
             break;	
              case 0x51:
                  printf("===> Input 'Down'\n");    
                  bFound=1;
             break;	
              case 0x50:
                  printf("===> Input 'Left'\n");    
                  bFound=1;
             break;	
              case 0x4F:
                  printf("===> Input 'Right'\n");    
                  bFound=1;
             break;	
              case 0x2A:
                  printf("===> Input 'BackSpace'\n");    
                  bFound=1;
             break;	              
              case 0x28:
                  printf("===> Input 'Enter'\n");    
                  bFound=1;
             break;	              
              case 0x39:
                  printf("===> Input 'Caps Lock'\n");    
                  bFound=1;
             break;	              
              case 0x2B:
                  printf("===> Input 'Tab'\n");    
                  bFound=1;
             break;	              
             
              case 0x2C:
                  printf("===> Input 'Space'\n");    
                  bFound=1;
             break;	              
              case 0x2D:
                  printf("===> Input '-'\n");    
                  bFound=1;
             break;	              
              case 0x2E:
                  printf("===> Input '+'\n");    
                  bFound=1;
             break;	              
              case 0x31:
                  printf("===> Input '\\'\n");    
                  bFound=1;
             break;	              
              case 0x2F:
                  printf("===> Input '['\n");    
                  bFound=1;
             break;	              
              case 0x30:
                  printf("===> Input ']'\n");    
                  bFound=1;
             break;	              
              case 0x33:
                  printf("===> Input ';'\n");    
                  bFound=1;
             break;	              
              case 0x34:
                  printf("===> Input '''\n");    
                  bFound=1;
             break;	              
              case 0x36:
                  printf("===> Input ','\n");    
                  bFound=1;
             break;	              
              case 0x37:
                  printf("===> Input '.'\n");    
                  bFound=1;
             break;	              
              case 0x38:
                  printf("===> Input '/'\n");    
                  bFound=1;
             break;	              
              case 0x29:
                  printf("===> Input 'ESC'\n");    
                  bFound=1;
             break;	              
              case 0x35:
                  printf("===> Input '`'\n");    
                  bFound=1;
             break;	              
              case 0x4C:
                  printf("===> Input 'Del'\n");    
                  bFound=1;
             break;	              
              case 0x49:
                  printf("===> Input 'Ins'\n");    
                  bFound=1;
             break;	              
              case 0x48:
                  printf("===> Input 'Pause'\n");    
                  bFound=1;
             break;	              
              case 0x46:
                  printf("===> Input 'PtrSc'\n");    
                  bFound=1;
             break;	              
              case 0x53:
                  printf("===> Input 'Num'\n");    
                  bFound=1;
             break;	              
 


             }
        
 if (bFound==0)        
 {
 	
 	
    if 	((*pbBuffer4K_1>0)|(*(pbBuffer4K_1+1)>0)|(*(pbBuffer4K_1+2)>0)|(*(pbBuffer4K_1+3)>0)
            	|(*(pbBuffer4K_1+4)>0)|(*(pbBuffer4K_1+5)>0)|(*(pbBuffer4K_1+6)>0)|(*(pbBuffer4K_1+7)>0))
        { printf(">>> Keyboard Data:0x%x  0x%x  0x%x  0x%x / 0x%x  0x%x  0x%x  0x%x \n"
                       ,*pbBuffer4K_1,*(pbBuffer4K_1+1),*(pbBuffer4K_1+2),*(pbBuffer4K_1+3)
                   ,*(pbBuffer4K_1+4),*(pbBuffer4K_1+5),*(pbBuffer4K_1+6),*(pbBuffer4K_1+7));
        }	

 	
    }

return 0;        
	
}

//====================================================================
// * Function Name: OTGH_HID_Keyboard                          
// * Description: 
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_HID_Keyboard(void)
{
UINT8  *pbBuffer4K_1;

// UINT8 bCMD[8];
//UINT8 bTemp[0xFF];
Host20_BufferPointerArray_Structure aTemp;
  //<1>.Set Interface-0 Idle to 0 => 0x21,0x0A,0x00,0x00, 0x00,0x00,0x00,0x00

  //<2>.Set Interface-1 Idle to 0 => 0x21,0x0A,0x00,0x00, 0x01,0x00,0x00,0x00

  //<3>.SetReport to => 0x21,0x09,0x00,0x02, 0x00,0x00,0x01,0x00

         pbBuffer4K_1=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);   
	     aTemp.BufferPointerArray[0]=pbBuffer4K_1;
	     aTemp.BufferPointerArray[1]=0;	
	     aTemp.BufferPointerArray[2]=0;	
	     aTemp.BufferPointerArray[3]=0;
	     aTemp.BufferPointerArray[4]=0;	        
 flib_Host20_Interrupt_Init(psDevice_AP->saCD[0].sInterface[0].sED[0].bED_Interval,0,1);
  while(psDevice_AP->bConnectStatus>0)
       {
        flib_Host20_Issue_Interrupt(0,8,&(aTemp.BufferPointerArray[0]),0,OTGH_Dir_IN);
        OTGH_HID_Parsing_Keyboard(pbBuffer4K_1);

        }

  //<7>.free memory
        flib_Host20_ReleaseStructure(Host20_MEM_TYPE_4K_BUFFER,pbBuffer4K_1);
  //<8>.Disable Periodic     
        flib_Host20_Periodic_Setting(HOST20_Disable);






}


//====================================================================
// * Function Name: OTGH_HID_Mouse                          
// * Description: 
//   <1>.Init Interrupt EndPoint 
//   <2>.Start to issue Interrupr-In 4 bytes 
//   <3>.Analysis the "Interrupr-In 4 bytes"
//   <4>.Goto step1
// * Input: none
// * OutPut: none
//====================================================================
void OTGH_HID_Mouse(UINT8 bControlListNum)
{
UINT8  *pbBuffer4K_1;
 UINT8 bCMD[8];
//UINT8 bTemp[0xFF];
Host20_BufferPointerArray_Structure aTemp;

  // <1>.Set Idle to 0 => 0x21,0x0A,0x00,0x00, 0x00,0x00,0x00,0x00
         pbBuffer4K_1=flib_Host20_GetStructure(Host20_MEM_TYPE_4K_BUFFER);   
	     aTemp.BufferPointerArray[0]=pbBuffer4K_1;
	     aTemp.BufferPointerArray[1]=0;	
	     aTemp.BufferPointerArray[2]=0;	
	     aTemp.BufferPointerArray[3]=0;
	     aTemp.BufferPointerArray[4]=0;	        
         flib_Host20_Control_Command_Request(&bCMD,0x21,HOST20_HID_SetIdle,0,0,0);
         flib_Host20_Issue_Control_Turbo(bControlListNum,&bCMD,0x01,&(aTemp.BufferPointerArray[0]),0);//bEdNum,*pbCmd,hwDataSize,*pbData)
         printf(">>> Set Idle to 0 finish...\n");
  
  // <2>.GetDescriptor HID Report Descriptor => 0x81,0x06,0x00,0x22,0x00,0x00,0xFF,0x00
         flib_Host20_Control_Command_Request(&bCMD,0x81,HOST20_CONTROL_GetDescriptor,0x2200,0,0xFF);
         flib_Host20_Issue_Control_Turbo(bControlListNum,&bCMD,0xFF,&(aTemp.BufferPointerArray[0]),0);//bEdNum,*pbCmd,hwDataSize,*pbData)
         printf(">>> GetDescriptor HID Report Descriptor finish...\n");


  //<3>.Allocate memory
        
  //<4>.Init Interrupt EndPoint 
        flib_Host20_Interrupt_Init(psDevice_AP->saCD[0].sInterface[0].sED[0].bED_Interval,0,1);
  while(mwHost20_PORTSC_ConnectStatus_Rd()>0)
       {

  //<5>.Start to issue Interrupr-In 4 bytes 
  
        flib_Host20_Issue_Interrupt(0,4,&(aTemp.BufferPointerArray[0]),0,OTGH_Dir_IN);

  //<6>.Analysis the "Interrupr-In 4 bytes"
        //<Byte-1>.Button-1 down => 0x04
        //<Byte-2>.X(Left=>0xFF Right=>0x01)
        //<Byte-3>.Y(UP=>0xFF   Down=>0x01)
        //<Byte-4>.Wheel(Up=>0xFF Down=>0x01)

        OTGH_HID_Parsing_Mouse(pbBuffer4K_1);




                      
       }  while(mwHost20_PORTSC_ConnectStatus_Rd()>0)                  
                        
  //<7>.free memory
        flib_Host20_ReleaseStructure(Host20_MEM_TYPE_4K_BUFFER,pbBuffer4K_1);
        
  //<8>.Disable Periodic     
        flib_Host20_Periodic_Setting(HOST20_Disable);
}

⌨️ 快捷键说明

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