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

📄 swit_a.lst

📁 时间触发嵌入式系统设计模式:使用8051系列微控制器开发可靠应用
💻 LST
字号:
C51 COMPILER V6.10  SWIT_A                                                                 04/18/2001 16:16:19 PAGE 1   


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

stmt level    source

   1          /*------------------------------------------------------------------*-
   2          
   3             SWIT_A.C (v1.00)
   4           
   5            ------------------------------------------------------------------
   6          
   7             Simple switch interface code, with software debounce.
   8          
   9          
  10             COPYRIGHT
  11             ---------
  12          
  13             This code is from the book:
  14          
  15             PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont 
  16             [Pearson Education, 2001; ISBN: 0-201-33138-1].
  17          
  18             This code is copyright (c) 2001 by Michael J. Pont.
  19           
  20             See book for copyright details and other information.
  21          
  22          -*------------------------------------------------------------------*/
  23          
  24          #include "Main.h"
  25          #include "Port.h"
  26          
  27          #include "Swit_A.h"
  28          
  29          // ------ Public variable definitions ------------------------------
  30          
  31          bit Sw_pressed_G = 0; // The current switch status
  32          
  33          
  34          // ------ Private constants ----------------------------------------
  35          
  36          // Allows NO or NC switch to be used (or other wiring variations)
  37          #define SW_PRESSED (0)
  38          
  39          // SW_THRES must be > 1 for correct debounce behaviour
  40          #define SW_THRES (3)
  41          
  42          
  43          /*------------------------------------------------------------------*-
  44          
  45            SWITCH_Init()
  46          
  47            Initialisation function for the switch library.
  48          
  49          -*------------------------------------------------------------------*/
  50          void SWITCH_Init(void)
  51             {
  52   1         Sw_pin = 1; // Use this pin for input
  53   1         }
  54          
  55          /*------------------------------------------------------------------*-
C51 COMPILER V6.10  SWIT_A                                                                 04/18/2001 16:16:19 PAGE 2   

  56          
  57            SWITCH_Update()
  58            
  59            This is the main switch function.  
  60          
  61            It should be scheduled every 50 - 500 ms.
  62           
  63          -*------------------------------------------------------------------*/
  64          void SWITCH_Update(void)
  65             {
  66   1         static tByte Duration;
  67   1      
  68   1         if (Sw_pin == SW_PRESSED)
  69   1            {
  70   2            Duration += 1;
  71   2      
  72   2            if (Duration > SW_THRES)
  73   2               {
  74   3               Duration = SW_THRES;
  75   3      
  76   3               Sw_pressed_G = 1;  // Switch is pressed...
  77   3               return;
  78   3               }
  79   2      
  80   2            // Switch pressed, but not yet for long enough
  81   2            Sw_pressed_G = 0;
  82   2            return; 
  83   2            }
  84   1          
  85   1         // Switch not pressed - reset the count
  86   1         Duration = 0;
  87   1         Sw_pressed_G = 0;  // Switch not pressed...
  88   1         }
  89          
  90          /*------------------------------------------------------------------*-
  91            ---- END OF FILE -------------------------------------------------
  92          -*------------------------------------------------------------------*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =     30    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      1    ----
   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 + -