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

📄 ps2.lst

📁 一个以前开发的实际应用的交通灯控制器程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
  56   3                                      KbSta=KBBUF_NOKEY;              
*** ERROR C202 IN LINE 56 OF IIC[ULTRAL]\PS2.C: 'KbSta': undefined identifier
  57   3                              }
  58   2              }
  59   1              
  60   1              return KEY_NOKEY;       
*** ERROR C202 IN LINE 60 OF IIC[ULTRAL]\PS2.C: 'KEY_NOKEY': undefined identifier
  61   1      }
  62          
  63          void KbWait4High()
  64          {
  65   1              while(!KB_CLK)
  66   1              if(DelayCnt==0)
*** ERROR C202 IN LINE 66 OF IIC[ULTRAL]\PS2.C: 'DelayCnt': undefined identifier
  67   1                      break;
  68   1      }
  69          
  70          void KbWait4Low()
  71          {
  72   1              while(KB_CLK)
  73   1              if(DelayCnt==0)
*** ERROR C202 IN LINE 73 OF IIC[ULTRAL]\PS2.C: 'DelayCnt': undefined identifier
  74   1                      break;
  75   1      }
  76          
  77          void PS2_SendChar(unsigned char dat)//ps2主设备向从设备发送数据
  78          {
  79   1              unsigned char SendCnt;
  80   1              unsigned char SendChk=0x00;
  81   1              EX0=0;
  82   1              EA=0;
  83   1              DelayCnt=2;//100ms
*** ERROR C202 IN LINE 83 OF IIC[ULTRAL]\PS2.C: 'DelayCnt': undefined identifier
  84   1              //发起一个传送,发起始位
  85   1              KB_CLK=0;//将时钟线拉低并保持100us
  86   1              for(SendCnt=0;SendCnt<150;SendCnt++);
  87   1              KB_DAT=0;//起始位
  88   1              KB_CLK=1;
  89   1              //发送Data0-7
  90   1              for(SendCnt=0;SendCnt<8;SendCnt++)
  91   1              {
  92   2                      KbWait4Low();//while(KB_CLK);//等待时钟线变为低
  93   2                      KB_DAT=dat & 0x01;//发送数据
  94   2                      if(KB_DAT)
C51 COMPILER V7.50   PS2                                                                   04/03/2007 10:38:51 PAGE 4   

  95   2                              SendChk++;//计算校验
  96   2                      KbWait4High();//while(!KB_CLK);//等待时钟线变高
  97   2                      dat>>=1;//待发送数据右移一位
  98   2              }
  99   1              //发送校验位
 100   1              KbWait4Low();//while(KB_CLK);//等待时钟线变为低
 101   1              switch(SendChk)
 102   1              {
 103   2              case 0:
 104   2              case 2:
 105   2              case 4:
 106   2              case 6:
 107   2                      KB_DAT=1;
 108   2                      break;//奇校验
 109   2              case 1:
 110   2              case 3:
 111   2              case 5:
 112   2              case 7:
 113   2                      KB_DAT=0;
 114   2                      break;//奇校验
 115   2              default:
 116   2                      break;
 117   2              }
 118   1              KbWait4High();//while(!KB_CLK);//等待时钟线变高
 119   1              KbWait4Low();//while(KB_CLK);//等待时钟线变为低
 120   1              KB_DAT=1; //发送停止位 停止位总为1
 121   1              KbWait4High();//while(!KB_CLK);//等待时钟线变高
 122   1              KbWait4Low();//while(KB_CLK);//等待时钟线变为低
 123   1              KbWait4High();//while(!KB_CLK);//等待时钟线变高
 124   1              KB_CLK=1;
 125   1              KB_DAT=1;
 126   1              EX0=1;
 127   1              EA=1;
 128   1      }
 129          
 130          void PS2_RecChar(void) interrupt INT_SOURCE_EX1//外部中断1
*** ERROR C141 IN LINE 130 OF IIC[ULTRAL]\PS2.C: syntax error near '2'
 131          {
 132                  
 133                  unsigned char IntNum = 0; //中断次数计数
 134              unsigned char KeyV=0; //键值
 135                  bit Kbparity;//奇校验
 136          
 137                  EX0=0;
*** ERROR C279 IN LINE 137 OF IIC[ULTRAL]\PS2.C: 'EX0': multiple initialization
*** ERROR C231 IN LINE 137 OF IIC[ULTRAL]\PS2.C: 'EX0': redefinition
 138              EA=0;
*** ERROR C279 IN LINE 138 OF IIC[ULTRAL]\PS2.C: 'EA': multiple initialization
*** ERROR C231 IN LINE 138 OF IIC[ULTRAL]\PS2.C: 'EA': redefinition
 139              DelayCnt=2;
 140              //while (KB_CLK);//等待时钟线变低
 141              KbWait4High();//while(!KB_CLK);//等待PS/2CLK拉高:起始位不要
*** ERROR C231 IN LINE 141 OF IIC[ULTRAL]\PS2.C: 'KbWait4High': redefinition
 142              for(IntNum=0;IntNum<8;IntNum++)
*** ERROR C141 IN LINE 142 OF IIC[ULTRAL]\PS2.C: syntax error near 'for'
*** ERROR C141 IN LINE 142 OF IIC[ULTRAL]\PS2.C: syntax error near '=', expected ')'
*** ERROR C129 IN LINE 142 OF IIC[ULTRAL]\PS2.C: missing ';' before '<'
 143              {
 144                          KbWait4Low();//while(KB_CLK);//等待PS/2CL拉低
 145                          KeyV=KeyV>>1; //因键盘数据是低>>高,结合上一句所以右移一位
 146                          if(KB_DAT)
 147                                  KeyV=KeyV | 0x80; //当键盘数据线为1时为1到最高位
C51 COMPILER V7.50   PS2                                                                   04/03/2007 10:38:51 PAGE 5   

 148                          KbWait4High();//while(!KB_CLK);  //等待PS/2CLK拉高
 149              }
 150              KbWait4Low();//while(KB_CLK); //等待PS/2CLK拉低
 151                  Kbparity=KB_DAT;//奇校验位
 152              KbWait4High();//while(!KB_CLK);//等待时钟线变高
 153              KbWait4Low();//while(KB_CLK);//等待PS/2CLK拉低:停止位不要
 154              KbWait4High();//while(!KB_CLK);//等待时钟线变高
 155                  
 156                  KbBuf[KbCnt]=KeyV;//存入缓存中
 157              KbCnt++;
 158                  if(KbCnt>=KBBUF_SIZE)
 159                          KbCnt=0;
 160              KbFlagSta=1;//标记新接收到一个编码
 161              EX0=1;
 162              EA=1;    
 163          }
 164          
 165          void PS2_Init()
 166          {
 167                  unsigned char xdata i;
 168                  KB_CLK=1;
 169                  KB_DAT=1;
 170                  EX1=1;//
 171                  //EA=1;//kf
 172          //使用键盘上电时的默认设置
 173                  //PS2_SendChar(KB_RESET);//复位
 174                  //PS2_SendChar(KB_ALLKEY_MASK);//只用通码,禁止机打、断码
 175                  //PS2_SendChar(KB_SETLED);//设置键盘Led
 176                  //PS2_SendChar(KB_CAPSLOCK+KB_NUMLOCK+KB_SCROLLLOCK);
 177          
 178                  for(i=0;i<KBBUF_SIZE;i++)
 179                          KbBuf[i]=0;
 180                  KbSta=KBBUF_NOKEY;
 181          }

C51 COMPILATION COMPLETE.  0 WARNING(S),  93 ERROR(S)

⌨️ 快捷键说明

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