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

📄 kbd_drv.lst

📁 这是atmel公司的89C51SND1C的mp3源程序
💻 LST
字号:
C51 COMPILER V6.20c  KBD_DRV                                                               07/10/2002 15:17:33 PAGE 1   


C51 COMPILER V6.20c, COMPILATION OF MODULE KBD_DRV
OBJECT MODULE PLACED IN ..\obj\kbd_drv.obj
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE ..\..\..\lib\kbd\kbd_drv.c BROWSE INCDIR(..\src\system;..\..\..\lib) DEFINE
                    -(KEIL) DEBUG OBJECTEXTEND PRINT(.\kbd_drv.lst) OBJECT(..\obj\kbd_drv.obj) 

stmt level    source

   1          /*C**************************************************************************
   2          * $RCSfile: kbd_drv.c,v $
   3          *----------------------------------------------------------------------------
   4          * Copyright (c) 2002 Atmel.
   5          *----------------------------------------------------------------------------
   6          * RELEASE:      $Name: DEMO_FAT_1_2_5 $      
   7          * REVISION:     $Revision: 1.3 $     
   8          * FILE_CVSID:   $Id: kbd_drv.c,v 1.3 2002/05/24 09:51:13 njourdan Exp $       
   9          *----------------------------------------------------------------------------
  10          * PURPOSE:
  11          * This file contains the keypad driver routines
  12          *
  13          * NOTES:
  14          * Driver Configuration:
  15          *   - KBD_EXIT_PD in config.h define as:
  16          *      TRUE:  to allow exit of power down by keyboard
  17          *      FALSE: to disallow exit of power down by keyboard
  18          *   - LOCK_ROW in config.h
  19          *   - KEY_LOCK in config.h
  20          * Global Variables:
  21          *   - gl_kbd_lock in bdata space
  22          *****************************************************************************/
  23          
  24          /*_____ I N C L U D E S ____________________________________________________*/
  25          
  26          #include "config.h"                         /* lib configuration header */
  27          #include "kbd_drv.h"                        /* Keyboard driver definition */
  28          
  29          
  30          /*_____ M A C R O S ________________________________________________________*/
  31          
  32          
  33          /*_____ D E F I N I T I O N ________________________________________________*/
  34          
  35          extern  bdata   bit     gl_kbd_lock;
  36          
  37          /*_____ D E C L A R A T I O N ______________________________________________*/
  38          
  39          static  void    kbd_set_prio (Byte);
  40          static  void    kbd_install (void);
  41          
  42          
  43          /*F**************************************************************************
  44          * NAME: kbd_init
  45          *----------------------------------------------------------------------------
  46          * PARAMS:
  47          *
  48          * return:
  49          *----------------------------------------------------------------------------
  50          * PURPOSE: 
  51          *   Keyboard initialisation function
  52          *----------------------------------------------------------------------------
  53          * EXAMPLE:
  54          *----------------------------------------------------------------------------
C51 COMPILER V6.20c  KBD_DRV                                                               07/10/2002 15:17:33 PAGE 2   

  55          * NOTE:
  56          *----------------------------------------------------------------------------
  57          * REQUIREMENTS:
  58          * ram/xram:
  59          * cycle:
  60          * stack: 
  61          * code:
  62          *****************************************************************************/
  63          void kbd_init (void)
  64          {
  65   1        P_KBD |= MSK_COL;             /* all columns inactive */
  66   1        gl_kbd_lock = (!LOCK_ROW);    /* Lock Key decoding */
  67   1      
  68   1        #if KBD_EXIT_PD == TRUE
                Kbd_enable_pd_exit();         /* enable keyboard Power-Down exit */
                kbd_set_prio(KBD_PRIO);
                Kbd_enable_int();             /* enable or re-enable the keyboard interrupt */
                #endif
  73   1      
  74   1        kbd_install();
  75   1      }
  76          
  77          
  78          /*F**************************************************************************
  79          * NAME: kbd_install
  80          *----------------------------------------------------------------------------
  81          * PARAMS:
  82          *
  83          * return:
  84          *----------------------------------------------------------------------------
  85          * PURPOSE: 
  86          *   Keyboard IT and columns mask init
  87          *----------------------------------------------------------------------------
  88          * EXAMPLE:
  89          *----------------------------------------------------------------------------
  90          * NOTE:
  91          *----------------------------------------------------------------------------
  92          * REQUIREMENTS:
  93          * ram/xram:
  94          * cycle:
  95          * stack: 
  96          * code:
  97          
  98          *****************************************************************************/
  99          void kbd_install (void)
 100          {
 101   1        if (gl_kbd_lock)
 102   1        {
 103   2          KBCON = KB_LCK;
 104   2          P_KBD &= MSK_LCK;
 105   2        }
 106   1        else
 107   1        {
 108   2          KBCON = KB_STD;
 109   2          P_KBD &= MSK_STD;
 110   2        }
 111   1        KBSTA = KBSTA;                /* dummy read for clearing pending interrupt */
 112   1      
 113   1        #if KBD_EXIT_PD
                Kbd_enable_int();             /* enable or re-enable the kbd interrupt */
                #endif
 116   1      }
C51 COMPILER V6.20c  KBD_DRV                                                               07/10/2002 15:17:33 PAGE 3   

 117          
 118          
 119          /*F**************************************************************************
 120          * NAME: kbd_set_prio
 121          *----------------------------------------------------------------------------
 122          * PARAMS:
 123          *
 124          * return:
 125          *----------------------------------------------------------------------------
 126          * PURPOSE: 
 127          *   Set the keyboard interface priority interrupt
 128          *----------------------------------------------------------------------------
 129          * EXAMPLE:
 130          *----------------------------------------------------------------------------
 131          * NOTE:
 132          *----------------------------------------------------------------------------
 133          * REQUIREMENTS:
 134          * ram/xram:
 135          * cycle:
 136          * stack: 
 137          * code:
 138          *****************************************************************************/
 139          #if KBD_EXIT_PD
              void kbd_set_prio (Byte priority)
              {
                if ((priority == 1) || (priority == 3))     /* set LSB priority bit */
                {
                  IPL1 |=  MSK_EKB;
                }
                if ((priority == 2) || (priority == 3))     /* set MSB priority bit */
                {
                  IPH1 |= MSK_EKB;
                }
              }
              #endif
 152          
 153          
 154          /*F**************************************************************************
 155          * NAME: kbd_decode
 156          *----------------------------------------------------------------------------
 157          * PARAMS:
 158          *
 159          * return:
 160          *   Decoded key pressed
 161          *----------------------------------------------------------------------------
 162          * PURPOSE: 
 163          *   Decode the key that generated an IT
 164          *----------------------------------------------------------------------------
 165          * EXAMPLE:
 166          *----------------------------------------------------------------------------
 167          * NOTE:
 168          *----------------------------------------------------------------------------
 169          * REQUIREMENTS:
 170          * ram/xram:
 171          * cycle:
 172          * stack: 
 173          * code:
 174          *****************************************************************************/
 175          Byte kbd_decode (void)
 176          {
 177   1      Byte key;
 178   1      
C51 COMPILER V6.20c  KBD_DRV                                                               07/10/2002 15:17:33 PAGE 4   

 179   1        if (gl_kbd_lock)
 180   1        {
 181   2          gl_kbd_lock = FALSE;
 182   2          kbd_install();
 183   2          return (KEY_LOCK);
 184   2        }
 185   1        else
 186   1        {
 187   2          P_KBD |= MSK_COL;           /* all columns inactive */
 188   2       
 189   2          /* COL3 = 0;                /* COL3 test (always 0) */
 190   2          key = (P_KBD & MSK_PKB);
 191   2          if (key != NK_COL3)
 192   2          {
 193   3            if (key == KEY_LOCK)
 194   3            {
 195   4              gl_kbd_lock = TRUE;     /* signal key locked */
 196   4            }
 197   3            kbd_install();
 198   3            return (key);
 199   3          }
 200   2      
 201   2          COL2 = 0;                   /* COL2 test */
 202   2          key = (P_KBD & MSK_PKB);
 203   2          if (key != NK_COL2)
 204   2          {
 205   3            kbd_install();
 206   3            return (key);
 207   3          }
 208   2      
 209   2          COL1 = 0;                   /* COL1 test */
 210   2          key = (P_KBD & MSK_PKB);
 211   2          if (key != NK_COL1)
 212   2          {
 213   3            kbd_install();
 214   3            return (key);
 215   3          }
 216   2        
 217   2          COL0 = 0;                   /* COL0 test */
 218   2          key = (P_KBD & MSK_PKB);
 219   2          if (key != NK_COL0)
 220   2          {
 221   3            kbd_install();
 222   3            return (key);
 223   3          }
 224   2        }
 225   1      }
 226          
 227          
 228          /*F**************************************************************************
 229          * NAME: kbd_int
 230          *----------------------------------------------------------------------------
 231          * PARAMS:
 232          *
 233          * return:
 234          *----------------------------------------------------------------------------
 235          * PURPOSE: 
 236          *   Keyboard interrupt function
 237          *----------------------------------------------------------------------------
 238          * EXAMPLE:
 239          *----------------------------------------------------------------------------
 240          * NOTE:
C51 COMPILER V6.20c  KBD_DRV                                                               07/10/2002 15:17:33 PAGE 5   

 241          *   This isr is called when a key is pressed to get out power-down Interrupt
 242          *   is re-enable in the install routine
 243          *----------------------------------------------------------------------------
 244          * REQUIREMENTS:
 245          * ram/xram:
 246          * cycle:
 247          * stack: 
 248          * code:
 249          *****************************************************************************/
 250          #if KBD_EXIT_PD
              Interrupt(kbd_int (void), IRQ_KBD)
              {
                Kbd_disable_int();              /* disable interrupt */
              }
              #endif
 256          
 257          
 258          


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