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

📄 main.lst

📁 RC500IC卡读写程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
 195          *                                                                           *
 196          * Function:     delay_1ms                                                   *
 197          *                                                                           *
 198          * Input:        _1ms                                                        *
 199          * Output:       -                                                           *
 200          *                                                                           *
 201          * Description:                                                              *
 202          *                                                                           *
 203          * Time delay with a resolution of 1 ms.                                     *
 204          *                                                                           *
 205          ****************************************************************************/
 206          
 207          void 	delay_1ms (uchar _1ms)
 208          {
 209   1      
 210   1        RCAP2LH = RCAP2_1ms;
 211   1        T2LH    = RCAP2_1ms;
 212   1        ET2 = 0; 	// Disable timer2 interrupt
 213   1        T2CON = 0x04;	// 16-bit auto-reload, clear TF2, start timer
 214   1      
 215   1        while (_1ms--)
 216   1        {
 217   2      	while (!TF2);
 218   2      	TF2 = FALSE;
 219   2        }
 220   1        TR2 = FALSE;
 221   1      
 222   1      }
 223          
 224          
 225          /****************************************************************************
 226          *                                                                           *
 227          * Function:     delay_10ms                                                  *
 228          *                                                                           *
 229          * Input:        _10ms                                                       *
 230          * Output:       -                                                           *
 231          *                                                                           *
 232          * Description:                                                              *
 233          *                                                                           *
 234          * Time delay with a resolution of 10 ms.                                    *
 235          *                                                                           *
 236          ****************************************************************************/
 237          
 238          void 	delay_10ms (uint _10ms)
 239          {
 240   1      
 241   1        RCAP2LH = RCAP2_10ms;
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 5   

 242   1        T2LH    = RCAP2_10ms;
 243   1        ET2 = 0; 	// Disable timer2 interrupt
 244   1        T2CON = 0x04;	// 16-bit auto-reload, clear TF2, start timer
 245   1      
 246   1        while (_10ms--)
 247   1        {
 248   2      	while (!TF2)
 249   2      	{
 250   3      	  if (CmdValid || CmdReceived)
 251   3      	  {
 252   4      		TR2 = FALSE;
 253   4      		TF2 = FALSE;
 254   4      		return;
 255   4      	  }
 256   3      	}
 257   2      	TF2 = FALSE;
 258   2        }
 259   1        TR2 = FALSE;
 260   1      
 261   1      }
 262          
 263          
 264          #ifdef NOP_DELAY
              
              /****************************************************************************
              *                                                                           *
              * Function:     delay_50us_NOP                                              *
              *                                                                           *
              * Input:        -                                                           *
              * Output:       -                                                           *
              *                                                                           *
              * Description:                                                              *
              *                                                                           *
              * Zeitverz攇erung von 50 鎠.                                                *
              *                                                                           *
              ****************************************************************************/
              
              void 	delay_50us_NOP (void)
              {
                uchar i;
              
                for(i=0; i<81; i++) _nop_();
              }
              
              #endif
 287          
 288          
 289          /****************************************************************************
 290          *                                                                           *
 291          * Function:     delay_8us_NOP                                               *
 292          *                                                                           *
 293          * Input:        -                                                           *
 294          * Output:       -                                                           *
 295          *                                                                           *
 296          * Description:                                                              *
 297          *                                                                           *
 298          *                                                                           *
 299          ****************************************************************************/
 300          
 301          void 	delay_8us_NOP (void)
 302          {
 303   1        uchar i;
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 6   

 304   1      
 305   1        for(i=0; i<14; i++) _nop_();
 306   1      }
 307          
 308          #pragma aregs
 309          
 310          
 311          /****************************************************************************
 312          *                                                                           *
 313          * Function:     xtoa_h                                                      *
 314          *                                                                           *
 315          * Input:        _byte                                                       *
 316          * Output:       ASCII High-Nibble                                           *
 317          *                                                                           *
 318          * Description:                                                              *
 319          *                                                                           *
 320          * Wandelt das High-Nibble des 乥ergebenen Bytes in ein ASCII-Zeichen um.    *
 321          *                                                                           *
 322          ****************************************************************************/
 323          
 324          uchar 	xtoa_h (uchar _byte)
 325          {
 326   1        uchar nibble = _byte >> 4;
 327   1      
 328   1        return ((nibble > 9)? nibble + 'A' - 10 : nibble + '0');
 329   1      }
 330          
 331          
 332          /****************************************************************************
 333          *                                                                           *
 334          * Function:     xtoa_l                                                      *
 335          *                                                                           *
 336          * Input:        _byte                                                       *
 337          * Output:       ASCII Low-Nibble                                            *
 338          *                                                                           *
 339          * Description:                                                              *
 340          *                                                                           *
 341          * Wandelt das Low-Nibble des 乥ergebenen Bytes in ein ASCII-Zeichen um.     *
 342          *                                                                           *
 343          ****************************************************************************/
 344          
 345          uchar 	xtoa_l (uchar _byte)
 346          {
 347   1        uchar nibble = _byte & 0x0F;
 348   1      
 349   1        return ((nibble > 9)? nibble + 'A' - 10 : nibble + '0');
 350   1      }
 351          
 352          
 353          /****************************************************************************
 354          *                                                                           *
 355          * Function:     isr_timer0                                                  *
 356          *                                                                           *
 357          * Input:        -                                                           *
 358          * Output:       -                                                           *
 359          *                                                                           *
 360          * Description:                                                              *
 361          *                                                                           *
 362          *                                                                           *
 363          ****************************************************************************/
 364          
 365          void 	isr_timer0 (void) interrupt 1 using 2
C51 COMPILER V6.12  MAIN                                                                   08/25/2007 20:27:22 PAGE 7   

 366          {
 367   1        if (Timer0Cnt)
 368   1        {
 369   2      	--Timer0Cnt;
 370   2        }
 371   1        else
 372   1        {
 373   2      	STOP_T0();
 374   2      
 375   2      #ifdef AUTODELAY
 376   2      	if (DelayRate < MAXDELAYRATE && CmdCnt > 0)
 377   2      	{
 378   3      	  DelayRate++;
 379   3      	  DelayRateLocked = FALSE;
 380   3      	}
 381   2      #endif
 382   2      
 383   2      	RecvState = RECV_STX;
 384   2      
 385   2      	if (!SendReady && LLfReady)
 386   2      	{
 387   3      	  if (RepCnt < MAXREPCNT)
 388   3      	  {
 389   4      		RepCnt++;
 390   4      		CALL_isr_UART();
 391   4      	  }
 392   3      	  else
 393   3      	  {
 394   4      		RepCnt = 0;
 395   4      		Quit = FALSE;
 396   4      		SendReady = TRUE;
 397   4      	  }

⌨️ 快捷键说明

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