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

📄 kbmousetest.c

📁 usbhostomapOMAP5910下键盘和鼠标的驱动程序
💻 C
字号:


unsigned char * cmd_s_port =  (unsigned char*)0x08000064;
unsigned char * dat_port = (unsigned char*)0x08000060;



//------------------------------------------------------------------------------------
void KBmouseTest(void)
{

 int i=0,j=0,keyvalu=0;
 short x,y,*px,*py,y1,y2,y3,y4;
 unsigned short st=0,getpen;
 unsigned char xxx=0,state=0;
 unsigned char *yyy;
 unsigned short *zzz,rowdat,*adrow,*adc,row,colum;
 
 

//*******************************************************************************
 /*  
   zxcv: 
      zzz=(unsigned short*)0x08000008;
     *(zzz)=0xdddd;
     yyy=(unsigned char*)0x0800000a;
     *(yyy)=0xdd;
     yyy=(unsigned char*)0x0800000b;
     *(yyy)=0xdd;
  
  goto zxcv;
  
  */
//keyboard mouse test program
 
     yyy=(unsigned char*)0x08000004;
     *(yyy)&=0x7f;
     for( i=0;i<100;i++)
     *(yyy)|=0x80;
        
  //write intr mask reg
  for( i=0;i<100;i++)       
  yyy=(unsigned char*)0x08000009;
     *(yyy)=0x10;
  for( i=0;i<100;i++) 
  
       zzz=(unsigned short*)0x08000008;
     *(zzz)=0xffff;
        st=*(zzz);
    st=0;
      
  //test self_test
 
for( i=0;i<100;i++)
 
 //  test23:
 //   state=*cmd_s_port;
  //  state &=0x02;  
  //  if (state==0x02)
 //      goto test23;
 //   else
     *cmd_s_port=0xAA;
     
     xxx=*dat_port;
     
     state=*cmd_s_port;
     
   
     test24:
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test24;
       else 
          xxx=0; 
          xxx=*dat_port;    //xxx=0x55 correct  
          
 
        //test kb interface
    
    test15:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test15;
    else
      *cmd_s_port=0xAB; 
     test16:    
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test16;
       else 
          xxx=0; 
          xxx=*dat_port;    //xxx=0x00 correct           
                
                           
        
  //write keyboard command byte
 
   test25: 
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test25;
    else
     *cmd_s_port=0x60;
   
 
     test26:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test26;
    else
     *dat_port=0x47;
     
    state= *cmd_s_port;
   
 
  //read keyboard command byte
 
    test27:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test27;
    else
     *cmd_s_port=0x20;    
     test28:
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test28;
       else 
          xxx=0; 
          xxx=*dat_port;    //xxx=0x47 correct  
     
     state=*cmd_s_port; 
         
       
 
      //enable kb   
      
    test0:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test0;
    else
      *cmd_s_port=0xAE;  
 

    //reset  kb 
    test40:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test40;
    else
       *dat_port=0xFF;
     test41:
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test41;
       else 
          xxx=0; 
          xxx=*dat_port;    //xxx=0xfa correct
     test42:  
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test42;
       else  
          xxx=0;
          xxx=*dat_port;    //xxx=0xaa correct
          
          
    //start kb 
              
    test43:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test43;
    else
      *dat_port=0xF4;
 
    test44:
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test44;
       else 
          xxx=0; 
          xxx=*dat_port;   //xxx=0xfa correct 
 
    //test kb led
    test45:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test45;
    else
      *dat_port=0xED;  
    test46:
    state=*cmd_s_port;
    state &=0x01;  
       if (state!=0x01)
          goto test46;
       else 
          xxx=0; 
          xxx=*dat_port;   //xxx=0xfa correct
   test47: 
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test47;
    else
      *dat_port=0x07;
   test48:  
    state=*cmd_s_port;
    state &=0x01;  
       if (state!=0x01)
          goto test48;
       else 
          xxx=0; 
          xxx=*dat_port;   //xxx=0xfa correct
           
         //test mouse interface
   test13: 
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test13;
    else
      *cmd_s_port=0xA9; 
 
      test14:    
     state=*cmd_s_port;
     state &=0x01;  
       if (state!=0x01)
          goto test14;
       else 
          xxx=0; 
          xxx=*dat_port;    //xxx=0x00 correct  
      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        //enable mouse
    //enable mouse
 test10:   
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test10;
    else
      *cmd_s_port=0xA8;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                             
    //reset  mouse
   test35: 
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test35;
    else
       *cmd_s_port=0xD4;
     
    test1:
 
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test1;
    else
       *dat_port=0xFF; 
     test2:
 
     state=*cmd_s_port;
     state &=0x20;  
       if (state!=0x20)
          goto test2;
       else 
          xxx=0; 
          xxx=*dat_port;    //xxx=0xfa correct  
      test3:
 
     state=*cmd_s_port;
     state &=0x20;  
       if (state!=0x20)
          goto test3;
       else  
          xxx=0;
          xxx=*dat_port;    //xxx=0xaa correct
           
          
    //start mouse      
    test36:
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test36;
    else
       *cmd_s_port=0xD4;               
    test4:
 
    state=*cmd_s_port;
    state &=0x02;  
    if (state==0x02)
       goto test4;
    else
      *dat_port=0xF4;
 for( i=0;i<100;i++)      
    test5:
    
   
     state=*cmd_s_port;
     state &=0x20;  
       if (state!=0x20)
          goto test5;
       else 
          xxx=0; 
          xxx=*dat_port;   //xxx=0x00 correct  ???????????? 
              
 printf("keyboard mouse initiate complete\n");      
 printf("Pls press any key on keyboard some times or move mouse & press button\n");       
 
     yyy=(unsigned char*)0x08000000;
     *(yyy)=0x00;  
     
   //test cpu receive data from kb
     
     yyy=(unsigned char*)0x08000000;
     *(yyy)=0x00; 
      
     zzz=(unsigned short*)0x08000006;
  st=*(zzz);
  
  st=*(zzz);
  
  i = 0;
  
  
    test:
    
      st=*(zzz);
  
      st=*(zzz);
    
      if(i> 30)    
         goto  exit_test;

      state=*cmd_s_port;
      if (state==0x15)
        {
             xxx=*dat_port; 
             i++;
       printf("kb data is :%x\n", xxx);
         }
      else if (state==0x35)
       {
        xxx=*dat_port; 
        i++;
       printf("mouse data is :%x\n", xxx);
       }
      else 
         goto test; 
          
       yyy=(unsigned char*)0x08000000;
       *(yyy)=0x00;
     
       state=*cmd_s_port;
     
       goto test;
    
  exit_test:

  return ;
}


⌨️ 快捷键说明

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