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

📄 menu_data.lst

📁 < C语言嵌入式系统开发>>一书配套源代码,C51代码,对于51学习有很好参考意义.
💻 LST
字号:
C51 COMPILER V6.21  MENU_DATA                                                              01/23/2002 18:05:24 PAGE 1   


C51 COMPILER V6.21, COMPILATION OF MODULE MENU_DATA
OBJECT MODULE PLACED IN Menu_Data.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Menu_Data.c OPTIMIZE(6,SIZE) BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*------------------------------------------------------------------*-
   2          
   3             Menu_Data.C (v1.00)
   4          
   5            ------------------------------------------------------------------
   6          
   7             Simple framework for menu-driven data acquisition.
   8          
   9             Use 'Hyperterminal' (under Windows 95, 98, 2000) or similar 
  10             terminal emulator program on other operating systems.
  11          
  12             Terminal options: 
  13          
  14             - Data bits    = 8
  15             - Parity       = None
  16             - Stop bits    = 1
  17             - Flow control = Xon / Xoff
  18          
  19             COPYRIGHT
  20             ---------
  21          
  22             This code is associated with the book:
  23          
  24             EMBEDDED C by Michael J. Pont 
  25             [Pearson Education, 2002: ISBN: 0-201-79523-X].
  26          
  27             This code is copyright (c) 2001 by Michael J. Pont.
  28           
  29             See book for copyright details and other information.
  30          
  31          -*------------------------------------------------------------------*/
  32          
  33          #include "Main.H"
  34          #include "Port.H"
  35          
  36          #include "Menu_Data.h"
  37          #include "PC_IO.h"
  38          
  39          // ------ Public variable declarations -----------------------------
  40          // See Char_Map.c
  41          extern const char code CHAR_MAP_G[10]; 
  42          
  43          // ------ Private variables ----------------------------------------
  44          static bit First_time_only_G;
  45          
  46          /*------------------------------------------------------------------*-
  47          
  48            MENU_Command_Processor()
  49          
  50            This function is the main menu 'command processor' function.  
  51          
  52            Call this (say) once every 10 ms (approx.).
  53          
  54          -*------------------------------------------------------------------*/
  55          void MENU_Command_Processor(void)
C51 COMPILER V6.21  MENU_DATA                                                              01/23/2002 18:05:24 PAGE 2   

  56             {
  57   1         char Ch;
  58   1      
  59   1         if (First_time_only_G == 0)
  60   1            {
  61   2            First_time_only_G = 1;
  62   2            MENU_Show_Menu();
  63   2            }
  64   1      
  65   1         // Check for user inputs
  66   1         PC_LINK_IO_Update();
  67   1      
  68   1         Ch = PC_LINK_IO_Get_Char_From_Buffer();
  69   1            
  70   1         if (Ch != PC_LINK_IO_NO_CHAR)
  71   1            {
  72   2            MENU_Perform_Task(Ch);
  73   2            MENU_Show_Menu();
  74   2            }
  75   1         }
  76          
  77          
  78          /*------------------------------------------------------------------*-
  79          
  80            MENU_Show_Menu()
  81          
  82            Display menu options on PC screen (via serial link)
  83            - edit as required to meet the needs of your application.
  84          
  85          -*------------------------------------------------------------------*/
  86          void MENU_Show_Menu(void)
  87             {
  88   1         PC_LINK_IO_Write_String_To_Buffer("Menu:\n"); 
  89   1         PC_LINK_IO_Write_String_To_Buffer("a - Read P1\n");
  90   1         PC_LINK_IO_Write_String_To_Buffer("b - Read P2\n\n");
  91   1         PC_LINK_IO_Write_String_To_Buffer("? : ");
  92   1         }
  93          
  94          
  95          /*------------------------------------------------------------------*-
  96          
  97            MENU_Perform_Task()
  98          
  99            Perform the required user task
 100            - edit as required to match the needs of your application.
 101          
 102          -*------------------------------------------------------------------*/
 103          void MENU_Perform_Task(char c)
 104             {
 105   1         // Echo the menu option
 106   1         PC_LINK_IO_Write_Char_To_Buffer(c);
 107   1         PC_LINK_IO_Write_Char_To_Buffer('\n');
 108   1      
 109   1         // Perform the task
 110   1         switch (c)
 111   1            {
 112   2            case 'a':
 113   2            case 'A':
 114   2               {
 115   3               Get_Data_From_Port1();
 116   3               break;
 117   3               }
C51 COMPILER V6.21  MENU_DATA                                                              01/23/2002 18:05:24 PAGE 3   

 118   2            
 119   2            case 'b':
 120   2            case 'B':
 121   2               {
 122   3               Get_Data_From_Port2();
 123   3               break;
 124   3               }
 125   2            } 
 126   1         }
 127          
 128          /*------------------------------------------------------------------*-
 129          
 130            Get_Data_From_Port1()
 131          
 132          -*------------------------------------------------------------------*/
 133          void Get_Data_From_Port1(void)
 134             {
 135   1         tByte Port1 = Data_Port1;
 136   1         char String[11] = "\nP1 = XXX\n\n";
 137   1      
 138   1         String[6] = CHAR_MAP_G[Port1 / 100];
 139   1         String[7] = CHAR_MAP_G[(Port1 / 10) % 10];
 140   1         String[8] = CHAR_MAP_G[Port1 % 10];
 141   1      
 142   1         PC_LINK_IO_Write_String_To_Buffer(String);
 143   1         }
 144          
 145          /*------------------------------------------------------------------*-
 146          
 147            Get_Data_From_Port2()
 148          
 149          -*------------------------------------------------------------------*/
 150          void Get_Data_From_Port2(void)
 151             {
 152   1         tByte Port2 = Data_Port2;
 153   1         char String[11] = "\nP2 = XXX\n\n";
 154   1      
 155   1         String[6] = CHAR_MAP_G[Port2 / 100];
 156   1         String[7] = CHAR_MAP_G[(Port2 / 10) % 10];
 157   1         String[8] = CHAR_MAP_G[Port2 % 10];
 158   1      
 159   1         PC_LINK_IO_Write_String_To_Buffer(String);
 160   1         }
 161          
 162          /*------------------------------------------------------------------*-
 163            ---- END OF FILE -------------------------------------------------
 164          -*------------------------------------------------------------------*/
 165          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    238    ----
   CONSTANT SIZE    =     61    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      25
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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