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

📄 menu_robot.lst

📁 Embedded C 这本书的范例光碟程式
💻 LST
字号:
C51 COMPILER V6.21  MENU_ROBOT                                                             01/23/2002 18:09:31 PAGE 1   


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

stmt level    source

   1          /*------------------------------------------------------------------*-
   2          
   3             Menu_Robot.C (v1.00)
   4          
   5            ------------------------------------------------------------------
   6          
   7             Simple framework for controlling a robot over a serial link.
   8          
   9             On PC 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_Robot.h"
  37          #include "PC_IO.h"
  38          
  39          // ------ Public variable declarations -----------------------------
  40          // See Stepper.c
  41          extern bit Motor_L;
  42          extern bit Motor_R;
  43          
  44          // ------ Private variables ----------------------------------------
  45          static bit First_time_only_G;
  46          
  47          
  48          /*------------------------------------------------------------------*-
  49          
  50            MENU_Command_Processor()
  51          
  52            This function is the main menu 'command processor' function.  
  53          
  54            Call this (say) once every 10 ms (approx.).
  55          
C51 COMPILER V6.21  MENU_ROBOT                                                             01/23/2002 18:09:31 PAGE 2   

  56          -*------------------------------------------------------------------*/
  57          void MENU_Command_Processor(void)
  58             {
  59   1         char Ch;
  60   1      
  61   1         if (First_time_only_G == 0)
  62   1            {
  63   2            First_time_only_G = 1;
  64   2            MENU_Show_Menu();
  65   2            }
  66   1      
  67   1         // Check for user inputs
  68   1         PC_LINK_IO_Update();
  69   1      
  70   1         Ch = PC_LINK_IO_Get_Char_From_Buffer();
  71   1            
  72   1         if (Ch != PC_LINK_IO_NO_CHAR)
  73   1            {
  74   2            MENU_Perform_Task(Ch);
  75   2            MENU_Show_Menu();
  76   2            }
  77   1         }
  78          
  79          
  80          /*------------------------------------------------------------------*-
  81          
  82            FUNCTION: MENU_Show_Menu()
  83          
  84            Display menu options on PC screen (via serial link)
  85            - edit as required to meet the needs of your application.
  86          
  87            HARDWARE: -
  88          
  89            GLOBALS:  -
  90          
  91            PARAMS:   void 
  92          
  93            RETURNS:  void
  94          
  95          -*------------------------------------------------------------------*/
  96          void MENU_Show_Menu(void)
  97             {
  98   1         PC_LINK_IO_Write_String_To_Buffer("a - Ahead\n");
  99   1         PC_LINK_IO_Write_String_To_Buffer("l - Left\n");
 100   1         PC_LINK_IO_Write_String_To_Buffer("r - Right\n");
 101   1         PC_LINK_IO_Write_String_To_Buffer("s - STOP\n\n");
 102   1         PC_LINK_IO_Write_String_To_Buffer("? : ");
 103   1         }
 104          
 105          
 106          /*------------------------------------------------------------------*-
 107          
 108            FUNCTION: MENU_Perform_Task()
 109          
 110            Perform the required user task
 111            - edit as required to match the needs of your application.
 112          
 113            HARDWARE: Uses the on-chip UART hardware.
 114          
 115            GLOBALS:  -
 116          
 117            PARAMS:   void 
C51 COMPILER V6.21  MENU_ROBOT                                                             01/23/2002 18:09:31 PAGE 3   

 118          
 119            RETURNS:  void
 120          
 121          -*------------------------------------------------------------------*/
 122          void MENU_Perform_Task(char c)
 123             {
 124   1         // Echo the menu option
 125   1         PC_LINK_IO_Write_Char_To_Buffer(c);
 126   1         PC_LINK_IO_Write_Char_To_Buffer('\n');
 127   1      
 128   1         // Perform the task
 129   1         switch (c)
 130   1            {
 131   2            case 'a':
 132   2            case 'A':
 133   2               {
 134   3               PC_LINK_IO_Write_String_To_Buffer("<*> AHEAD\n\n");
 135   3               Motor_L = 1;
 136   3               Motor_R = 1;
 137   3               break;
 138   3               }
 139   2            
 140   2            case 'l':
 141   2            case 'L':
 142   2               {
 143   3               PC_LINK_IO_Write_String_To_Buffer("<** LEFT\n\n");
 144   3               Motor_L = 0;
 145   3               Motor_R = 1;
 146   3               break;
 147   3               }
 148   2      
 149   2            case 'r':
 150   2            case 'R':
 151   2               {
 152   3               PC_LINK_IO_Write_String_To_Buffer("**> RIGHT\n\n");
 153   3               Motor_L = 1;
 154   3               Motor_R = 0;
 155   3               break;
 156   3               }
 157   2      
 158   2            case 's':
 159   2            case 'S':
 160   2               {
 161   3               PC_LINK_IO_Write_String_To_Buffer("*** STOP\n\n");
 162   3               Motor_L = 0;
 163   3               Motor_R = 0;
 164   3               }
 165   2            } 
 166   1         }
 167          
 168          /*------------------------------------------------------------------*-
 169            ---- END OF FILE -------------------------------------------------
 170          -*------------------------------------------------------------------*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    171    ----
   CONSTANT SIZE    =     94    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----       1
   IDATA SIZE       =   ----    ----
C51 COMPILER V6.21  MENU_ROBOT                                                             01/23/2002 18:09:31 PAGE 4   

   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 + -