亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? key.c

?? uCOS-II作者Jean J.Labrosse所著圖書 《嵌入式系統構件》書后光盤中的源代碼。基本設計了常用嵌入式系統的外圍硬件接口程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
*********************************************************************************************************
*                                    Embedded Systems Building Blocks
*                                 Complete and Ready-to-Use Modules in C
*
*                                         Matrix Keyboard Driver
*
*                            (c) Copyright 1999, Jean J. Labrosse, Weston, FL
*                                           All Rights Reserved
*
* Filename   : KEY.C
* Programmer : Jean J. Labrosse
*********************************************************************************************************
*                                             DESCRIPTION
*
*    The keyboard is assumed to be a matrix having 4 rows by 6 columns.  However, this code works for any
* matrix arrangements up to an 8 x 8 matrix.  By using from one to three of the column inputs, the driver
* can support "SHIFT" keys.  These keys are: SHIFT1, SHIFT2 and SHIFT3.
*
*    Your application software must declare (see KEY.H):
*
*    KEY_BUF_SIZE            Size of the KEYBOARD buffer
*
*    KEY_MAX_ROWS            The maximum number of rows    on the keyboard
*    KEY_MAX_COLS            The maximum number of columns on the keyboard
*
*    KEY_RPT_DLY             Number of scan times before auto repeat executes the function again
*    KEY_RPT_START_DLY       Number of scan times before auto repeat function engages
*
*    KEY_SCAN_TASK_DLY       The number of milliseconds between keyboard scans
*    KEY_SCAN_TASK_PRIO      Sets the priority of the keyboard scanning task
*    KEY_SCAN_TASK_STK_SIZE  The size of the keyboard scanning task stack
*
*    KEY_SHIFT1_MSK          The mask which determines which column input handles the SHIFT1 key
*                                (A 0x00 indicates that a SHIFT1 key is not present)
*    KEY_SHIFT1_OFFSET       The scan code offset to add when the SHIFT1 key is pressed
*
*    KEY_SHIFT2_MSK          The mask which determines which column input handles the SHIFT2 key
*                                (A 0x00 indicates that an SHIFT2 key is not present)
*    KEY_SHIFT2_OFFSET       The scan code offset to add when the SHIFT2 key is pressed
*
*    KEY_SHIFT3_MSK          The mask which determines which column input handles the SHIFT3 key
*                                (A 0x00 indicates that a SHIFT3 key is not present)
*    KEY_SHIFT3_OFFSET       The scan code offset to add when the SHIFT3 key is pressed
*
*
*    KEY_PORT_ROW            The port address of the keyboard matrix ROWs
*    KEY_PORT_COL            The port address of the keyboard matrix COLUMNs
*    KEY_PORT_CW             The port address of the keyboard I/O ports control word
*
*    KeyInitPort, KeySelRow() and KeyGetCol() are the only three hardware specific functions.  This has
*    been done to localize the interface to the hardware in only these two functions and thus make is
*    easier to adapt to your application.
*********************************************************************************************************
*/

/*$PAGE*/
/*
*********************************************************************************************************
*                                              INCLUDE FILES
*********************************************************************************************************
*/

#include "includes.h"

/*
*********************************************************************************************************
*                                            LOCAL CONSTANTS
*********************************************************************************************************
*/

#define KEY_STATE_UP                 1      /* Key scanning states used in KeyScan()                   */
#define KEY_STATE_DEBOUNCE           2
#define KEY_STATE_RPT_START_DLY      3
#define KEY_STATE_RPT_DLY            4

/*
*********************************************************************************************************
*                                            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                  */

static  OS_STK    KeyScanTaskStk[KEY_SCAN_TASK_STK_SIZE];  /* Keyboard scanning task stack             */

static  OS_EVENT *KeySemPtr;                               /* Pointer to keyboard semaphore            */

/*
*********************************************************************************************************
*                                       LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/

static  void      KeyBufIn(INT8U code);     /* Insert scan code into keyboard buffer                   */
static  INT8U     KeyDecode(void);          /* Get scan code from current key pressed                  */
static  BOOLEAN   KeyIsKeyDown(void);       /* See if key has been pressed                             */
static  void      KeyScanTask(void *data);  /* Keyboard scanning task                                  */

/*$PAGE*/
/*
*********************************************************************************************************
*                                INSERT KEY CHARACTER INTO KEYBOARD BUFFER
*
* Description : This function inserts a key character into the keyboard buffer
* Arguments   : code    is the keyboard scan code to insert into the buffer
* Returns     : none
*********************************************************************************************************
*/

static  void  KeyBufIn (INT8U code)
{
    OS_ENTER_CRITICAL();                         /* Start of critical section of code, disable ints    */
    if (KeyNRead < KEY_BUF_SIZE) {               /* Make sure that we don't overflow the buffer        */
        KeyNRead++;                              /* Increment the number of keys read                  */
        KeyBuf[KeyBufInIx++] = code;             /* Store the scan code into the buffer                */
        if (KeyBufInIx >= KEY_BUF_SIZE) {        /* Adjust index to the next scan code to put in buffer*/
            KeyBufInIx = 0;
        }
        OS_EXIT_CRITICAL();                      /* End of critical section of code                    */
        OSSemPost(KeySemPtr);                    /* Signal sem if scan code inserted in the buffer     */
    } else {                                     /* Buffer is full, key scan code is lost              */
        OS_EXIT_CRITICAL();                      /* End of critical section of code                    */
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                           DECODE KEYBOARD
*
* Description : This function is called to determine the key scan code of the key pressed.
* Arguments   : none
* Returns     : the key scan code
*********************************************************************************************************
*/

static  INT8U  KeyDecode (void)
{
    INT8U   col;
    INT8U   row;
    INT8U   offset;
    BOOLEAN done;
    INT8U   col_id;
    INT8U   msk;


    done = FALSE;
    row  = 0;
    while (row < KEY_MAX_ROWS && !done) {             /* Find out in which row key was pressed         */
        KeySelRow(row);                               /* Select a row                                  */
        if (KeyIsKeyDown()) {                         /* See if key is pressed in this row             */
            done = TRUE;                              /* We are done finding the row                   */
        } else {
            row++;                                    /* Select next row                               */
        }
    }
    col    = KeyGetCol();                             /* Read columns                                  */
    offset = 0;                                       /* No SHIFT1, SHIFT2 or SHIFT3 key pressed       */
    if (col & KEY_SHIFT1_MSK) {                       /* See if SHIFT1 key was also pressed            */
        offset += KEY_SHIFT1_OFFSET;
    }
    if (col & KEY_SHIFT2_MSK) {                       /* See if SHIFT2 key was also pressed            */
        offset += KEY_SHIFT2_OFFSET;
    }
    if (col & KEY_SHIFT3_MSK) {                       /* See if SHIFT3 key was also pressed            */
        offset += KEY_SHIFT3_OFFSET;
    }
    msk    = 0x01;                                    /* Set bit mask to scan for the column           */
    col_id =    0;                                    /* Set column value (0..7)                       */
    done   = FALSE;
    while (col_id < KEY_MAX_COLS && !done) {          /* Go through all columns                        */
        if (col & msk) {                              /* See if key was pressed in this columns        */
            done  = TRUE;                             /* Done, i has column value of the key (0..7)    */
        } else {
            col_id++;
            msk <<= 1;
        }
    }
    return (row * KEY_MAX_COLS + offset + col_id);    /* Return scan code                              */
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                         FLUSH KEYBOARD BUFFER
*
* Description : This function clears the keyboard buffer
* Arguments   : none
* Returns     : none
*********************************************************************************************************
*/

void  KeyFlush (void)
{
    while (KeyHit()) {                           /* While there are keys in the buffer...              */
        KeyGetKey(0);                            /* ... extract the next key from the buffer           */
    }
}

/*$PAGE*/
/*
*********************************************************************************************************
*                                                 GET KEY
*
* Description : Get a keyboard scan code from the keyboard driver.
* Arguments   : 'to'     is the amount of time KeyGetKey() will wait (in number of ticks) for a key to be
*                        pressed.  A timeout of '0' means that the caller is willing to wait forever for
*                        a key to be pressed.
* Returns     : != 0xFF  is the key scan code of the key pressed
*               == 0xFF  indicates that there is no key in the buffer within the specified timeout
*********************************************************************************************************
*/

INT8U  KeyGetKey (INT16U to)
{
    INT8U code;
    INT8U err;


    OSSemPend(KeySemPtr, to, &err);              /* Wait for a key to be pressed                       */
    OS_ENTER_CRITICAL();                         /* Start of critical section of code, disable ints    */
    if (KeyNRead > 0) {                          /* See if we have keys in the buffer                  */
        KeyNRead--;                              /* Decrement the number of keys read                  */
        code = KeyBuf[KeyBufOutIx];              /* Get scan code from the buffer                      */
        KeyBufOutIx++;
        if (KeyBufOutIx >= KEY_BUF_SIZE) {       /* Adjust index into the keyboard buffer              */
            KeyBufOutIx = 0;
        }
        OS_EXIT_CRITICAL();                      /* End of critical section of code                    */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品成a人| 韩日欧美一区二区三区| 麻豆传媒一区二区三区| 成人妖精视频yjsp地址| 欧美日韩一卡二卡| 中文字幕精品三区| 亚洲成av人片在线观看| 国产成人精品免费| 日韩一区二区三区四区| 亚洲激情图片qvod| caoporn国产精品| 精品欧美一区二区三区精品久久| 亚洲精品美国一| 国产尤物一区二区在线| 欧美一区二区在线播放| 亚洲女人的天堂| 不卡欧美aaaaa| 久久精品视频在线看| 免费成人在线网站| 91精品国产高清一区二区三区蜜臀| 国产精品福利一区| 成人性生交大片免费看中文| 欧美videossexotv100| 亚洲国产va精品久久久不卡综合| 99视频一区二区| 国产精品久久久久永久免费观看| 久久超碰97中文字幕| 欧美顶级少妇做爰| 五月天亚洲婷婷| 在线电影院国产精品| 亚洲已满18点击进入久久| 色综合久久综合网欧美综合网 | 日韩电影在线免费观看| 欧美三级韩国三级日本三斤| 亚洲精品久久久久久国产精华液| 成人免费视频网站在线观看| 国产精品―色哟哟| 99久久精品一区二区| 亚洲久草在线视频| 精品久久久久久久久久久久久久久 | 久久午夜羞羞影院免费观看| 麻豆精品在线播放| ww久久中文字幕| 国产高清在线精品| 亚洲天堂中文字幕| 欧美在线不卡一区| 蜜臀av一级做a爰片久久| 日韩久久久精品| 国产成人精品免费看| 中文字幕中文字幕一区二区| 色婷婷精品大在线视频| 污片在线观看一区二区| 日韩免费一区二区三区在线播放| 久久精品国产亚洲高清剧情介绍 | 欧美日韩精品二区第二页| 午夜一区二区三区在线观看| 日韩亚洲欧美一区| 国产福利一区在线| 亚洲精选视频免费看| 91精品国产福利| 国产精品中文字幕日韩精品| 综合av第一页| 91精品国产入口| 成人在线综合网| 五月婷婷激情综合网| 久久精品人人爽人人爽| 在线观看91视频| 狠狠久久亚洲欧美| 一区二区三区色| wwwwxxxxx欧美| 欧美日免费三级在线| 国产成人av自拍| 亚洲国产精品欧美一二99| 精品免费日韩av| 色哟哟在线观看一区二区三区| 亚洲v日本v欧美v久久精品| 久久精品综合网| 欧美美女一区二区在线观看| 国产精品1区2区3区在线观看| 亚洲人吸女人奶水| 久久网站热最新地址| 欧美日韩国产系列| 成人国产精品免费| 捆绑调教美女网站视频一区| 亚洲精品视频在线| 国产午夜亚洲精品理论片色戒 | 亚洲免费在线电影| 日韩三级免费观看| 91久久香蕉国产日韩欧美9色| 狠狠狠色丁香婷婷综合激情| 五月综合激情网| 亚洲欧美日韩一区二区| 久久精品在线观看| 日韩亚洲欧美一区二区三区| 在线观看成人小视频| av电影天堂一区二区在线| 久久精品国产免费| 日韩影院在线观看| 成人久久视频在线观看| 婷婷久久综合九色综合伊人色| 国产精品国产三级国产三级人妇| 欧美mv日韩mv国产网站app| 欧美色成人综合| 91黄色免费观看| 91麻豆精品在线观看| 成人丝袜视频网| 国产suv精品一区二区883| 久久国产免费看| 麻豆精品视频在线观看免费| 一区二区三区不卡视频| 亚洲图片激情小说| 亚洲欧美色一区| 综合激情成人伊人| 综合激情成人伊人| 亚洲视频一区在线| 亚洲色图视频免费播放| 亚洲手机成人高清视频| 亚洲精品一二三| 一区二区三区高清在线| 一区二区三区在线观看国产| 亚洲免费毛片网站| 亚洲成在线观看| 免费三级欧美电影| 韩国欧美一区二区| 国产成人综合网站| 91视频免费观看| 色老汉av一区二区三区| 在线免费观看视频一区| 欧美中文字幕不卡| 欧美日韩国产免费| 制服.丝袜.亚洲.另类.中文| 日韩欧美一区二区免费| 久久久久综合网| 国产精品福利在线播放| 亚洲一区av在线| 青草av.久久免费一区| 国产综合色在线| 99这里只有精品| 欧美人与性动xxxx| 精品久久久久久久久久久院品网 | 久久国产精品99久久人人澡| 国产在线不卡一区| 91丝袜美腿高跟国产极品老师| 欧美午夜精品一区二区蜜桃| 欧美日本韩国一区| 久久色.com| 亚洲蜜臀av乱码久久精品蜜桃| 亚洲第一av色| 国产精品一卡二| 欧洲中文字幕精品| 久久久久久久久一| 亚洲大片免费看| 国产999精品久久久久久绿帽| 在线观看区一区二| 午夜视频一区在线观看| 久久国产综合精品| 99精品欧美一区二区蜜桃免费| 5566中文字幕一区二区电影| 国产亚洲一区二区在线观看| 一个色综合av| 大白屁股一区二区视频| 欧洲精品一区二区| 国产午夜精品一区二区三区视频| 亚洲一区二区偷拍精品| 国产福利91精品一区| 欧美人妇做爰xxxⅹ性高电影| 国产人久久人人人人爽| 天天色 色综合| 91视频在线观看免费| 久久综合色一综合色88| 午夜精品久久久久久久久久久| 成人精品免费网站| 精品国产免费一区二区三区四区 | 日精品一区二区| 日本国产一区二区| 国产精品免费久久久久| 久久99精品视频| 91精品婷婷国产综合久久| 亚洲欧美一区二区三区孕妇| 国产一区二区三区观看| 日韩欧美在线一区二区三区| 亚洲综合久久av| 99国产精品久| 国产精品久久久久久久久快鸭 | 国产成人av电影在线观看| 91精品国产色综合久久| 亚洲综合色成人| 91蜜桃婷婷狠狠久久综合9色| 久久在线观看免费| 免费成人在线视频观看| 欧美疯狂性受xxxxx喷水图片| 亚洲夂夂婷婷色拍ww47| 成年人国产精品| 中文字幕一区在线观看视频| 国产99久久精品| 国产精品美女www爽爽爽| 从欧美一区二区三区| 中文字幕精品在线不卡| 99久久综合狠狠综合久久| 国产精品看片你懂得|