ATMEL公司AT89C51SND1为主控制器MP3源代码

源代码在线查看: kbd_drv.h

软件大小: 1291 K
上传用户: w277426078
关键词: ATMEL SND1 89C C51
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*H**************************************************************************
				* NAME:         kbd_drv.h         
				*----------------------------------------------------------------------------
				* Copyright (c) 2003 Atmel.
				*----------------------------------------------------------------------------
				* RELEASE:      snd1c-refd-nf-4_0_3      
				* REVISION:     1.8     
				*----------------------------------------------------------------------------
				* PURPOSE:
				* This file contains the keyboard driver definition
				*****************************************************************************/
				
				#ifndef _KBD_DRV_H_
				#define _KBD_DRV_H_
				
				/*_____ I N C L U D E S ____________________________________________________*/
				
				
				/*_____ M A C R O S ________________________________________________________*/
				
				/*----- Hardware Definition -----*/
				#define P_KBD           P1              /* keyboard port P1 */
				
				#define COL2            P1_4
				#define COL1            P1_4
				#define COL0            P1_3
				#define MSK_PKB         ((Byte)0x1B)    /* 00011011 mask for unused bit of P_KBD */
				#define MSK_COL         ((Byte)0x18)    /* 00011000 mask for columns */
				#define MSK_LINE        ((Byte)0x03)    /* 00000011 mask for KBSTA lines */
				
				/*----- Standart Keyboard Behavior -----*/
				#define KB_STD_LVL      ((Byte)0xC0)    /* 11000000 level    KINL1-KINL0 = 0, others = 1 */
				#define KB_STD_MSK      ((Byte)0x0C)    /* 00001100 mask IT  KINM1-KINM0 = 0, others = 1 */
				#define KB_STD          (KB_STD_LVL | KB_STD_MSK)   /* standard keyboard conf. */
				
				#define MSK_STD         ((Byte)0xE7)    /* 11100111 mask for columns */
				
				/*----- Locked Keyboard Behavior -----*/
				#define KB_LCK_LVL      ((Byte)0x40)    /* 01000000 level    KINL2 = 1, others = 0 */
				#define KB_LCK_MSK      ((Byte)0x0B)    /* 00001011 mask IT  KINM2 = 0, others = 1 */
				#define KB_LCK          (KB_LCK_LVL | KB_LCK_MSK)   /* locked keyboard conf. */
				
				#define MSK_LCK         ((Byte)0xFF)    /* locked; mask for columns: 11111111 */
				
				/*----- Key Decoding Mask -----*/
				#define NO_KEY          ((Byte)0x1B)    // 00011011
				#define NK_COL0         ((Byte)0x13)    // 00010011
				#define NK_COL1         ((Byte)0x0B)    // 00001011
				#define NK_COL2         (P_KBD & MSK_PKB)
				#define NK_COL3         (P_KBD & MSK_PKB)
				
				/*----- Key Definition -----*/
				#define KEY_0_0         ((Byte)0x02)    /* 00000010 Row0 Col0 */
				#define KEY_0_1         ((Byte)0x0A)    /* 00001010 Row0 Col1 */
				
				
				#define KEY_1_0         ((Byte)0x01)    // 00000001
				#define KEY_1_1         ((Byte)0x09)    // 00001001
				
				#define KEY_X_0         ((Byte)0x10)    /* 00010000 Row0 and Row1 COL0 */
				#define KEY_X_1         ((Byte)0x08)    /* 00001000 Row0 and Row1 COL1 */
				
				/*----- Macro-command -----*/
				
				
				/*_____ D E F I N I T I O N ________________________________________________*/
				
				
				/*_____ D E C L A R A T I O N ______________________________________________*/
				
				void    kbd_init (void);
				Byte    kbd_decode (void);
				
				#define Kbd_enable_int()        (IEN1 |= MSK_EKB)
				#define Kbd_disable_int()       (IEN1 &= ~MSK_EKB)
				#define Kbd_enable_pd_exit()    (KBSTA |= MSK_KPDE)
				#define Kbd_disable_pd_exit()   (KBSTA &= ~MSK_KPDE)
				#define Kbd_key_pressed()       ((KBSTA & MSK_LINE & ~KBCON) != 0)
				#define Kbd_key_locked()        (LOCK_ROW == 0)
				
				void    kbd_task_init (void);
				
				#endif  /* _KBD_DRV_H_ */
							

相关资源