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

📄 key_cfg.h

📁 ucosII在TMS320LF2407成功移植的源代码
💻 H
字号:
/*
*********************************************************************************************************
*                           Shanghai Maritime University
*                                                 Pudong Avenue 1550#
*
*                                        (c)Copyright 2005,SMSC,Shanghai,China
*                                                    All Rights Reserved
*
*
* Filename   : Key_cfg.h
* Programmer : Jason Chen (Refer to Jean J. Labrosse's Matrix keyboard driver)
*********************************************************************************************************
*                                          USER DEFINED CONSTANTS
*
* Note: These #defines would normally reside in your application specific code.
*********************************************************************************************************
*/
//#include "Data_types.h"
#ifndef KEY_CFG_H
#define KEY_CFG_H

#include "includes.h"


#define  KEY_BUF_SIZE               10      /* Size of the KEYBOARD buffer                             */

#define KEY_PORT_VAL      port8001     /* Port of single-switch keyboard interface */

#define KEY_PORT_MAX_BITS     16    /* Port bits of single-switch keyboard interface */

#define  KEY_RPT_DLY                 2      /* Number of scan times before auto repeat executes again  */
#define  KEY_RPT_START_DLY          10      /* Number of scan times before auto repeat function engages*/

#define  KEY_SCAN_TASK_DLY          100      /* Number of milliseconds between keyboard scans           */
#define  KEY_SCAN_TASK_PRIO         10      /* Set priority of keyboard scan task                      */
#define  KEY_SCAN_TASK_STK_SIZE   400      /* Size of keyboard scan task stack                        */

#define MULTITASK          1
#define OS                uCOS_II
/*
*********************************************************************************************************
*                                            Key scanning states used in key sanning FSM
*********************************************************************************************************
*/
#define KEY_STATE_UP                 1     
#define KEY_STATE_DEBOUNCE           2
#define KEY_STATE_RPT_START_DLY      3
#define KEY_STATE_RPT_DLY            4


/*
*****************************************************
*             Definition of Instruction and Data Ports
*****************************************************
*/
#if MULTITASK == 1

#if OS == uCOS_II
//static OS_EVENT *DispSem;
static  OS_STK    KeyScanTaskStk[KEY_SCAN_TASK_STK_SIZE];  /* Keyboard scanning task stack             */
static  OS_EVENT *KeySemPtr;                               /* Pointer to keyboard semaphore            */
#define xOSSemBCreate(options,init)               OSSemCreate(init)
#define xOSSemTake(sem,timeout,addtion)     OSSemPend(sem,timeout,addtion)
#define xOSSemGive(sem)                                 OSSemPost(sem)
#define DELAY(Ticks)                                       Delay(Ticks)
#define xOSTaskCreate(name, \
	                              priority, \
	                              stack,\
	                              entrypoint,\
	                              arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)    OSTaskCreate( entrypoint,arg1,stack,priority)
#define xOSTimeDlyHMSM(hour,minute, second,millisecond)        OSTimeDlyHMSM(hour,minute, second,millisecond)                     
 /*--------------------------------------------------------
   If the macroes of 'INT_DISABLE()' and 'INT_ENABLE() ' are defined, 
   remember to add ';' at  each end of these two macro contents.
   -------------------------------------------------------*/
#define INT_DISABLE()      asm("   SETC INTM");
#define INT_ENABLE()       asm("   CLRC INTM");
#endif

#else
#define DELAY(cnt)     Delay(cnt)
/*--------------------------------------------------------
   If the macroes of 'INT_DISABLE()' and 'INT_ENABLE() ' are defined, 
   remember to add ';' at  each end of these two macro contents.
   -------------------------------------------------------*/
#define INT_DISABLE()      asm("   SETC INTM");
#define INT_ENABLE()       asm("   CLRC INTM");
#define OS_ENTER_CRITICAL()
#define OS_EXIT_CRITICAL()  

#endif
ioport unsigned char port8001;
/*
*********************************************************************************************************
*                                            GLOBAL VARIABLES
*********************************************************************************************************
*/

static  INT8U     KeyBuf[KEY_BUF_SIZE];     /* Keyboard buffer                                         */
static  INT8U     KeyBufInIx;               /* Index into key buf where next scan code will be inserted*/
static  INT8U     KeyBufOutIx;              /* Index into key buf where next scan code will be removed */
static  INT16U    KeyDownTmr;               /* Counts how long key has been pressed                    */
static  INT8U     KeyNRead;                 /* Number of keys read from the keyboard                   */

static  INT8U     KeyRptStartDlyCtr;        /* Number of scan times before auto repeat is started      */
static  INT8U     KeyRptDlyCtr;             /* Number of scan times before auto repeat executes again  */

static  INT8U     KeyScanState;             /* Current state of key scanning function                  */

#endif /* End of KEY_CFG_H */
/*
*********************************************************************************************************
*                                           End  of  Key_cfg.h
*********************************************************************************************************
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -