C51 COMPILER V9.52.0.0   MC_KEY                                                            08/21/2018 12:02:27 PAGE 1   


C51 COMPILER V9.52.0.0, COMPILATION OF MODULE MC_KEY
OBJECT MODULE PLACED IN .\obj\MC_Key.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE User\Source\MC_Key.c LARGE OMF2 WARNINGLEVEL(0) OPTIMIZE(SIZE) BROWSE NOARE
                    -GS INCDIR(.\Library\Include;.\User\Include) DEBUG PRINT(.\obj\MC_Key.lst) TABS(2) OBJECT(.\obj\MC_Key.obj)

line level    source

   1          
   2          /************************ (C) COPYRIGHT 2015 FT *******************************
   3          * File Name          : 
   4          * Author             : Application Team  Tom.wang 
   5          * Version            : V2.0.0
   6          * Date               : 06/15/2015
   7          * Description        : 
   8          ********************************************************************************
   9          /*******************************************************************************
  10          * All Rights Reserved
  11          *******************************************************************************/
  12          
  13          /* Includes ------------------------------------------------------------------*/
  14          #include <FU6812_MCU.h>
  15          #include <sys_conf.h>
  16          #include <MC_key.h>
  17          
  18          /** @addtogroup FT68xx
  19            * @{
  20            */
  21          
  22          /* Private typedef -----------------------------------------------------------*/
  23          /* Private define ------------------------------------------------------------*/
  24          #define X0_EN                  0         
  25          #define X1_EN                  0
  26          #define X2_EN                  0
  27          #define X3_EN                  0
  28          
  29          /* Private macro -------------------------------------------------------------*/
  30          /* Private variables ---------------------------------------------------------*/
  31          #if(X0_EN)
              key_TypeDef xdata X0;
              #endif
  34          #if(X1_EN)
              key_TypeDef xdata X1;
              #endif
  37          #if(X2_EN)
              key_TypeDef xdata X2;
              #endif
  40          #if(X3_EN)
              key_TypeDef xdata X3;
              #endif
  43          //u8  xdata u8KeyForbid;            //按键禁止标志
  44          
  45          /* Private function prototypes -----------------------------------------------*/
  46          void Key_Config(void);
  47          void Key_init(void);
  48          void Key_Filtrate(void);
  49          /* Private functions ---------------------------------------------------------*/
  50          
  51          void Key_Config(void)
  52          {
  53   1      //端子设置 X1设置输入
  54   1        #if(X0_EN)
C51 COMPILER V9.52.0.0   MC_KEY                                                            08/21/2018 12:02:27 PAGE 2   

                ClrBit(X0_GPIO_PORT,X0_PIN);  //输入使能
                SetBit(X0_PU,X0_PIN);         //上拉电阻
                #endif
  58   1        #if(X1_EN)
                ClrBit(X1_GPIO_PORT,X1_PIN);  //输入使能
                SetBit(X1_PU,X1_PIN);         //上拉电阻
                #endif
  62   1        #if(X2_EN)
                ClrBit(X2_GPIO_PORT,X2_PIN);  //输入使能
                SetBit(X2_PU,X2_PIN);         //上拉电阻
                #endif
  66   1        #if(X3_EN)
                ClrBit(X3_GPIO_PORT,X3_PIN);  //输入使能
                SetBit(X3_PU,X3_PIN);         //上拉电阻
                #endif
  70   1      }
  71          void Key_init(void)
  72          {
  73   1        #if(X0_EN)
                X0.XCount = 0;
                X0.Xflg = FALSE;
                X0.Kflg = FALSE;
                X0.KNum = FALSE;
                #endif
  79   1        
  80   1        #if(X1_EN)
                X1.XCount = 0;
                X1.Xflg = FALSE;
                X1.Kflg = FALSE;
                X1.KNum = FALSE;
                #endif
  86   1      
  87   1        #if(X2_EN)
                X2.XCount = 0;
                X2.Xflg = FALSE;
                X2.Kflg = FALSE;
                X2.KNum = FALSE;
                #endif
  93   1      
  94   1        #if(X3_EN)
                X3.XCount = 0;
                X3.Xflg = FALSE;
                X3.Kflg = FALSE;
                X3.KNum = FALSE;
                #endif
 100   1      }
 101          /*******************************************************************************
 102          * Function Name  : Key_Filtrate
 103          * Description    : 
 104          * Input          : None
 105          * Output         : X1.Kflg  按键按下标志（脉冲有效）    X1.Xflg 端子按下标志（电平有效）
 106          * Return         : None
 107          *******************************************************************************/
 108          
 109          void Key_Filtrate(void)
 110          {
 111   1        //if((Ctl.State != MOTOR_NORMAL)&&(u8KeyForbid != 0X7F))    //X1 X2 在停机下有效
 112   1        {
 113   2          //X0
 114   2          #if(X0_EN)
                  if(X0_GPIO_PIN)  
                  {
C51 COMPILER V9.52.0.0   MC_KEY                                                            08/21/2018 12:02:27 PAGE 3   

                    X0.XCount++;
                    if(X0.KNum == TRUE)            //如果按键滤波ok，等待按键释放
                    {
                      X0.Kflg = TRUE;              //按键按下并释放
                    }
                  }
                  else
                  {
                    X0.XCount--;                   //按键按下计时
                  }
              
                  if(X0.XCount >= KEY_FILTERCOUNT)
                  {
                    X0.Xflg = FALSE;               //端子
                    
                    X0.XCount = KEY_FILTERCOUNT;
                  }
                  else if(X0.XCount <= -KEY_FILTERCOUNT) 
                  {
                    X0.Xflg = TRUE;                //端子按下
                    X0.KNum = TRUE;                //按键
                    
                    X0.XCount = -KEY_FILTERCOUNT;
                  }
                #endif
 142   2      
 143   2        #if(X1_EN)
                  //X1
                  if(X1_GPIO_PIN)  
                  {
                    X1.XCount++;
                    if(X1.KNum == TRUE)            //如果按键滤波ok，等待按键释放
                    {
                      X1.Kflg = TRUE;              //按键按下并释放
                    }
                  }
                  else
                  {
                    X1.XCount--;                   //按键按下计时
                  }
              
                  if(X1.XCount > KEY_FILTERCOUNT)
                  {
                    X1.Xflg = FALSE;               //端子
                    
                    X1.XCount = KEY_FILTERCOUNT;
                  }
                  else if(X1.XCount < -KEY_FILTERCOUNT) 
                  {
                    X1.Xflg = TRUE;                //端子按下
                    X1.KNum = TRUE;                //按键
                    
                    X1.XCount = -KEY_FILTERCOUNT;
                  }
                #endif
 172   2      
 173   2        #if(X2_EN)
                  //X2 
                  if(X2_GPIO_PIN)  
                  {
                    X2.XCount++;
                    if(X2.KNum == TRUE)            //如果按键滤波ok，等待按键释放
C51 COMPILER V9.52.0.0   MC_KEY                                                            08/21/2018 12:02:27 PAGE 4   

                    {
                      X2.Kflg = TRUE;              //按键按下并释放
                    }
                  }
                  else
                  {
                    X2.XCount--;                   //按键按下计时
                  }
                  
                  if(X2.XCount > KEY_FILTERCOUNT)
                  {
                    X2.Xflg = FALSE;               //端子
                    
                    X2.XCount = KEY_FILTERCOUNT;
                  }
                  else if(X2.XCount < -KEY_FILTERCOUNT) 
                  {
                    X2.Xflg = TRUE;                //端子按下
                    X2.KNum = TRUE;                //按键
                    
                    X2.XCount = -KEY_FILTERCOUNT;
                  } 
                #endif
 202   2        }
 203   1        
 204   1        //X3 
 205   1        #if(X3_EN)
                if(X3_GPIO_PIN)  
                {
                  X3.XCount++;
                  if(X3.KNum == TRUE)            //如果按键滤波ok，等待按键释放
                  {
                    X3.Kflg = TRUE;              //按键按下并释放
                  }
                }
                else
                {
                  X3.XCount--;                   //按键按下计时
                }
              
                if(X3.XCount > KEY_FILTERCOUNT)
                {
                  X3.Xflg = FALSE;               //端子
                  
                  X3.XCount = KEY_FILTERCOUNT;
                }
                else if(X3.XCount < -KEY_FILTERCOUNT) 
                {
                  X3.Xflg = TRUE;                //端子按下
                  X3.KNum = TRUE;                //按键
                  
                  X3.XCount = -KEY_FILTERCOUNT;
                }    
                #endif  
 233   1      } 


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =      3    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
C51 COMPILER V9.52.0.0   MC_KEY                                                            08/21/2018 12:02:27 PAGE 5   

   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


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