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

📄 vdipnew.lst

📁 interfacing of vdip module with 89c52
💻 LST
📖 第 1 页 / 共 3 页
字号:
 398          
 399          
 400          
 401          
 402          
 403          //*****************************************************************************************
 404          //  
 405          //  Write to file command (OPW) using long command set
 406          //  
 407          //*****************************************************************************************
 408          void VNC1L_WriteToFile(char *buffer, int number_character)
 409          {
 410   1              int j, stringlength = number_character;
 411   1              char FIFOByte = 0x00;
 412   1      
 413   1              serial_sendbyte('W');                                                                   // Send 'W'
 414   1              serial_sendbyte('R');                                                                   // Send 'R'
 415   1              serial_sendbyte('F');                                                                   // Send 'F'
 416   1              serial_sendbyte(' ');                                                                   // Send ' '
 417   1              serial_sendbyte(0x00);                                                                  // Send 0x00 - Number of bytes to write MSB
 418   1              serial_sendbyte(0x00);                                                                  // Send 0x00
 419   1              serial_sendbyte(0x00);                                                                  // Send 0x00
 420   1              serial_sendbyte(0x52);                                                                  // Send 0x0E - Number of  bytes to write LSB
 421   1              serial_sendbyte(0x0D);                                                                  // Send carriage return
C51 COMPILER V7.20   VDIPNEW                                                               02/23/2009 14:04:45 PAGE 8   

 422   1      if (stringlength>=80)
 423   1      {
 424   2      for (j=0;j<=80;j++)
 425   2      {
 426   3      serial_sendbyte(*buffer++);
 427   3      }
 428   2      }
 429   1      if (stringlength<80)
 430   1      {
 431   2      for (j=0;j<=stringlength;j++)
 432   2      {
 433   3      serial_sendbyte(*buffer++);
 434   3      }
 435   2      for (j=stringlength+1;j<=80;j++)
 436   2      {
 437   3      serial_sendbyte(*buffer++);
 438   3      }
 439   2      }
 440   1              serial_sendbyte(0x0D);                                                                  // Send carriage return
 441   1              serial_sendbyte(0x0A);                                                                  // Send line feed
 442   1              serial_sendbyte(0x0D);                                                                  // Send carriage return
 443   1      
 444   1              while (RX_FIFO_COUNT < 0x05)                                                    // Wait until at least 5 bytes in the Rx FIFO
 445   1              {
 446   2                      delay_ms(10);                                                                           // Wait for 5 byte response("D:\>" + 0x0D)
 447   2              }
 448   1      
 449   1              while (RX_FIFO_COUNT > 0x00)
 450   1              {
 451   2                      serial_readfromrxfifo(&FIFOByte);                                       // Read response bytes form FIFO
 452   2              }
 453   1      
 454   1      }
 455          
 456          
 457          
 458          
 459          
 460          //*****************************************************************************************
 461          //  
 462          //  Close file command (CLF) using long command set
 463          //  
 464          //*****************************************************************************************
 465          void VNC1L_CloseFile()
 466          {
 467   1              char FIFOByte = 0x00;
 468   1      
 469   1              serial_sendbyte('C');                                                                   // Send 'C'
 470   1              serial_sendbyte('L');                                                                   // Send 'L'
 471   1              serial_sendbyte('F');                                                                   // Send 'F'
 472   1              serial_sendbyte(' ');                                                                   // Send ' '
 473   1              serial_sendbyte('h');                                                                   // Send 'h'
 474   1              serial_sendbyte('e');                                                                   // Send 'e'
 475   1              serial_sendbyte('l');                                                                   // Send 'l'
 476   1              serial_sendbyte('l');                                                                   // Send 'l'
 477   1              serial_sendbyte('o');                                                                   // Send 'o'
 478   1              serial_sendbyte('.');                                                                   // Send '.'
 479   1              serial_sendbyte('t');                                                                   // Send 't'
 480   1              serial_sendbyte('x');                                                                   // Send 'x'
 481   1              serial_sendbyte('t');                                                                   // Send 't'
 482   1              serial_sendbyte(0x0D);                                                                  // Send carriage return
 483   1      
C51 COMPILER V7.20   VDIPNEW                                                               02/23/2009 14:04:45 PAGE 9   

 484   1              while (RX_FIFO_COUNT < 0x05)                                                    // Wait until at least 5 bytes in the Rx FIFO
 485   1              {
 486   2                      delay_ms(10);                                                                           // Wait for 5 byte response("D:\>" + 0x0D)
 487   2              }
 488   1      
 489   1              while (RX_FIFO_COUNT > 0x00)
 490   1              {
 491   2                      serial_readfromrxfifo(&FIFOByte);                                       // Read response bytes form FIFO
 492   2              }
 493   1      }
 494          //*****************************************************************************************
 495          //*****************************************************************************************
 496          //*****************************************************************************************
 497          //  
 498          //  Interrupt routines go here
 499          //  Use receive character interrupt to add received characters to the RX FIFO
 500          //  
 501          //*****************************************************************************************
 502          //*****************************************************************************************
 503          //*****************************************************************************************
 504          
 505          void serial_IT(void) interrupt 4 
 506          {
 507   1      
 508   1              if (RI == 1) /* if reception occur */
 509   1              {
 510   2              RI = 0;      /* clear reception flag for next reception */
 511   2          serial_addtorxfifo();                             
 512   2              }
 513   1                      
 514   1      }
 515          
 516          //*****************************************************************************************
 517          //*****************************************************************************************
 518          //*****************************************************************************************
 519          //  
 520          //  Main line code
 521          //  
 522          //*****************************************************************************************
 523          //*****************************************************************************************
 524          //*****************************************************************************************
 525          void main()
 526          {       
 527   1              char Sync = 0x00;
 528   1              P2=0x00;
 529   1              VNC1L_State = VNC1L_Idle;                                                               // Initialise state to idle
 530   1              serial_init(9600, FLOW_RTS_CTS);                                                // Initialise Baud rate and flow control
 531   1              delay_s(1);     // Allow some time for power up
 532   1              if (VNC1L_Sync() == Synchronised)                                               // Synchronise to Vinculum
 533   1              {
 534   2                      while (1)                                                                                       // Main state machine - do not return from here
 535   2                      {
 536   3                              switch (VNC1L_State)
 537   3                              {
 538   4                                      case VNC1L_Idle:
 539   4                                              Sync = VNC1L_Sync();
 540   4                                              P2=0X00;
 541   4                                              P2_0=1;
 542   4                                              if (VNC1L_FindDisk() == GotDisk)                // Check for disk
 543   4                                              {
 544   5                                                      VNC1L_State = VNC1L_DiskAvailable;      // Update state to indicate disk found
 545   5                                              }
C51 COMPILER V7.20   VDIPNEW                                                               02/23/2009 14:04:45 PAGE 10  

 546   4      
 547   4                                              break;
 548   4              
 549   4                                      case VNC1L_DiskAvailable:
 550   4                                              P2_1=1;
 551   4                                              VNC1L_OpenFile();                                               // Send open file for write command     (OPW) - file name "hello.txt"
 552   4                                              VNC1L_State = VNC1L_WriteFile;                  // Update state to indicate file has been created and can be written
 553   4                                              break;
 554   4      
 555   4                                      case VNC1L_WriteFile:
 556   4                                              P2_2=1;
 557   4                                              VNC1L_WriteToFile(reset_screen,40);                                     // Send write file command (WRF) - write "Hello World!"
 558   4                                              VNC1L_State = VNC1L_EndFile;                    // Update state to indicate file has been written and can now be close
             -d
 559   4                                              break;
 560   4      
 561   4                                      case VNC1L_EndFile:
 562   4                                              P2_3=1;
 563   4                                         VNC1L_CloseFile();                                           // Send close file command (CLF)
 564   4                                              VNC1L_State = VNC1L_WaitForRemove;              // Update state to indicate witing for disk to be removed
 565   4                                              break;
 566   4      
 567   4                                      case VNC1L_WaitForRemove:
 568   4                                              P2_4=1;
 569   4                                              Sync = VNC1L_Sync();
 570   4                                              if (VNC1L_FindDisk() != GotDisk)                // Check for disk
 571   4                                              {
 572   5                                                      VNC1L_State = VNC1L_Idle;                       // Update state to indicate disk has been removed and return to idle
 573   5                                              }
 574   4                                              P2=0XFF;
 575   4                                              break;
 576   4                                      
 577   4                                      default:
 578   4                                              P2_5=1;
 579   4                                              VNC1L_State = VNC1L_Idle;                               // Default to idle state
 580   4                              }
 581   3      
 582   3                      }
 583   2      
 584   2              }
 585   1      
 586   1      }
 587          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1317    ----
   CONSTANT SIZE    =     41    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     61      27
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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